diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerBootApp.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerBootApp.java index e6705f9ab0..759184d766 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerBootApp.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerBootApp.java @@ -282,8 +282,8 @@ SpringProcessConnectorRemote localAppsFromCommandsConnector(SimpleLanguageServer return new JdtReconciler(cuCache, config, reconcilers, projectObserver); } - @Bean SpringXMLCompletionEngine xmlCompletionEngine(SimpleLanguageServer server, JavaProjectFinder projectFinder, SpringSymbolIndex symbolIndex, BootJavaConfig config) { - return new SpringXMLCompletionEngine(server, projectFinder, symbolIndex, config); + @Bean SpringXMLCompletionEngine xmlCompletionEngine(SimpleLanguageServer server, JavaProjectFinder projectFinder, SpringSymbolIndex symbolIndex, SpringMetamodelIndex springIndex, BootJavaConfig config) { + return new SpringXMLCompletionEngine(server, projectFinder, symbolIndex, springIndex, config); } @Bean SpringPropertiesCompletionEngine propertiesCompletionEngine(BootLanguageServerParams params, JavaProjectFinder projectFinder, SourceLinks sourceLinks, BootJavaConfig config) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java index 7238997b0b..f3a7466282 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java @@ -59,6 +59,7 @@ import org.eclipse.lsp4j.CompletionItemKind; import org.springframework.ide.vscode.boot.app.BootJavaConfig; import org.springframework.ide.vscode.boot.app.SpringSymbolIndex; +import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex; import org.springframework.ide.vscode.boot.xml.completions.BeanRefCompletionProposalProvider; import org.springframework.ide.vscode.boot.xml.completions.ConstructorArgNameCompletionProposalProvider; import org.springframework.ide.vscode.boot.xml.completions.GenericXMLCompletionProposal; @@ -91,7 +92,8 @@ public class SpringXMLCompletionEngine implements ICompletionEngine, LanguageSpe public SpringXMLCompletionEngine( SimpleLanguageServer server, JavaProjectFinder projectFinder, - SpringSymbolIndex symbolIndex, + SpringSymbolIndex symbolIndex, + SpringMetamodelIndex springIndex, BootJavaConfig config ) { @@ -102,7 +104,7 @@ public SpringXMLCompletionEngine( TypeCompletionProposalProvider classesAndInterfacesProvider = new TypeCompletionProposalProvider(server, projectFinder, true, true, true, false); TypeCompletionProposalProvider packagesProvider = new TypeCompletionProposalProvider(server, projectFinder, true, false, false, false); - BeanRefCompletionProposalProvider beanRefProvider = new BeanRefCompletionProposalProvider(projectFinder, symbolIndex); + BeanRefCompletionProposalProvider beanRefProvider = new BeanRefCompletionProposalProvider(projectFinder, springIndex); PropertyNameCompletionProposalProvider propertyNameProvider = new PropertyNameCompletionProposalProvider(projectFinder); ConstructorArgNameCompletionProposalProvider constructorArgNameProvider = new ConstructorArgNameCompletionProposalProvider(projectFinder); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java index 4aff7a5f97..17875916f3 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.springframework.ide.vscode.boot.xml.completions; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -19,15 +20,14 @@ import org.eclipse.lemminx.dom.DOMNode; import org.eclipse.lemminx.dom.parser.Scanner; import org.eclipse.lsp4j.CompletionItemKind; -import org.springframework.ide.vscode.boot.app.SpringSymbolIndex; -import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation; -import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation; +import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex; import org.springframework.ide.vscode.boot.xml.XMLCompletionProvider; import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits; import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal; import org.springframework.ide.vscode.commons.languageserver.completion.InternalCompletionList; import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.commons.protocol.spring.Bean; import org.springframework.ide.vscode.commons.util.FuzzyMatcher; import org.springframework.ide.vscode.commons.util.Renderable; import org.springframework.ide.vscode.commons.util.text.TextDocument; @@ -40,11 +40,11 @@ public class BeanRefCompletionProposalProvider implements XMLCompletionProvider { private final JavaProjectFinder projectFinder; - private final SpringSymbolIndex symbolIndex; + private final SpringMetamodelIndex index; - public BeanRefCompletionProposalProvider(JavaProjectFinder projectFinder, SpringSymbolIndex symbolIndex) { + public BeanRefCompletionProposalProvider(JavaProjectFinder projectFinder, SpringMetamodelIndex index) { this.projectFinder = projectFinder; - this.symbolIndex = symbolIndex; + this.index = index; } @Override @@ -66,11 +66,9 @@ public InternalCompletionList getCompletions(TextDocument doc, String namespace, final String searchPrefix = prefix; - List addonInfos = symbolIndex.getAllAdditionalInformation(addonInfo -> addonInfo instanceof BeansSymbolAddOnInformation); - - List completionItems = addonInfos.stream() - .map(info -> (BeansSymbolAddOnInformation) info) - .map(beanInfo -> beanInfo.getBeanID()) + Bean[] beansOfProject = this.index.getBeansOfProject(project.getElementName()); + List completionItems = Arrays.stream(beansOfProject) + .map(bean -> bean.getName()) .filter(beanID -> beanID != null && beanID.length() > 0) .map(beanID -> Tuples.of(beanID, FuzzyMatcher.matchScore(searchPrefix, beanID))) .filter(tuple -> tuple.getT2() != 0.0)