Skip to content

Commit a50b03b

Browse files
authored
Diagnostics of extension-less files are cleared (#1066)
* Update initialization code of workspace services to listen to all delete events (so diagnostics of deleted files can be properly cleared) * Revert "Update initialization code of workspace services to listen to all delete events (so diagnostics of deleted files can be properly cleared)" This reverts commit ec0898c. * Add glob pattern to listen to all rename and delete events * Have separate glob patterns for creation, deletion, and renaming of files
1 parent bc693a9 commit a50b03b

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/parametric/capabilities/FileOperationCapability.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
package org.rascalmpl.vscode.lsp.parametric.capabilities;
2828

2929
import java.util.ArrayList;
30+
import java.util.Collections;
3031
import java.util.List;
3132
import java.util.concurrent.CompletableFuture;
3233
import java.util.concurrent.Executor;
@@ -80,13 +81,31 @@ protected final FileOperationOptions mergeOptions(FileOperationOptions o1, FileO
8081
.map(FileOperationCapability::extensionFilter)
8182
.collect(Collectors.toList());
8283

83-
var anyFolder = new FileOperationPattern("**/*");
84-
anyFolder.setMatches(FileOperationPatternKind.Folder);
85-
patterns.add(new FileOperationFilter(anyFolder));
84+
for (var glob : folderOperationGlobs()) {
85+
var pattern = new FileOperationPattern(glob);
86+
pattern.setMatches(FileOperationPatternKind.Folder);
87+
patterns.add(new FileOperationFilter(pattern));
88+
}
89+
90+
for (var glob : fileOperationGlobs()) {
91+
var pattern = new FileOperationPattern(glob);
92+
pattern.setMatches(FileOperationPatternKind.File);
93+
patterns.add(new FileOperationFilter(pattern));
94+
}
8695

8796
return CompletableFutureUtils.completedFuture(new FileOperationOptions(patterns), exec);
8897
}
8998

99+
protected List<String> folderOperationGlobs() {
100+
// By default, do receive notifications about each folder
101+
return List.of("**/*");
102+
}
103+
104+
protected List<String> fileOperationGlobs() {
105+
// By default, don't receive notifications about any file
106+
return Collections.emptyList();
107+
}
108+
90109
/**
91110
* Options to use when registering statically, i.e. nothing is known about the registered languages.
92111
*/
@@ -141,6 +160,12 @@ protected void registerStatically(ServerCapabilities result) {
141160
fileOperationCapabilities(result).setDidDelete(staticOptions());
142161
}
143162

163+
@Override
164+
protected List<String> fileOperationGlobs() {
165+
// Receiving notifications about extension-less files would be enough, but it seems "extension-less file"
166+
// cannot be expressed using LSP's glob patterns.
167+
return List.of("**/*");
168+
}
144169
}
145170

146171
/**

0 commit comments

Comments
 (0)