File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1028,6 +1028,39 @@ void onDidSaveDocument(DidSaveTextDocumentParams params)
10281028 }
10291029}
10301030
1031+ @protocolNotification(" workspace/didChangeWatchedFiles" )
1032+ void onDidChangeWatchedFiles (DidChangeWatchedFilesParams params)
1033+ {
1034+ foreach (c; params.changes)
1035+ {
1036+ trace(" watched file did change: " , c);
1037+
1038+ string filename = c.uri.uriToFile;
1039+
1040+ auto inst = backend.getBestInstance! ClangCompilationDatabaseComponent(filename);
1041+ if (! inst)
1042+ continue ;
1043+
1044+ string ccdbPath = inst.get ! ClangCompilationDatabaseComponent.getDbPath();
1045+ if (! ccdbPath)
1046+ continue ;
1047+
1048+ filename = filename.buildNormalizedPath();
1049+
1050+ if (filename == ccdbPath)
1051+ {
1052+ if (c.type == FileChangeType.deleted)
1053+ {
1054+ filename = discoverCcdb(inst.cwd);
1055+ tracef(" CCDB file deleted. Switching from %s to %s" , ccdbPath, filename ? filename : " (null)" );
1056+ }
1057+
1058+ tracef(" will (re)load %s" , filename);
1059+ inst.get ! ClangCompilationDatabaseComponent.setDbPath(filename);
1060+ }
1061+ }
1062+ }
1063+
10311064shared static this ()
10321065{
10331066 import core.time : MonoTime;
You can’t perform that action at this time.
0 commit comments