do not configure boot ls as server for general xml docs and instead use watch files mechanism to detect changes to XML files
This commit is contained in:
@@ -14,10 +14,6 @@
|
||||
contentType="org.eclipse.jdt.core.javaSource"
|
||||
id="org.eclipse.languageserver.languages.springboot">
|
||||
</contentTypeMapping>
|
||||
<contentTypeMapping
|
||||
contentType="org.eclipse.core.runtime.xml"
|
||||
id="org.eclipse.languageserver.languages.springboot">
|
||||
</contentTypeMapping>
|
||||
<contentTypeMapping
|
||||
contentType="org.springframework.boot.ide.properties.application.properties"
|
||||
id="org.eclipse.languageserver.languages.springboot"
|
||||
|
||||
@@ -96,6 +96,10 @@ public class SpringSymbolIndex {
|
||||
private SpringIndexerXML springIndexerXML;
|
||||
private SpringIndexerJava springIndexerJava;
|
||||
|
||||
private String watchXMLDeleteRegistration;
|
||||
private String watchXMLCreatedRegistration;
|
||||
private String watchXMLChangedRegistration;
|
||||
|
||||
private SimpleWorkspaceService getWorkspaceService() {
|
||||
return server.getServer().getWorkspaceService();
|
||||
}
|
||||
@@ -143,8 +147,7 @@ public class SpringSymbolIndex {
|
||||
}
|
||||
|
||||
public void serverInitialized() {
|
||||
List<String> globPattern = Arrays.stream(this.indexer).map(indexer ->
|
||||
indexer.getFileWatchPatterns()).flatMap(Arrays::stream).collect(Collectors.toList());
|
||||
List<String> 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<String> 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<Void> initializeProject(IJavaProject project) {
|
||||
try {
|
||||
if (SpringProjectUtil.isBootProject(project) || SpringProjectUtil.isSpringProject(project)) {
|
||||
|
||||
Reference in New Issue
Block a user