diff --git a/eclipse-language-servers/org.springframework.tooling.boot.ls/plugin.xml b/eclipse-language-servers/org.springframework.tooling.boot.ls/plugin.xml
index 9a2ff4c42..6e01405b7 100644
--- a/eclipse-language-servers/org.springframework.tooling.boot.ls/plugin.xml
+++ b/eclipse-language-servers/org.springframework.tooling.boot.ls/plugin.xml
@@ -14,10 +14,6 @@
contentType="org.eclipse.jdt.core.javaSource"
id="org.eclipse.languageserver.languages.springboot">
-
-
globPattern = Arrays.stream(this.indexer).map(indexer ->
- indexer.getFileWatchPatterns()).flatMap(Arrays::stream).collect(Collectors.toList());
+ List globPattern = Arrays.asList(springIndexerJava.getFileWatchPatterns());
getWorkspaceService().getFileObserver().onFileDeleted(globPattern, (file) -> {
deleteDocument(new TextDocumentIdentifier(file).getUri());
@@ -157,6 +160,38 @@ public class SpringSymbolIndex {
});
}
+ public void configureIndexer(boolean springXMLSupportEnabled) {
+ synchronized (this) {
+ if (springXMLSupportEnabled && !(Arrays.asList(this.indexer).contains(springIndexerXML))) {
+ this.indexer = new SpringIndexer[] {springIndexerJava, springIndexerXML};
+
+ List globPattern = Arrays.asList(springIndexerXML.getFileWatchPatterns());
+
+ watchXMLDeleteRegistration = getWorkspaceService().getFileObserver().onFileDeleted(globPattern, (file) -> {
+ deleteDocument(new TextDocumentIdentifier(file).getUri());
+ });
+ watchXMLCreatedRegistration = getWorkspaceService().getFileObserver().onFileCreated(globPattern, (file) -> {
+ createDocument(new TextDocumentIdentifier(file).getUri());
+ });
+ watchXMLChangedRegistration = getWorkspaceService().getFileObserver().onFileChanged(globPattern, (file) -> {
+ updateDocument(new TextDocumentIdentifier(file).getUri(), null);
+ });
+
+ }
+ else if (!springXMLSupportEnabled && Arrays.asList(this.indexer).contains(springIndexerXML)) {
+ this.indexer = new SpringIndexer[] {springIndexerJava};
+
+ getWorkspaceService().getFileObserver().unsubscribe(watchXMLChangedRegistration);
+ getWorkspaceService().getFileObserver().unsubscribe(watchXMLCreatedRegistration);
+ getWorkspaceService().getFileObserver().unsubscribe(watchXMLDeleteRegistration);
+
+ watchXMLChangedRegistration = null;
+ watchXMLCreatedRegistration = null;
+ watchXMLDeleteRegistration = null;
+ }
+ }
+ }
+
public void shutdown() {
try {
synchronized(this) {
@@ -173,15 +208,6 @@ public class SpringSymbolIndex {
}
}
- public void configureIndexer(boolean springXMLSupportEnabled) {
- if (springXMLSupportEnabled) {
- this.indexer = new SpringIndexer[] {springIndexerJava, springIndexerXML};
- }
- else {
- this.indexer = new SpringIndexer[] {springIndexerJava};
- }
- }
-
public CompletableFuture initializeProject(IJavaProject project) {
try {
if (SpringProjectUtil.isBootProject(project) || SpringProjectUtil.isSpringProject(project)) {