Merge BootJavaServerParams into BootLanguageServerParams
This also required the removal of duplicated SpringPropertyIndex related classes that existed in both boot properties and boot java language servers before. A single BootLanguageServerParams now contains the same kind of property index that should be able to support both uses.
This commit is contained in:
@@ -11,9 +11,12 @@
|
||||
package org.springframework.ide.vscode.boot;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
|
||||
@@ -38,26 +41,37 @@ import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
* Parameters for creating Boot Properties language server
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public class BootLanguageServerParams {
|
||||
|
||||
//Shared
|
||||
public final JavaProjectFinder projectFinder;
|
||||
public final ProjectObserver projectObserver;
|
||||
public final SpringPropertyIndexProvider indexProvider;
|
||||
|
||||
//Boot Properies
|
||||
public final TypeUtilProvider typeUtilProvider;
|
||||
|
||||
//Boot Java
|
||||
public final RunningAppProvider runningAppProvider;
|
||||
public final Duration watchDogInterval;
|
||||
|
||||
public BootLanguageServerParams(
|
||||
JavaProjectFinder projectFinder,
|
||||
ProjectObserver projectObserver,
|
||||
SpringPropertyIndexProvider indexProvider,
|
||||
TypeUtilProvider typeUtilProvider
|
||||
TypeUtilProvider typeUtilProvider,
|
||||
RunningAppProvider runningAppProvider,
|
||||
Duration watchDogInterval
|
||||
) {
|
||||
super();
|
||||
this.projectFinder = projectFinder;
|
||||
this.projectObserver = projectObserver;
|
||||
this.indexProvider = indexProvider;
|
||||
this.typeUtilProvider = typeUtilProvider;
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
this.watchDogInterval = watchDogInterval;
|
||||
}
|
||||
|
||||
public static LSFactory<BootLanguageServerParams> createDefault() {
|
||||
@@ -79,7 +93,9 @@ public class BootLanguageServerParams {
|
||||
javaProjectFinder.filter(BootProjectUtil::isBootProject),
|
||||
projectObserver,
|
||||
indexProvider,
|
||||
(IDocument doc) -> new TypeUtil(javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri())))
|
||||
(IDocument doc) -> new TypeUtil(javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.DEFAULT,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -102,7 +118,9 @@ public class BootLanguageServerParams {
|
||||
javaProjectFinder.filter(BootProjectUtil::isBootProject),
|
||||
projectObserver,
|
||||
indexProvider,
|
||||
typeUtilProvider
|
||||
typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -128,9 +146,10 @@ public class BootLanguageServerParams {
|
||||
javaProjectFinder.filter(BootProjectUtil::isBootProject),
|
||||
projectObserver,
|
||||
indexProvider,
|
||||
(IDocument doc) -> new TypeUtil(javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri())))
|
||||
(IDocument doc) -> new TypeUtil(javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.NULL,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.Registration;
|
||||
import org.eclipse.lsp4j.RegistrationParams;
|
||||
import org.springframework.ide.vscode.boot.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup;
|
||||
import org.springframework.ide.vscode.boot.java.autowired.AutowiredHoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolProvider;
|
||||
@@ -41,7 +42,6 @@ import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.ActiveProfilesProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.BeanInjectedIntoHoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.ComponentInjectionsHoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.LiveAppURLSymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.RequestMappingHoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.RequestMappingSymbolProvider;
|
||||
@@ -55,6 +55,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.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.HighlightParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter;
|
||||
@@ -93,9 +94,9 @@ public class BootJavaLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
private JavaProjectFinder projectFinder;
|
||||
|
||||
public BootJavaLanguageServer(LSFactory<BootJavaLanguageServerParams> _params) {
|
||||
public BootJavaLanguageServer(LSFactory<BootLanguageServerParams> _params) {
|
||||
super("boot-java");
|
||||
BootJavaLanguageServerParams serverParams = _params.create(this);
|
||||
BootLanguageServerParams serverParams = _params.create(this);
|
||||
|
||||
this.config = new BootJavaConfig();
|
||||
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 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.java;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.DefaultSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.commons.gradle.GradleCore;
|
||||
import org.springframework.ide.vscode.commons.gradle.GradleProjectCache;
|
||||
import org.springframework.ide.vscode.commons.gradle.GradleProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.java.BootProjectUtil;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.CompositeJavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.CompositeProjectOvserver;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LSFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.maven.MavenCore;
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenProjectCache;
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenProjectFinder;
|
||||
|
||||
public class BootJavaLanguageServerParams {
|
||||
|
||||
public final JavaProjectFinder projectFinder;
|
||||
public final ProjectObserver projectObserver;
|
||||
public final SpringPropertyIndexProvider indexProvider;
|
||||
public final RunningAppProvider runningAppProvider;
|
||||
public final Duration watchDogInterval;
|
||||
|
||||
public BootJavaLanguageServerParams(
|
||||
JavaProjectFinder projectFinder,
|
||||
ProjectObserver projectObserver,
|
||||
SpringPropertyIndexProvider indexProvider,
|
||||
RunningAppProvider runningAppProvider,
|
||||
Duration watchDogInterval
|
||||
) {
|
||||
super();
|
||||
this.projectFinder = projectFinder;
|
||||
this.projectObserver = projectObserver;
|
||||
this.indexProvider = indexProvider;
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
this.watchDogInterval = watchDogInterval;
|
||||
}
|
||||
|
||||
public static LSFactory<BootJavaLanguageServerParams> createDefault() {
|
||||
return (SimpleLanguageServer server) -> {
|
||||
// Initialize project finders, project caches and project observers
|
||||
CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder();
|
||||
MavenProjectCache mavenProjectCache = new MavenProjectCache(server, MavenCore.getDefault(), true, Paths.get(IJavaProject.PROJECT_CACHE_FOLDER));
|
||||
javaProjectFinder.addJavaProjectFinder(new MavenProjectFinder(mavenProjectCache));
|
||||
|
||||
GradleProjectCache gradleProjectCache = new GradleProjectCache(server, GradleCore.getDefault(), true, Paths.get(IJavaProject.PROJECT_CACHE_FOLDER));
|
||||
javaProjectFinder.addJavaProjectFinder(new GradleProjectFinder(gradleProjectCache));
|
||||
|
||||
CompositeProjectOvserver projectObserver = new CompositeProjectOvserver(Arrays.asList(mavenProjectCache, gradleProjectCache));
|
||||
|
||||
return new BootJavaLanguageServerParams(
|
||||
javaProjectFinder.filter(BootProjectUtil::isBootProject),
|
||||
projectObserver,
|
||||
new DefaultSpringPropertyIndexProvider(javaProjectFinder, projectObserver),
|
||||
RunningAppProvider.DEFAULT,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
public static LSFactory<BootJavaLanguageServerParams> createTestDefault() {
|
||||
return (SimpleLanguageServer server) -> {
|
||||
// Initialize project finders, project caches and project observers
|
||||
CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder();
|
||||
MavenProjectCache mavenProjectCache = new MavenProjectCache(server, MavenCore.getDefault(), false, null);
|
||||
mavenProjectCache.setAlwaysFireEventOnFileChanged(true);
|
||||
javaProjectFinder.addJavaProjectFinder(new MavenProjectFinder(mavenProjectCache));
|
||||
|
||||
GradleProjectCache gradleProjectCache = new GradleProjectCache(server, GradleCore.getDefault(), false, null);
|
||||
gradleProjectCache.setAlwaysFireEventOnFileChanged(true);
|
||||
javaProjectFinder.addJavaProjectFinder(new GradleProjectFinder(gradleProjectCache));
|
||||
|
||||
CompositeProjectOvserver projectObserver = new CompositeProjectOvserver(Arrays.asList(mavenProjectCache, gradleProjectCache));
|
||||
|
||||
return new BootJavaLanguageServerParams(
|
||||
javaProjectFinder.filter(BootProjectUtil::isBootProject),
|
||||
projectObserver,
|
||||
new DefaultSpringPropertyIndexProvider(javaProjectFinder, projectObserver),
|
||||
RunningAppProvider.DEFAULT,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.java;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.ide.vscode.boot.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LaunguageServerApp;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.LogRedirect;
|
||||
@@ -30,7 +31,7 @@ public class Main {
|
||||
}
|
||||
LaunguageServerApp.start(serverName, () -> {
|
||||
SimpleLanguageServer server = new BootJavaLanguageServer(
|
||||
BootJavaLanguageServerParams.createDefault()
|
||||
BootLanguageServerParams.createDefault()
|
||||
);
|
||||
return server;
|
||||
});
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2017 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.java.metadata;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
|
||||
public class DefaultSpringPropertyIndexProvider implements SpringPropertyIndexProvider {
|
||||
|
||||
private static final FuzzyMap<ConfigurationMetadataProperty> EMPTY_INDEX = new SpringPropertyIndex(null);
|
||||
|
||||
private JavaProjectFinder javaProjectFinder;
|
||||
private SpringPropertiesIndexManager indexManager;
|
||||
|
||||
private ProgressService progressService = (id, msg) -> {
|
||||
/* ignore */ };
|
||||
|
||||
public DefaultSpringPropertyIndexProvider(JavaProjectFinder javaProjectFinder, ProjectObserver projectObserver) {
|
||||
this.javaProjectFinder = javaProjectFinder;
|
||||
this.indexManager = new SpringPropertiesIndexManager(projectObserver);
|
||||
}
|
||||
|
||||
public DefaultSpringPropertyIndexProvider(JavaProjectFinder javaProjectFinder) {
|
||||
this(javaProjectFinder, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMap<ConfigurationMetadataProperty> getIndex(IDocument doc) {
|
||||
Optional<IJavaProject> jp = javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()));
|
||||
if (jp.isPresent()) {
|
||||
return indexManager.get(jp.get(), progressService);
|
||||
}
|
||||
return EMPTY_INDEX;
|
||||
}
|
||||
|
||||
public void setProgressService(ProgressService progressService) {
|
||||
this.progressService = progressService;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2017 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.java.metadata;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataRepository;
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataRepositoryJsonBuilder;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspath;
|
||||
|
||||
public class PropertiesLoader {
|
||||
|
||||
private static final String MAIN_SPRING_CONFIGURATION_METADATA_JSON = "META-INF/spring-configuration-metadata.json";
|
||||
|
||||
public static final String ADDITIONAL_SPRING_CONFIGURATION_METADATA_JSON = "META-INF/additional-spring-configuration-metadata.json";
|
||||
|
||||
/**
|
||||
* The default classpath location for config metadata loaded when scanning .jar files on the classpath.
|
||||
*/
|
||||
public static final String[] JAR_META_DATA_LOCATIONS = {
|
||||
MAIN_SPRING_CONFIGURATION_METADATA_JSON
|
||||
//Not scanning 'additional' metadata because it integrated already in the main data.
|
||||
};
|
||||
|
||||
/**
|
||||
* The default classpath location for config metadata loaded when scanning project output folders.
|
||||
*/
|
||||
public static final String[] PROJECT_META_DATA_LOCATIONS = {
|
||||
MAIN_SPRING_CONFIGURATION_METADATA_JSON,
|
||||
ADDITIONAL_SPRING_CONFIGURATION_METADATA_JSON
|
||||
};
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(PropertiesLoader.class.getName());
|
||||
|
||||
private ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create();
|
||||
|
||||
public ConfigurationMetadataRepository load(IClasspath classPath) {
|
||||
try {
|
||||
classPath.getClasspathEntries().forEach(entry -> {
|
||||
File fileEntry = entry.toFile();
|
||||
if (fileEntry.exists()) {
|
||||
if (fileEntry.isDirectory()) {
|
||||
loadFromOutputFolder(entry);
|
||||
} else {
|
||||
loadFromJar(entry);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LOG.log(Level.SEVERE, "Failed to retrieve classpath", e);
|
||||
}
|
||||
ConfigurationMetadataRepository repository = builder.build();
|
||||
return repository;
|
||||
}
|
||||
|
||||
private void loadFromOutputFolder(Path outputFolderPath) {
|
||||
if (outputFolderPath != null && Files.exists(outputFolderPath)) {
|
||||
Arrays.stream(PROJECT_META_DATA_LOCATIONS).forEach(mdLoc -> {
|
||||
loadFromJsonFile(outputFolderPath.resolve(mdLoc));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromJsonFile(Path mdf) {
|
||||
if (Files.exists(mdf)) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = Files.newInputStream(mdf);
|
||||
loadFromInputStream(mdf, is);
|
||||
} catch (Exception e) {
|
||||
LOG.log(Level.SEVERE, "Error loading file '" + mdf + "'", e);
|
||||
} finally {
|
||||
if (is!=null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromJar(Path f) {
|
||||
JarFile jarFile = null;
|
||||
try {
|
||||
jarFile = new JarFile(f.toFile());
|
||||
//jarDump(jarFile);
|
||||
for (String loc : JAR_META_DATA_LOCATIONS) {
|
||||
ZipEntry e = jarFile.getEntry(loc);
|
||||
if (e!=null) {
|
||||
loadFrom(jarFile, e);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LOG.log(Level.SEVERE, "Error loading JAR file", e);
|
||||
} finally {
|
||||
if (jarFile!=null) {
|
||||
try {
|
||||
jarFile.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void loadFrom(JarFile jarFile, ZipEntry ze) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = jarFile.getInputStream(ze);
|
||||
loadFromInputStream(jarFile, is);
|
||||
} catch (Throwable e) {
|
||||
LOG.log(Level.SEVERE, "Error loading JAR file", e);
|
||||
} finally {
|
||||
if (is!=null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromInputStream(Object origin, InputStream is) throws IOException {
|
||||
builder.withJsonResource(origin, is);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014, 2017 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.java.metadata;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
|
||||
/**
|
||||
* Support for Reconciling, Content Assist and Hover Text in spring properties
|
||||
* file all make use of a per-project index of spring properties metadata extracted
|
||||
* from project's classpath. This Index manager is responsible for keeping at most
|
||||
* one index per-project and to keep the index up-to-date.
|
||||
*
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public class SpringPropertiesIndexManager {
|
||||
|
||||
private Map<IJavaProject, SpringPropertyIndex> indexes = null;
|
||||
private static int progressIdCt = 0;
|
||||
|
||||
public SpringPropertiesIndexManager(ProjectObserver projectObserver) {
|
||||
if (projectObserver != null) {
|
||||
projectObserver.addListener(new Listener() {
|
||||
|
||||
@Override
|
||||
public void created(IJavaProject project) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(IJavaProject project) {
|
||||
invalidateIndex(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleted(IJavaProject project) {
|
||||
invalidateIndex(project);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized SpringPropertyIndex invalidateIndex(IJavaProject project) {
|
||||
if (indexes != null) {
|
||||
return indexes.remove(project);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized FuzzyMap<ConfigurationMetadataProperty> get(IJavaProject project, ProgressService progressService) {
|
||||
if (indexes==null) {
|
||||
indexes = new HashMap<>();
|
||||
}
|
||||
|
||||
SpringPropertyIndex index = indexes.get(project);
|
||||
if (index==null) {
|
||||
String progressId = getProgressId();
|
||||
if (progressService != null) {
|
||||
progressService.progressEvent(progressId, "Indexing Spring Boot Properties...");
|
||||
}
|
||||
|
||||
index = new SpringPropertyIndex(project.getClasspath());
|
||||
indexes.put(project, index);
|
||||
|
||||
if (progressService != null) {
|
||||
progressService.progressEvent(progressId, null);
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
private static synchronized String getProgressId() {
|
||||
return DefaultSpringPropertyIndexProvider.class.getName()+ (progressIdCt++);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 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.java.metadata;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty;
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataRepository;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspath;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
|
||||
public class SpringPropertyIndex extends FuzzyMap<ConfigurationMetadataProperty> {
|
||||
|
||||
public SpringPropertyIndex(IClasspath projectPath) {
|
||||
if (projectPath!=null) {
|
||||
PropertiesLoader loader = new PropertiesLoader();
|
||||
ConfigurationMetadataRepository metadata = loader.load(projectPath);
|
||||
Collection<ConfigurationMetadataProperty> allEntries = metadata.getAllProperties().values();
|
||||
for (ConfigurationMetadataProperty item : allEntries) {
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getKey(ConfigurationMetadataProperty entry) {
|
||||
return entry.getId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 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.java.metadata;
|
||||
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SpringPropertyIndexProvider {
|
||||
FuzzyMap<ConfigurationMetadataProperty> getIndex(IDocument doc);
|
||||
}
|
||||
@@ -24,7 +24,8 @@ import org.eclipse.jdt.core.dom.SimpleName;
|
||||
import org.eclipse.jdt.core.dom.StringLiteral;
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.CompletionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
@@ -50,13 +51,13 @@ public class ValueCompletionProcessor implements CompletionProvider {
|
||||
List<ICompletionProposal> result = new ArrayList<>();
|
||||
|
||||
try {
|
||||
FuzzyMap<ConfigurationMetadataProperty> index = indexProvider.getIndex(doc);
|
||||
FuzzyMap<PropertyInfo> index = indexProvider.getIndex(doc);
|
||||
|
||||
// case: @Value(<*>)
|
||||
if (node == annotation && doc.get(offset - 1, 2).endsWith("()")) {
|
||||
List<Match<ConfigurationMetadataProperty>> matches = findMatches("", index);
|
||||
List<Match<PropertyInfo>> matches = findMatches("", index);
|
||||
|
||||
for (Match<ConfigurationMetadataProperty> match : matches) {
|
||||
for (Match<PropertyInfo> match : matches) {
|
||||
|
||||
DocumentEdits edits = new DocumentEdits(doc);
|
||||
edits.replace(offset, offset, "\"${" + match.data.getId() + "}\"");
|
||||
@@ -96,7 +97,7 @@ public class ValueCompletionProcessor implements CompletionProvider {
|
||||
}
|
||||
|
||||
private void computeProposalsForSimpleName(ASTNode node, List<ICompletionProposal> completions, int offset,
|
||||
IDocument doc, FuzzyMap<ConfigurationMetadataProperty> index) {
|
||||
IDocument doc, FuzzyMap<PropertyInfo> index) {
|
||||
String prefix = identifyPropertyPrefix(node.toString(), offset - node.getStartPosition());
|
||||
|
||||
int startOffset = node.getStartPosition();
|
||||
@@ -105,9 +106,9 @@ public class ValueCompletionProcessor implements CompletionProvider {
|
||||
String proposalPrefix = "\"";
|
||||
String proposalPostfix = "\"";
|
||||
|
||||
List<Match<ConfigurationMetadataProperty>> matches = findMatches(prefix, index);
|
||||
List<Match<PropertyInfo>> matches = findMatches(prefix, index);
|
||||
|
||||
for (Match<ConfigurationMetadataProperty> match : matches) {
|
||||
for (Match<PropertyInfo> match : matches) {
|
||||
|
||||
DocumentEdits edits = new DocumentEdits(doc);
|
||||
edits.replace(startOffset, endOffset, proposalPrefix + "${" + match.data.getId() + "}" + proposalPostfix);
|
||||
@@ -118,7 +119,7 @@ public class ValueCompletionProcessor implements CompletionProvider {
|
||||
}
|
||||
|
||||
private void computeProposalsForStringLiteral(ASTNode node, List<ICompletionProposal> completions, int offset,
|
||||
IDocument doc, FuzzyMap<ConfigurationMetadataProperty> index) throws BadLocationException {
|
||||
IDocument doc, FuzzyMap<PropertyInfo> index) throws BadLocationException {
|
||||
String prefix = identifyPropertyPrefix(doc.get(node.getStartPosition() + 1, offset - (node.getStartPosition() + 1)), offset - (node.getStartPosition() + 1));
|
||||
|
||||
int startOffset = offset - prefix.length();
|
||||
@@ -140,9 +141,9 @@ public class ValueCompletionProcessor implements CompletionProvider {
|
||||
String fullNodeContent = doc.get(node.getStartPosition(), node.getLength());
|
||||
String postCompletion = isClosingBracketMissing(fullNodeContent + preCompletion) ? "}" : "";
|
||||
|
||||
List<Match<ConfigurationMetadataProperty>> matches = findMatches(prefix, index);
|
||||
List<Match<PropertyInfo>> matches = findMatches(prefix, index);
|
||||
|
||||
for (Match<ConfigurationMetadataProperty> match : matches) {
|
||||
for (Match<PropertyInfo> match : matches) {
|
||||
|
||||
DocumentEdits edits = new DocumentEdits(doc);
|
||||
edits.replace(startOffset, endOffset, preCompletion + match.data.getId() + postCompletion);
|
||||
@@ -183,8 +184,8 @@ public class ValueCompletionProcessor implements CompletionProvider {
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Match<ConfigurationMetadataProperty>> findMatches(String prefix, FuzzyMap<ConfigurationMetadataProperty> index) {
|
||||
List<Match<ConfigurationMetadataProperty>> matches = index.find(camelCaseToHyphens(prefix));
|
||||
private List<Match<PropertyInfo>> findMatches(String prefix, FuzzyMap<PropertyInfo> index) {
|
||||
List<Match<PropertyInfo>> matches = index.find(camelCaseToHyphens(prefix));
|
||||
return matches;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansMod
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness.CustomizableProjectContent;
|
||||
@@ -58,7 +58,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
};
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@@ -66,7 +66,7 @@ public class AutowiredHoverProviderTest {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.ide.vscode.boot.java.beans.ComponentSymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.beans.test.SpringIndexerHarness.TestSymbolInfo;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
public class SpringIndexerBeansTest {
|
||||
|
||||
private AnnotationHierarchyAwareLookup<SymbolProvider> symbolProviders;
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private JavaProjectFinder projectFinder;
|
||||
|
||||
@Before
|
||||
@@ -39,7 +39,7 @@ public class SpringIndexerBeansTest {
|
||||
symbolProviders.put(Annotations.BEAN, new BeansSymbolProvider());
|
||||
symbolProviders.put(Annotations.COMPONENT, new ComponentSymbolProvider());
|
||||
|
||||
harness = BootLanguageServerHarness.builder().build();
|
||||
harness = BootJavaLanguageServerHarness.builder().build();
|
||||
projectFinder = harness.getProjectFinder();
|
||||
harness.intialize(new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI()));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.ide.vscode.boot.java.beans.ComponentSymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.beans.test.SpringIndexerHarness.TestSymbolInfo;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
public class SpringIndexerFunctionBeansTest {
|
||||
|
||||
private AnnotationHierarchyAwareLookup<SymbolProvider> symbolProviders;
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private JavaProjectFinder projectFinder;
|
||||
|
||||
@Before
|
||||
@@ -39,7 +39,7 @@ public class SpringIndexerFunctionBeansTest {
|
||||
symbolProviders.put(Annotations.BEAN, new BeansSymbolProvider());
|
||||
symbolProviders.put(Annotations.COMPONENT, new ComponentSymbolProvider());
|
||||
|
||||
harness = BootLanguageServerHarness.builder().build();
|
||||
harness = BootJavaLanguageServerHarness.builder().build();
|
||||
projectFinder = harness.getProjectFinder();
|
||||
harness.intialize(new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI()));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.ide.vscode.boot.java.BootJavaLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ConditionalsLiveHoverTest {
|
||||
public void setup() throws Exception {
|
||||
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
.build();
|
||||
|
||||
@@ -16,13 +16,13 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
public class ActiveProfilesHoverTest {
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@@ -30,7 +30,7 @@ public class ActiveProfilesHoverTest {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.junit.Test;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
@@ -26,14 +26,14 @@ public class ActuatorWarningHoverTest {
|
||||
private static final String ACTUATOR_PROJECT = "empty-boot-15-web-app";
|
||||
private static final String NO_ACTUATOR_PROJECT = "no-actuator-boot-15-web-app";
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansMod
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness.CustomizableProjectContent;
|
||||
@@ -41,7 +41,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
};
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@@ -49,7 +49,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansMod
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness.CustomizableProjectContent;
|
||||
@@ -55,7 +55,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
|
||||
};
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@@ -63,7 +63,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
|
||||
@@ -19,13 +19,13 @@ import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansMod
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
public class FunctionInjectionsHoverProviderTest {
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@@ -33,7 +33,7 @@ public class FunctionInjectionsHoverProviderTest {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.ide.vscode.boot.java.BootJavaLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class RequestMappingLiveHoverTest {
|
||||
public void setup() throws Exception {
|
||||
|
||||
mockAppProvider = new MockRunningAppProvider();
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.runningAppProvider(mockAppProvider.provider)
|
||||
.watchDogInterval(Duration.ofMillis(100))
|
||||
.build();
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
@@ -28,11 +28,11 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
*/
|
||||
public class RequestMappingSymbolProviderTest {
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness = BootLanguageServerHarness.builder().build();
|
||||
harness = BootJavaLanguageServerHarness.builder().build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.TestAsserts;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
@@ -31,13 +31,13 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
*/
|
||||
public class ScopeCompletionTest {
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private Editor editor;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
IJavaProject testProject = ProjectsHarness.INSTANCE.mavenProject("test-annotations");
|
||||
harness = BootLanguageServerHarness.builder().mockDefaults().build();
|
||||
harness = BootJavaLanguageServerHarness.builder().mockDefaults().build();
|
||||
harness.useProject(testProject);
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.maven.MavenCore;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
@@ -41,16 +41,16 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
*/
|
||||
public class CompilationUnitCacheTest {
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness = BootLanguageServerHarness.builder().build();
|
||||
harness = BootJavaLanguageServerHarness.builder().build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cu_cached() throws Exception {
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults().build();
|
||||
harness.useProject(new IJavaProject() {
|
||||
@Override
|
||||
@@ -91,7 +91,7 @@ public class CompilationUnitCacheTest {
|
||||
|
||||
@Test
|
||||
public void cu_cache_invalidated_by_doc_change() throws Exception {
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults().build();
|
||||
harness.useProject(new IJavaProject() {
|
||||
@Override
|
||||
@@ -122,7 +122,7 @@ public class CompilationUnitCacheTest {
|
||||
|
||||
@Test
|
||||
public void cu_cache_invalidated_by_doc_close() throws Exception {
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults().build();
|
||||
harness.useProject(new IJavaProject() {
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.ide.vscode.boot.java.requestmapping.RequestMappingSym
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexer;
|
||||
import org.springframework.ide.vscode.commons.maven.MavenCore;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ public class SpringIndexerTest {
|
||||
public void setup() throws Exception {
|
||||
symbolProviders = new HashMap<>();
|
||||
symbolProviders.put(Annotations.SPRING_REQUEST_MAPPING, new RequestMappingSymbolProvider());
|
||||
harness = BootLanguageServerHarness.builder().build();
|
||||
harness = BootJavaLanguageServerHarness.builder().build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,13 +21,13 @@ import java.io.File;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServer;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.DefaultSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
|
||||
import org.springframework.ide.vscode.commons.maven.MavenCore;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ public class SpringPropertyIndexTest {
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness = BootLanguageServerHarness.builder().build();
|
||||
harness = BootJavaLanguageServerHarness.builder().build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.ide.vscode.project.harness.PropertyIndexHarness;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.ide.vscode.project.harness.PropertyIndexHarness;
|
||||
*/
|
||||
public class ValueCompletionTest {
|
||||
|
||||
private BootLanguageServerHarness harness;
|
||||
private BootJavaLanguageServerHarness harness;
|
||||
private IJavaProject testProject;
|
||||
|
||||
private Editor editor;
|
||||
@@ -48,7 +48,7 @@ public class ValueCompletionTest {
|
||||
// But it is not used in the indexProvider.
|
||||
//This is a bit odd... but we preserved the strangeness how it was.
|
||||
testProject = ProjectsHarness.INSTANCE.mavenProject("test-annotations");
|
||||
harness = BootLanguageServerHarness.builder()
|
||||
harness = BootJavaLanguageServerHarness.builder()
|
||||
.mockDefaults()
|
||||
.projectFinder(d -> Optional.ofNullable(getTestProject()))
|
||||
.build();
|
||||
|
||||
@@ -28,6 +28,8 @@ import org.springframework.ide.vscode.boot.BootLanguageServer;
|
||||
import org.springframework.ide.vscode.boot.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.metadata.CachingValueProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertiesLoader;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
@@ -1587,9 +1589,16 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
|
||||
@Override
|
||||
protected SimpleLanguageServer newLanguageServer() {
|
||||
ComposableLanguageServer server = BootLanguageServer.create(
|
||||
s -> new BootLanguageServerParams(javaProjectFinder, null, md.getIndexProvider(),
|
||||
typeUtilProvider));
|
||||
ComposableLanguageServer<?> server = BootLanguageServer.create(
|
||||
s -> new BootLanguageServerParams(
|
||||
javaProjectFinder,
|
||||
null,
|
||||
md.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
)
|
||||
);
|
||||
server.setMaxCompletionsNumber(-1);
|
||||
return server.getServer();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,11 @@ import org.springframework.ide.vscode.boot.BootLanguageServer;
|
||||
import org.springframework.ide.vscode.boot.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.metadata.CachingValueProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.properties.BootPropertiesLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
@@ -3706,9 +3709,16 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
|
||||
@Override
|
||||
protected SimpleLanguageServer newLanguageServer() {
|
||||
ComposableLanguageServer server = BootLanguageServer.create(
|
||||
s -> new BootLanguageServerParams(javaProjectFinder, null, md.getIndexProvider(),
|
||||
typeUtilProvider));
|
||||
ComposableLanguageServer<?> server = BootLanguageServer.create(
|
||||
s -> new BootLanguageServerParams(
|
||||
javaProjectFinder,
|
||||
null,
|
||||
md.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
)
|
||||
);
|
||||
server.setMaxCompletionsNumber(-1);
|
||||
return server.getServer();
|
||||
}
|
||||
|
||||
@@ -14,17 +14,18 @@ import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.springframework.ide.vscode.boot.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServer;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
|
||||
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;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LSFactory;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
|
||||
public class BootLanguageServerHarness extends LanguageServerHarness<BootJavaLanguageServer> {
|
||||
public class BootJavaLanguageServerHarness extends LanguageServerHarness<BootJavaLanguageServer> {
|
||||
|
||||
private PropertyIndexHarness indexHarness;
|
||||
private final JavaProjectFinder projectFinder = (doc) -> getServerWrapper().getProjectFinder().find(doc);
|
||||
@@ -43,16 +44,17 @@ public class BootLanguageServerHarness extends LanguageServerHarness<BootJavaLan
|
||||
|
||||
public static class Builder {
|
||||
|
||||
LSFactory<BootJavaLanguageServerParams> defaultsFactory = BootJavaLanguageServerParams.createTestDefault();
|
||||
LSFactory<BootLanguageServerParams> defaultsFactory = BootLanguageServerParams.createTestDefault();
|
||||
private JavaProjectFinder projectFinder = null;
|
||||
private ProjectObserver projectObserver = null;
|
||||
private SpringPropertyIndexProvider indexProvider = null;
|
||||
private RunningAppProvider runningAppProvider = null;
|
||||
private PropertyIndexHarness indexHarness = null;
|
||||
private Duration watchDogInterval = null;
|
||||
private TypeUtilProvider typeUtilProvider = null;
|
||||
|
||||
public BootLanguageServerHarness build() throws Exception {
|
||||
BootLanguageServerHarness harness = new BootLanguageServerHarness(this);
|
||||
public BootJavaLanguageServerHarness build() throws Exception {
|
||||
BootJavaLanguageServerHarness harness = new BootJavaLanguageServerHarness(this);
|
||||
return harness;
|
||||
}
|
||||
|
||||
@@ -89,14 +91,15 @@ public class BootLanguageServerHarness extends LanguageServerHarness<BootJavaLan
|
||||
/**
|
||||
* This constructor is private. Use the builder api instead.
|
||||
*/
|
||||
private BootLanguageServerHarness(Builder builder) throws Exception {
|
||||
private BootJavaLanguageServerHarness(Builder builder) throws Exception {
|
||||
super(() -> {
|
||||
LSFactory<BootJavaLanguageServerParams> params = (server) -> {
|
||||
BootJavaLanguageServerParams defaults = BootJavaLanguageServerParams.createTestDefault().create(server);
|
||||
return new BootJavaLanguageServerParams(
|
||||
LSFactory<BootLanguageServerParams> params = (server) -> {
|
||||
BootLanguageServerParams defaults = BootLanguageServerParams.createTestDefault().create(server);
|
||||
return new BootLanguageServerParams(
|
||||
builder.projectFinder==null?defaults.projectFinder:builder.projectFinder,
|
||||
builder.projectObserver==null?defaults.projectObserver:builder.projectObserver,
|
||||
builder.indexProvider==null?defaults.indexProvider:builder.indexProvider,
|
||||
builder.typeUtilProvider==null?defaults.typeUtilProvider:builder.typeUtilProvider,
|
||||
builder.runningAppProvider==null?defaults.runningAppProvider:builder.runningAppProvider,
|
||||
builder.watchDogInterval==null?defaults.watchDogInterval:builder.watchDogInterval
|
||||
);
|
||||
@@ -19,8 +19,10 @@ import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMe
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation;
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ValueHint;
|
||||
import org.springframework.ide.vscode.boot.configurationmetadata.ValueProvider;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.SpringPropertyIndex;
|
||||
import org.springframework.ide.vscode.boot.java.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
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.commons.java.IClasspath;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
@@ -38,11 +40,11 @@ public class PropertyIndexHarness {
|
||||
|
||||
protected final SpringPropertyIndexProvider indexProvider = new SpringPropertyIndexProvider() {
|
||||
@Override
|
||||
public FuzzyMap<ConfigurationMetadataProperty> getIndex(IDocument doc) {
|
||||
public FuzzyMap<PropertyInfo> getIndex(IDocument doc) {
|
||||
synchronized (PropertyIndexHarness.this) {
|
||||
if (index==null) {
|
||||
IClasspath classpath = testProject == null ? null : testProject.getClasspath();
|
||||
index = new SpringPropertyIndex(classpath);
|
||||
index = new SpringPropertyIndex(ValueProviderRegistry.getDefault(), classpath);
|
||||
for (ConfigurationMetadataProperty propertyInfo : datas.values()) {
|
||||
index.add(propertyInfo);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ package org.springframework.ide.vscode.boot;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.ide.vscode.boot.properties.BootLanguageServer;
|
||||
import org.springframework.ide.vscode.boot.properties.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LaunguageServerApp;
|
||||
import org.springframework.ide.vscode.commons.util.LogRedirect;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user