Refactoring in preparation of using injecting
ad-hoc Property index into ValueProvider This is so we can try to use it to compute user-defined logger groups. See https://www.pivotaltracker.com/n/projects/1346850
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<factorypath>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/language-server-starter/1.1.0-SNAPSHOT/language-server-starter-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter/2.0.5.RELEASE/spring-boot-starter-2.0.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-autoconfigure/2.0.5.RELEASE/spring-boot-autoconfigure-2.0.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-logging/2.0.5.RELEASE/spring-boot-starter-logging-2.0.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
@@ -10,8 +9,6 @@
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/eclipse/org.json/1.0/org.json-1.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/java-properties/1.1.0-SNAPSHOT/java-properties-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/commons-util/1.1.0-SNAPSHOT/commons-util-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/javolution/javolution-core-java/6.0.0/javolution-core-java-6.0.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/cglib/cglib/3.2.7/cglib-3.2.7.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/ant/ant/1.10.3/ant-1.10.3.jar" enabled="true" runInBatchMode="false"/>
|
||||
@@ -20,7 +17,6 @@
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/jsoup/jsoup/1.9.2/jsoup-1.9.2.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/guava/19.0/guava-19.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/antlr/antlr4-runtime/4.5.3/antlr4-runtime-4.5.3.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/commons-maven/1.1.0-SNAPSHOT/commons-maven-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/maven/maven-core/3.3.9/maven-core-3.3.9.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/maven/maven-model/3.3.9/maven-model-3.3.9.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/maven/maven-settings/3.3.9/maven-settings-3.3.9.jar" enabled="true" runInBatchMode="false"/>
|
||||
@@ -61,11 +57,8 @@
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/maven/wagon/wagon-file/2.10/wagon-file-2.10.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/maven/wagon/wagon-provider-api/2.10/wagon-provider-api-2.10.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/commons-java/1.1.0-SNAPSHOT/commons-java-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/jboss/jandex/2.0.5.Final/jandex-2.0.5.Final.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/commons-gradle/1.1.0-SNAPSHOT/commons-gradle-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/gradle/gradle-tooling-api/4.3/gradle-tooling-api-4.3.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/commons-language-server/1.1.0-SNAPSHOT/commons-language-server-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot/2.0.5.RELEASE/spring-boot-2.0.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-context/5.0.9.RELEASE/spring-context-5.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-aop/5.0.9.RELEASE/spring-aop-5.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
@@ -73,12 +66,11 @@
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-expression/5.0.9.RELEASE/spring-expression-5.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/io/projectreactor/reactor-core/3.1.9.RELEASE/reactor-core-3.1.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/reactivestreams/reactive-streams/1.0.2/reactive-streams-1.0.2.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/commons-yaml/1.1.0-SNAPSHOT/commons-yaml-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/javax/inject/javax.inject/1/javax.inject-1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/ide/vscode/commons-boot-app-cli/1.1.0-SNAPSHOT/commons-boot-app-cli-1.1.0-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/json/json/20160810/json-20160810.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/commons-codec/commons-codec/1.11/commons-codec-1.11.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/usr/lib/jvm/java-8-oracle/jre/../lib/tools.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/ow2/asm/asm/6.1.1/asm-6.1.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/eclipse/jdt/org.eclipse.jdt.core/3.15.0/org.eclipse.jdt.core-3.15.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/eclipse/platform/org.eclipse.core.resources/3.13.100/org.eclipse.core.resources-3.13.100.jar" enabled="true" runInBatchMode="false"/>
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.app;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
@@ -25,11 +27,17 @@ import org.springframework.ide.vscode.boot.java.links.JdtJavaDocumentUriProvider
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ClassReferenceProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.LoggerNameProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.boot.yaml.completions.ApplicationYamlAssistContext;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LspClient;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.commons.util.LogRedirect;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
@@ -55,8 +63,28 @@ public class BootLanguagServerBootApp {
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) {
|
||||
return BootLanguageServerParams.createDefault(server);
|
||||
@Bean AdHocSpringPropertyIndexProvider adHocProperties(BootLanguageServerParams params, FileObserver fileObserver) {
|
||||
return new AdHocSpringPropertyIndexProvider(params.projectFinder, params.projectObserver, fileObserver);
|
||||
}
|
||||
|
||||
@Bean FileObserver fileObserver(SimpleLanguageServer server) {
|
||||
return server.getWorkspaceService().getFileObserver();
|
||||
}
|
||||
|
||||
@Bean ValueProviderRegistry valueProviders() {
|
||||
return new ValueProviderRegistry();
|
||||
}
|
||||
|
||||
@Bean InitializingBean initializeValueProviders(ValueProviderRegistry r, @Qualifier("adHocProperties") SpringPropertyIndexProvider adHocProperties) {
|
||||
return () -> {
|
||||
r.def("logger-name", new LoggerNameProvider(adHocProperties).FACTORY);
|
||||
r.def("class-reference", ClassReferenceProvider.FACTORY);
|
||||
};
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, ValueProviderRegistry valueProviders) {
|
||||
return BootLanguageServerParams.createDefault(server, valueProviders);
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
|
||||
@@ -14,10 +14,13 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.properties.BootPropertiesLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter;
|
||||
@@ -44,6 +47,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
@Autowired YamlASTProvider parser;
|
||||
@Autowired YamlStructureProvider yamlStructureProvider;
|
||||
@Autowired YamlAssistContextProvider yamlAssistContextProvider;
|
||||
@Qualifier("adHocProperties") @Autowired SpringPropertyIndexProvider adHocProperties;
|
||||
|
||||
private CompositeLanguageServerComponents components;
|
||||
private VscodeCompletionEngineAdapter completionEngineAdapter;
|
||||
@@ -67,7 +71,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
// some server intialization code. Migrate that code and get rid of the ComposableLanguageServer class
|
||||
CompositeLanguageServerComponents.Builder builder = new CompositeLanguageServerComponents.Builder();
|
||||
builder.add(new BootPropertiesLanguageServerComponents(server, params, javaElementLocationProvider, parser, yamlStructureProvider, yamlAssistContextProvider));
|
||||
builder.add(new BootJavaLanguageServerComponents(server, params, sourceLinks, cuCache));
|
||||
builder.add(new BootJavaLanguageServerComponents(server, params, sourceLinks, cuCache, adHocProperties));
|
||||
components = builder.build(server);
|
||||
params.projectObserver.addListener(reconcileOpenDocuments(server, components));
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProv
|
||||
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndex;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
|
||||
import org.springframework.ide.vscode.commons.gradle.GradleCore;
|
||||
@@ -59,7 +60,6 @@ public class BootLanguageServerParams {
|
||||
public final JavaProjectFinder projectFinder;
|
||||
public final ProjectObserver projectObserver;
|
||||
public final SpringPropertyIndexProvider indexProvider;
|
||||
public final SpringPropertyIndexProvider adHocIndexProvider;
|
||||
|
||||
//Boot Properies
|
||||
public final TypeUtilProvider typeUtilProvider;
|
||||
@@ -72,7 +72,6 @@ public class BootLanguageServerParams {
|
||||
JavaProjectFinder projectFinder,
|
||||
ProjectObserver projectObserver,
|
||||
SpringPropertyIndexProvider indexProvider,
|
||||
SpringPropertyIndexProvider adHocIndexProvider,
|
||||
TypeUtilProvider typeUtilProvider,
|
||||
RunningAppProvider runningAppProvider,
|
||||
Duration watchDogInterval
|
||||
@@ -82,28 +81,25 @@ public class BootLanguageServerParams {
|
||||
this.projectFinder = projectFinder;
|
||||
this.projectObserver = projectObserver;
|
||||
this.indexProvider = indexProvider;
|
||||
this.adHocIndexProvider = adHocIndexProvider;
|
||||
this.typeUtilProvider = typeUtilProvider;
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
this.watchDogInterval = watchDogInterval;
|
||||
}
|
||||
|
||||
public static BootLanguageServerParams createDefault(SimpleLanguageServer server) {
|
||||
public static BootLanguageServerParams createDefault(SimpleLanguageServer server, ValueProviderRegistry valueProviders) {
|
||||
// Initialize project finders, project caches and project observers
|
||||
JavaProjectsService jdtProjectCache = new JavaProjectsServiceWithFallback(
|
||||
server,
|
||||
new JdtLsProjectCache(server),
|
||||
() -> createFallbackProjectCache(server)
|
||||
);
|
||||
DefaultSpringPropertyIndexProvider indexProvider = new DefaultSpringPropertyIndexProvider(jdtProjectCache, jdtProjectCache);
|
||||
SpringPropertyIndexProvider adHocProvider = new AdHocSpringPropertyIndexProvider(jdtProjectCache, jdtProjectCache, server.getWorkspaceService().getFileObserver());
|
||||
DefaultSpringPropertyIndexProvider indexProvider = new DefaultSpringPropertyIndexProvider(jdtProjectCache, jdtProjectCache, valueProviders);
|
||||
indexProvider.setProgressService(server.getProgressService());
|
||||
|
||||
return new BootLanguageServerParams(
|
||||
jdtProjectCache.filter(BootProjectUtil::isBootProject),
|
||||
jdtProjectCache,
|
||||
indexProvider,
|
||||
adHocProvider,
|
||||
(IDocument doc) -> new TypeUtil(jdtProjectCache.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.createDefault(server),
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
@@ -147,7 +143,7 @@ public class BootLanguageServerParams {
|
||||
};
|
||||
}
|
||||
|
||||
public static BootLanguageServerParams createTestDefault(SimpleLanguageServer server) {
|
||||
public static BootLanguageServerParams createTestDefault(SimpleLanguageServer server, ValueProviderRegistry valueProviders) {
|
||||
// Initialize project finders, project caches and project observers
|
||||
CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder();
|
||||
MavenProjectCache mavenProjectCache = new MavenProjectCache(server, MavenCore.getDefault(), false, null, (uri, cpe) -> JavaDocProviders.createFor(cpe));
|
||||
@@ -160,14 +156,13 @@ public class BootLanguageServerParams {
|
||||
|
||||
CompositeProjectOvserver projectObserver = new CompositeProjectOvserver(Arrays.asList(mavenProjectCache, gradleProjectCache));
|
||||
|
||||
DefaultSpringPropertyIndexProvider indexProvider = new DefaultSpringPropertyIndexProvider(javaProjectFinder, projectObserver);
|
||||
DefaultSpringPropertyIndexProvider indexProvider = new DefaultSpringPropertyIndexProvider(javaProjectFinder, projectObserver, valueProviders);
|
||||
indexProvider.setProgressService(server.getProgressService());
|
||||
|
||||
return new BootLanguageServerParams(
|
||||
javaProjectFinder.filter(BootProjectUtil::isBootProject),
|
||||
projectObserver,
|
||||
indexProvider,
|
||||
(doc) -> SpringPropertyIndex.EMPTY_INDEX,
|
||||
(IDocument doc) -> new TypeUtil(javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.NULL,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
|
||||
@@ -63,6 +63,7 @@ import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor;
|
||||
import org.springframework.ide.vscode.boot.java.value.ValueHoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.value.ValuePropertyReferencesProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.composable.LanguageServerComponents;
|
||||
@@ -108,7 +109,13 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
private CodeLensHandler codeLensHandler;
|
||||
private DocumentHighlightHandler highlightsEngine;
|
||||
|
||||
public BootJavaLanguageServerComponents(SimpleLanguageServer server, BootLanguageServerParams serverParams, SourceLinks sourceLinks, CompilationUnitCache cuCache) {
|
||||
public BootJavaLanguageServerComponents(
|
||||
SimpleLanguageServer server,
|
||||
BootLanguageServerParams serverParams,
|
||||
SourceLinks sourceLinks,
|
||||
CompilationUnitCache cuCache,
|
||||
SpringPropertyIndexProvider adHocIndexProvider
|
||||
) {
|
||||
this.server = server;
|
||||
this.serverParams = serverParams;
|
||||
|
||||
@@ -119,7 +126,7 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
this.cuCache = cuCache;
|
||||
|
||||
propertyIndexProvider = serverParams.indexProvider;
|
||||
adHocPropertyIndexProvider = serverParams.adHocIndexProvider;
|
||||
this.adHocPropertyIndexProvider = adHocIndexProvider;
|
||||
|
||||
SimpleWorkspaceService workspaceService = server.getWorkspaceService();
|
||||
SimpleTextDocumentService documents = server.getTextDocumentService();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ClassReferenceProvider extends CachingValueProvider {
|
||||
return UNTARGETTED_INSTANCE;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
private static <K,V> Function<K,V> applyOn(long duration, TimeUnit unit, Function<K,V> func) {
|
||||
Cache<K,V> cache = CacheBuilder.newBuilder().expireAfterAccess(duration, unit).expireAfterWrite(duration, unit).build();
|
||||
return (k) -> {
|
||||
|
||||
@@ -22,17 +22,17 @@ import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
|
||||
public class DefaultSpringPropertyIndexProvider implements SpringPropertyIndexProvider {
|
||||
|
||||
|
||||
private JavaProjectFinder javaProjectFinder;
|
||||
private SpringPropertiesIndexManager indexManager;
|
||||
|
||||
|
||||
private ProgressService progressService = (id, msg) -> { /*ignore*/ };
|
||||
|
||||
public DefaultSpringPropertyIndexProvider(JavaProjectFinder javaProjectFinder, ProjectObserver projectObserver) {
|
||||
|
||||
public DefaultSpringPropertyIndexProvider(JavaProjectFinder javaProjectFinder, ProjectObserver projectObserver, ValueProviderRegistry valueProviders) {
|
||||
this.javaProjectFinder = javaProjectFinder;
|
||||
this.indexManager = new SpringPropertiesIndexManager(ValueProviderRegistry.getDefault(), projectObserver);
|
||||
this.indexManager = new SpringPropertiesIndexManager(valueProviders, projectObserver);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FuzzyMap<PropertyInfo> getIndex(IDocument doc) {
|
||||
Optional<IJavaProject> jp = javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()));
|
||||
|
||||
@@ -30,9 +30,14 @@ import reactor.util.function.Tuples;
|
||||
* @author Alex Boyko
|
||||
*/
|
||||
public class LoggerNameProvider extends CachingValueProvider {
|
||||
|
||||
private static final ValueProviderStrategy INSTANCE = new LoggerNameProvider();
|
||||
public static final Function<Map<String, Object>, ValueProviderStrategy> FACTORY = (params) -> INSTANCE;
|
||||
|
||||
private final SpringPropertyIndexProvider adhocProperties;
|
||||
|
||||
public LoggerNameProvider(SpringPropertyIndexProvider adhocProperties) {
|
||||
this.adhocProperties = adhocProperties;
|
||||
}
|
||||
|
||||
public final Function<Map<String, Object>, ValueProviderStrategy> FACTORY = (params) -> this;
|
||||
|
||||
@Override
|
||||
protected Flux<StsValueHint> getValuesAsync(IJavaProject javaProject, String query) {
|
||||
@@ -48,5 +53,4 @@ public class LoggerNameProvider extends CachingValueProvider {
|
||||
.flatMapIterable(l -> l)
|
||||
.map(t -> t.getT1());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,26 +32,6 @@ import reactor.core.publisher.Flux;
|
||||
*/
|
||||
public class ValueProviderRegistry {
|
||||
|
||||
private static ValueProviderRegistry DEFAULT;
|
||||
|
||||
/**
|
||||
* Creates a default {@link ValueProviderRegistry} which is initialized with all the known
|
||||
* providers. (This is the one production code should use, test code might make use
|
||||
* something else for mocking purposes).
|
||||
*/
|
||||
public synchronized static ValueProviderRegistry getDefault() {
|
||||
if (DEFAULT==null) {
|
||||
DEFAULT = new ValueProviderRegistry();
|
||||
DEFAULT.initializeDefaults(DEFAULT);
|
||||
}
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
protected void initializeDefaults(ValueProviderRegistry r) {
|
||||
def("logger-name", LoggerNameProvider.FACTORY);
|
||||
def("class-reference", ClassReferenceProvider.FACTORY);
|
||||
}
|
||||
|
||||
private Map<String, Function<Map<String, Object>, ValueProviderStrategy>> registry = new HashMap<>();
|
||||
|
||||
public interface ValueProviderStrategy {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.bootiful;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
|
||||
@Configuration
|
||||
public class AdHocPropertyHarnessTestConf {
|
||||
@Bean AdHocPropertyHarness adHocPropertyHarness() {
|
||||
return new AdHocPropertyHarness();
|
||||
}
|
||||
|
||||
@Bean SpringPropertyIndexProvider adHocProperties(AdHocPropertyHarness adHocProperties) {
|
||||
return adHocProperties.getIndexProvider();
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
@OverrideAutoConfiguration(enabled=false)
|
||||
@ImportAutoConfiguration(classes=LanguageServerAutoConf.class)
|
||||
@SpringBootTest(classes={
|
||||
BootLanguagServerBootApp.class,
|
||||
BootLanguagServerBootApp.class
|
||||
})
|
||||
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public @interface BootLanguageServerTest {
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.bootiful;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
@@ -15,10 +27,11 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
public class HoverTestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean MockRunningAppProvider mockAppsHarness() {
|
||||
@@ -33,13 +46,12 @@ public class HoverTestConf {
|
||||
return Duration.ofMillis(100);
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, ValueProviderRegistry valueProviders, PropertyIndexHarness indexHarness) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
return new BootLanguageServerParams(
|
||||
indexHarness().getProjectFinder(),
|
||||
indexHarness.getProjectFinder(),
|
||||
testDefaults.projectObserver,
|
||||
indexHarness().getIndexProvider(),
|
||||
indexHarness().getAdHocIndexProvider(),
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
watchDogInterval()
|
||||
@@ -53,5 +65,4 @@ public class HoverTestConf {
|
||||
@Bean SourceLinks sourceLinks() {
|
||||
return SourceLinkFactory.NO_SOURCE_LINKS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
|
||||
@@ -21,6 +22,7 @@ import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
|
||||
import org.springframework.ide.vscode.boot.test.DefinitionLinkAsserts;
|
||||
@@ -32,10 +34,12 @@ import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
|
||||
@Configuration public class PropertyEditorTestConf {
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
public class PropertyEditorTestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean MockRunningAppProvider mockAppsHarness() {
|
||||
@@ -53,15 +57,14 @@ import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, defaultLanguageId, defaultFileExtension);
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) {
|
||||
JavaProjectFinder projectFinder = indexHarness().getProjectFinder();
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, PropertyIndexHarness indexHarness) {
|
||||
JavaProjectFinder projectFinder = indexHarness.getProjectFinder();
|
||||
TypeUtilProvider typeUtilProvider = (IDocument doc) -> new TypeUtil(projectFinder.find(new TextDocumentIdentifier(doc.getUri())));
|
||||
|
||||
return new BootLanguageServerParams(
|
||||
projectFinder,
|
||||
ProjectObserver.NULL,
|
||||
indexHarness().getIndexProvider(),
|
||||
indexHarness().getAdHocIndexProvider(),
|
||||
indexHarness.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
|
||||
@@ -1,24 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.bootiful;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexer;
|
||||
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
|
||||
@Configuration public class SymbolProviderTestConf {
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
public class SymbolProviderTestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) {
|
||||
@@ -29,8 +45,8 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java");
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) {
|
||||
return BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, ValueProviderRegistry valueProviders) {
|
||||
return BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
}
|
||||
|
||||
@Bean SpringIndexer springIndexer(BootLanguageServerInitializer serverInit) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.editor.harness;
|
||||
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
|
||||
public class AdHocPropertyHarness {
|
||||
|
||||
private FuzzyMap<PropertyInfo> adHocProperties = new FuzzyMap<PropertyInfo>() {
|
||||
@Override
|
||||
protected String getKey(PropertyInfo entry) {
|
||||
return entry.getId();
|
||||
}
|
||||
};
|
||||
|
||||
protected final SpringPropertyIndexProvider adHocIndexProvider = doc -> adHocProperties;
|
||||
|
||||
public SpringPropertyIndexProvider getIndexProvider() {
|
||||
return adHocIndexProvider;
|
||||
}
|
||||
|
||||
public void add(String adHocPropertyId) {
|
||||
adHocProperties.add(new PropertyInfo(adHocPropertyId, null, null, null, null, null, null, null, null, null, null));
|
||||
}
|
||||
}
|
||||
@@ -34,15 +34,9 @@ import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
*/
|
||||
public class PropertyIndexHarness {
|
||||
|
||||
private final ValueProviderRegistry valueProviders;
|
||||
private Map<String, ConfigurationMetadataProperty> datas = new LinkedHashMap<>();
|
||||
private ValueProviderRegistry valueProviders = ValueProviderRegistry.getDefault();
|
||||
private SpringPropertyIndex index = null;
|
||||
private FuzzyMap<PropertyInfo> adHocProperties = new FuzzyMap<PropertyInfo>() {
|
||||
@Override
|
||||
protected String getKey(PropertyInfo entry) {
|
||||
return entry.getId();
|
||||
}
|
||||
};
|
||||
private IJavaProject testProject = null;
|
||||
|
||||
protected final SpringPropertyIndexProvider indexProvider = new SpringPropertyIndexProvider() {
|
||||
@@ -60,9 +54,11 @@ public class PropertyIndexHarness {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected final SpringPropertyIndexProvider adHocIndexProvider = doc -> adHocProperties;
|
||||
|
||||
|
||||
public PropertyIndexHarness(ValueProviderRegistry valueProviders) {
|
||||
this.valueProviders = valueProviders;
|
||||
}
|
||||
|
||||
public synchronized void useProject(IJavaProject p) throws Exception {
|
||||
index = null;
|
||||
this.testProject = p;
|
||||
@@ -572,18 +568,10 @@ public class PropertyIndexHarness {
|
||||
return indexProvider;
|
||||
}
|
||||
|
||||
public SpringPropertyIndexProvider getAdHocIndexProvider() {
|
||||
return adHocIndexProvider;
|
||||
}
|
||||
|
||||
public JavaProjectFinder getProjectFinder() {
|
||||
return (doc) -> Optional.ofNullable(testProject);
|
||||
}
|
||||
|
||||
public void adHoc(String adHocPropertyId) {
|
||||
adHocProperties.add(new PropertyInfo(adHocPropertyId, null, null, null, null, null, null, null, null, null, null));
|
||||
}
|
||||
|
||||
public IJavaProject getTestProject() {
|
||||
return testProject;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.bootiful.AdHocPropertyHarnessTestConf;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
@@ -36,6 +38,7 @@ import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
@@ -67,10 +70,11 @@ public class CompilationUnitCacheTest {
|
||||
@Autowired
|
||||
private MockProjectObserver projectObserver;
|
||||
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
@Configuration static class TestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) {
|
||||
@@ -85,13 +89,12 @@ public class CompilationUnitCacheTest {
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java");
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, MockProjectObserver projectObserver) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, MockProjectObserver projectObserver, ValueProviderRegistry valueProviders, PropertyIndexHarness indexHarness) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
return new BootLanguageServerParams(
|
||||
indexHarness().getProjectFinder(),
|
||||
indexHarness.getProjectFinder(),
|
||||
projectObserver,
|
||||
indexHarness().getIndexProvider(),
|
||||
indexHarness().getAdHocIndexProvider(),
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
|
||||
@@ -19,20 +19,27 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.bootiful.AdHocPropertyHarnessTestConf;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor;
|
||||
import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
@@ -58,8 +65,11 @@ public class ValueCompletionTest {
|
||||
private Editor editor;
|
||||
|
||||
@Autowired private PropertyIndexHarness indexHarness;
|
||||
@Autowired private AdHocPropertyHarness adHocProperties;
|
||||
|
||||
@Configuration static class TestConf {
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
static class TestConf {
|
||||
|
||||
//Somewhat strange test setup, test provides a specific test project.
|
||||
//The project finder finds this test project,
|
||||
@@ -70,8 +80,8 @@ public class ValueCompletionTest {
|
||||
return ProjectsHarness.INSTANCE.mavenProject("test-annotations");
|
||||
}
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(MavenJavaProject testProject) {
|
||||
@@ -82,13 +92,12 @@ public class ValueCompletionTest {
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java");
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, JavaProjectFinder projectFinder) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, JavaProjectFinder projectFinder, ValueProviderRegistry valueProviders, PropertyIndexHarness indexHarness) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
return new BootLanguageServerParams(
|
||||
projectFinder,
|
||||
ProjectObserver.NULL,
|
||||
indexHarness().getIndexProvider(),
|
||||
indexHarness().getAdHocIndexProvider(),
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
@@ -336,9 +345,9 @@ public class ValueCompletionTest {
|
||||
"${spring.prop1}<*>"
|
||||
);
|
||||
|
||||
indexHarness.adHoc("spring.ad-hoc.thingy");
|
||||
indexHarness.adHoc("spring.ad-hoc.other-thingy");
|
||||
indexHarness.adHoc("spring.prop1"); //should not suggest this twice!
|
||||
adHocProperties.add("spring.ad-hoc.thingy");
|
||||
adHocProperties.add("spring.ad-hoc.other-thingy");
|
||||
adHocProperties.add("spring.prop1"); //should not suggest this twice!
|
||||
editor.assertContextualCompletions(
|
||||
"<*>"
|
||||
, //==>
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
|
||||
/**
|
||||
* Index Navigation tests.
|
||||
*
|
||||
*
|
||||
* @author Kris De Volder
|
||||
* @author Alex Boyko
|
||||
*
|
||||
@@ -27,7 +27,7 @@ public class IndexNavigatorTest {
|
||||
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
PropertyIndexHarness harness = new PropertyIndexHarness();
|
||||
PropertyIndexHarness harness = indexHarness();
|
||||
harness.defaultTestData();
|
||||
|
||||
start(harness);
|
||||
@@ -43,9 +43,13 @@ public class IndexNavigatorTest {
|
||||
assertEmpty();
|
||||
}
|
||||
|
||||
private PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness(new ValueProviderRegistry());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialName() throws Exception {
|
||||
PropertyIndexHarness harness = new PropertyIndexHarness();
|
||||
PropertyIndexHarness harness = indexHarness();
|
||||
harness.defaultTestData();
|
||||
|
||||
start(harness);
|
||||
@@ -60,7 +64,7 @@ public class IndexNavigatorTest {
|
||||
|
||||
@Test
|
||||
public void testAmbiguous() throws Exception {
|
||||
PropertyIndexHarness harness = new PropertyIndexHarness();
|
||||
PropertyIndexHarness harness = indexHarness();
|
||||
harness.defaultTestData();
|
||||
|
||||
harness.data("foo.bar", "java.lang.String", null, "Foo dot bar");
|
||||
@@ -130,7 +134,7 @@ public class IndexNavigatorTest {
|
||||
public void navigate(String propName) {
|
||||
navigator = navigator.selectSubProperty(propName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class LoggerNameProviderTest {
|
||||
"org.springframework.instrument.classloading.jboss.JBossMCTranslatorAdapter", //11
|
||||
"org.springframework.instrument.classloading.jboss.JBossModulesAdapter" //12
|
||||
};
|
||||
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
private MavenJavaProject project;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class LoggerNameProviderTest {
|
||||
|
||||
@Test
|
||||
public void directResults() throws Exception {
|
||||
LoggerNameProvider p = new LoggerNameProvider();
|
||||
LoggerNameProvider p = new LoggerNameProvider(null);
|
||||
String query = "jboss";
|
||||
List<String> directQueryResults = getResults(p, query);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class LoggerNameProviderTest {
|
||||
|
||||
@Test
|
||||
public void cachedResults() throws Exception {
|
||||
LoggerNameProvider p = new LoggerNameProvider();
|
||||
LoggerNameProvider p = new LoggerNameProvider(null);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
String query = "jboss";
|
||||
@@ -105,7 +105,7 @@ public class LoggerNameProviderTest {
|
||||
public void incrementalResults() throws Exception {
|
||||
String fullQuery = "jboss";
|
||||
|
||||
CachingValueProvider p = new LoggerNameProvider();
|
||||
CachingValueProvider p = new LoggerNameProvider(null);
|
||||
for (int i = 0; i <= fullQuery.length(); i++) {
|
||||
String query = fullQuery.substring(0, i);
|
||||
List<String> results = getResults(p, query);
|
||||
|
||||
@@ -22,21 +22,21 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
* Sanity test the boot properties index
|
||||
*
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
public class PropertiesIndexTest {
|
||||
|
||||
private static final String CUSTOM_PROPERTIES_PROJECT = "custom-properties-boot-project";
|
||||
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
private ProgressService progressService = (id, msg) -> { /*ignore*/ };
|
||||
|
||||
|
||||
@Test
|
||||
public void springStandardPropertyPresent_Maven() throws Exception {
|
||||
SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(
|
||||
ValueProviderRegistry.getDefault(), null);
|
||||
new ValueProviderRegistry(), null);
|
||||
IJavaProject mavenProject = projects.mavenProject(CUSTOM_PROPERTIES_PROJECT);
|
||||
FuzzyMap<PropertyInfo> index = indexManager.get(mavenProject, progressService);
|
||||
PropertyInfo propertyInfo = index.get("server.port");
|
||||
@@ -48,7 +48,7 @@ public class PropertiesIndexTest {
|
||||
@Test
|
||||
public void customPropertyPresent_Maven() throws Exception {
|
||||
SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(
|
||||
ValueProviderRegistry.getDefault(), null);
|
||||
new ValueProviderRegistry(), null);
|
||||
IJavaProject mavenProject = projects.mavenProject(CUSTOM_PROPERTIES_PROJECT);
|
||||
FuzzyMap<PropertyInfo> index = indexManager.get(mavenProject, progressService);
|
||||
PropertyInfo propertyInfo = index.get("demo.settings.user");
|
||||
@@ -60,7 +60,7 @@ public class PropertiesIndexTest {
|
||||
@Test
|
||||
public void propertyNotPresent_Maven() throws Exception {
|
||||
SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(
|
||||
ValueProviderRegistry.getDefault(), null);
|
||||
new ValueProviderRegistry(), null);
|
||||
IJavaProject mavenProject = projects.mavenProject(CUSTOM_PROPERTIES_PROJECT);
|
||||
FuzzyMap<PropertyInfo> index = indexManager.get(mavenProject, progressService);
|
||||
PropertyInfo propertyInfo = index.get("my.server.port");
|
||||
|
||||
Reference in New Issue
Block a user