PT #160596363: Fixes for live hints and navigation for multi-projects

Initial work: highlights fixed, source links bean

SourceLinks bean uses project finder

Project finder all projects. Source entries for dependency projects.

Properly support peer projects for fall back Gradle projects

Update code minings for e4.9
This commit is contained in:
BoykoAlex
2019-01-17 19:01:04 -05:00
parent a115b736e4
commit 0681baa876
58 changed files with 710 additions and 312 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -80,10 +80,10 @@ public class BootLanguagServerBootApp {
return new ValueProviderRegistry();
}
@Bean InitializingBean initializeValueProviders(ValueProviderRegistry r, @Qualifier("adHocProperties") ProjectBasedPropertyIndexProvider adHocProperties) {
@Bean InitializingBean initializeValueProviders(ValueProviderRegistry r, @Qualifier("adHocProperties") ProjectBasedPropertyIndexProvider adHocProperties, SourceLinks sourceLinks) {
return () -> {
r.def("logger-name", LoggerNameProvider.factory(adHocProperties));
r.def("class-reference", ClassReferenceProvider.FACTORY);
r.def("logger-name", LoggerNameProvider.factory(adHocProperties, sourceLinks));
r.def("class-reference", ClassReferenceProvider.factory(sourceLinks));
};
}
@@ -93,8 +93,8 @@ public class BootLanguagServerBootApp {
}
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
@Bean SourceLinks sourceLinks(SimpleLanguageServer server, CompilationUnitCache cuCache) {
return SourceLinkFactory.createSourceLinks(server, cuCache);
@Bean SourceLinks sourceLinks(SimpleLanguageServer server, CompilationUnitCache cuCache, BootLanguageServerParams params) {
return SourceLinkFactory.createSourceLinks(server, cuCache, params.projectFinder);
}
@Bean CompilationUnitCache cuCache(BootLanguageServerParams params, SimpleTextDocumentService documents) {
@@ -133,13 +133,13 @@ public class BootLanguagServerBootApp {
return YamlStructureProvider.DEFAULT;
}
@Bean YamlAssistContextProvider yamlAssistContextProvider(BootLanguageServerParams params, JavaElementLocationProvider javaElementLocationProvider) {
@Bean YamlAssistContextProvider yamlAssistContextProvider(BootLanguageServerParams params, JavaElementLocationProvider javaElementLocationProvider, SourceLinks sourceLinks) {
return new YamlAssistContextProvider() {
@Override
public YamlAssistContext getGlobalAssistContext(YamlDocument ydoc) {
IDocument doc = ydoc.getDocument();
FuzzyMap<PropertyInfo> index = params.indexProvider.getIndex(doc);
return ApplicationYamlAssistContext.global(ydoc, index, new PropertyCompletionFactory(), params.typeUtilProvider.getTypeUtil(doc), RelaxedNameConfig.COMPLETION_DEFAULTS, javaElementLocationProvider);
return ApplicationYamlAssistContext.global(ydoc, index, new PropertyCompletionFactory(), params.typeUtilProvider.getTypeUtil(sourceLinks, doc), RelaxedNameConfig.COMPLETION_DEFAULTS, javaElementLocationProvider);
}
};
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -70,7 +70,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
//TODO: ComposableLanguageServer object instance serves no purpose anymore. The constructor really just contains
// 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 BootPropertiesLanguageServerComponents(server, params, javaElementLocationProvider, parser, yamlStructureProvider, yamlAssistContextProvider, sourceLinks));
builder.add(new BootJavaLanguageServerComponents(server, params, sourceLinks, cuCache, adHocProperties));
components = builder.build(server);
params.projectObserver.addListener(reconcileOpenDocuments(server, components));

View File

@@ -13,10 +13,12 @@ package org.springframework.ide.vscode.boot.app;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
import org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsService;
import org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsServiceWithFallback;
@@ -101,7 +103,7 @@ public class BootLanguageServerParams {
jdtProjectCache.filter(project -> SpringProjectUtil.isBootProject(project) || SpringProjectUtil.isSpringProject(project)),
jdtProjectCache,
indexProvider,
(IDocument doc) -> new TypeUtil(jdtProjectCache.find(new TextDocumentIdentifier(doc.getUri()))),
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, jdtProjectCache.find(new TextDocumentIdentifier(doc.getUri()))),
RunningAppProvider.createDefault(server),
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
);
@@ -141,6 +143,11 @@ public class BootLanguageServerParams {
public IJavadocProvider javadocProvider(String projectUri, CPE cpe) {
return javadocService.javadocProvider(projectUri, cpe);
}
@Override
public Collection<? extends IJavaProject> all() {
return javaProjectFinder.all();
}
};
}
@@ -164,7 +171,7 @@ public class BootLanguageServerParams {
javaProjectFinder.filter(project -> SpringProjectUtil.isBootProject(project) || SpringProjectUtil.isSpringProject(project)),
projectObserver,
indexProvider,
(IDocument doc) -> new TypeUtil(javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
RunningAppProvider.NULL,
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
);

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -18,6 +18,7 @@ import org.eclipse.lsp4j.TextDocumentPositionParams;
import org.gradle.internal.impldep.com.google.common.collect.ImmutableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
import org.springframework.ide.vscode.boot.metadata.types.Type;
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
@@ -46,6 +47,9 @@ public class PropertiesJavaDefinitionHandler implements DefinitionHandler, Langu
@Autowired
private JavaElementLocationProvider javaElementLocationProvider;
@Autowired
private SourceLinks sourceLinks;
@Autowired
private BootLanguageServerParams params;
@@ -53,7 +57,7 @@ public class PropertiesJavaDefinitionHandler implements DefinitionHandler, Langu
public List<Location> handle(TextDocumentPositionParams position) {
try {
TextDocument doc = documents.get(position);
TypeUtil typeUtil = params.typeUtilProvider.getTypeUtil(doc);
TypeUtil typeUtil = params.typeUtilProvider.getTypeUtil(sourceLinks, doc);
FuzzyMap<PropertyInfo> index = params.indexProvider.getIndex(doc);
int offset;
offset = doc.toOffset(position.getPosition());

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 Pivotal, Inc.
* Copyright (c) 2017, 2019 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
@@ -264,7 +264,7 @@ public class AutowiredHoverProvider implements HoverProvider {
}
private static boolean isCompatibleBeanType(IJavaProject jp, LiveBean bean, String bindingQualifiedName) {
String rawLiveBeanFqName = bean.getType();
String rawLiveBeanFqName = bean.getType(true);
int idx = rawLiveBeanFqName.indexOf('<');
// Trim the generic parameters part if it's present
String liveBeanTypeFQName = idx < 0 ? rawLiveBeanFqName : rawLiveBeanFqName.substring(0, idx);

View File

@@ -10,9 +10,11 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.handlers;
import java.io.File;
import java.net.URI;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import org.eclipse.jdt.core.dom.ASTNode;
@@ -42,6 +44,7 @@ import org.springframework.ide.vscode.commons.java.IClasspath;
import org.springframework.ide.vscode.commons.java.IClasspathUtil;
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.ls.Classpath;
import org.springframework.ide.vscode.commons.languageserver.util.HoverHandler;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
@@ -105,14 +108,28 @@ public class BootJavaHoverProvider implements HoverHandler {
if (!hasActuatorDependency(project.get())) {
// double check the running apps in case there is a non-boot app running with live beans enabled
boolean nonBootLiveBeansAround = false;
boolean onAppsClasspath = false;
for (SpringBootApp bootApp : runningBootApps) {
if (bootApp.providesNonBootLiveBeans()) {
nonBootLiveBeansAround = true;
break;
} else {
try {
List<File> binaryRoots = IClasspathUtil.getBinaryRoots(project.get().getClasspath(), Classpath::isSource);
for (String path : bootApp.getClasspath()) {
File file = new File(path);
if (binaryRoots.contains(file)) {
onAppsClasspath = true;
break;
}
}
} catch (Exception e) {
logger.error("", e);
}
}
}
if (!nonBootLiveBeansAround) {
if (!nonBootLiveBeansAround && !onAppsClasspath) {
return new CodeLens[0];
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -14,7 +14,6 @@ import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.Stack;
@@ -31,6 +30,7 @@ import org.springframework.ide.vscode.commons.java.IClasspath;
import org.springframework.ide.vscode.commons.java.IJavaModuleData;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.javadoc.TypeUrlProviderFromContainerUrl;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.util.text.Region;
/**
@@ -45,12 +45,30 @@ public abstract class AbstractSourceLinks implements SourceLinks {
private CompilationUnitCache cuCache;
protected AbstractSourceLinks(CompilationUnitCache cuCache) {
private JavaProjectFinder projectFinder;
protected AbstractSourceLinks(CompilationUnitCache cuCache, JavaProjectFinder projectFinder) {
this.cuCache = cuCache;
this.projectFinder = projectFinder;
}
@Override
public Optional<String> sourceLinkUrlForFQName(IJavaProject project, String fqName) {
Optional<String> url = project == null ? Optional.empty() : getSourceLinkUrlForFQName(project, fqName);
if (!url.isPresent()) {
for (IJavaProject jp : projectFinder.all()) {
if (jp != project) {
url = getSourceLinkUrlForFQName(jp, fqName);
if (url.isPresent()) {
break;
}
}
}
}
return url;
}
private Optional<String> getSourceLinkUrlForFQName(IJavaProject project, String fqName) {
IJavaModuleData classpathResource = project.getIndex().findClasspathResourceContainer(fqName);
if (classpathResource != null) {
File file = classpathResource.getContainer();
@@ -64,17 +82,10 @@ public abstract class AbstractSourceLinks implements SourceLinks {
}
@Override
public Optional<String> sourceLinkUrlForClasspathResource(IJavaProject project, String path) {
int idx = path.lastIndexOf(CLASS);
if (idx >= 0) {
Path p = Paths.get(path.substring(0, idx));
return sourceLinkUrlForFQName(project, p.toString().replace(File.separator, "."));
}
return Optional.empty();
public Optional<String> sourceLinkUrlForClasspathResource(String path) {
return SourceLinks.sourceLinkUrlForClasspathResource(this, projectFinder, path);
}
private Optional<String> javaSourceLinkUrl(IJavaProject project, String fqName, IJavaModuleData folderModuleData) {
IClasspath classpath = project.getClasspath();
return SourceLinks.sourceFromSourceFolder(fqName, classpath)

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.commons.java.IJavaModuleData;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.util.text.Region;
import com.google.common.base.Supplier;
@@ -36,8 +37,8 @@ public class AtomSourceLinks extends AbstractSourceLinks {
private static Supplier<Logger> LOG = Suppliers.memoize(() -> LoggerFactory.getLogger(AbstractSourceLinks.class));
public AtomSourceLinks(CompilationUnitCache cuCache) {
super(cuCache);
public AtomSourceLinks(CompilationUnitCache cuCache, JavaProjectFinder projectFinder) {
super(cuCache, projectFinder);
}
@Override

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -10,12 +10,10 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.links;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import org.slf4j.Logger;
@@ -23,6 +21,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.java.IMember;
import org.springframework.ide.vscode.commons.java.IType;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
/**
* Source links for Eclipse client. Eclipse IntroURLs.
@@ -47,21 +46,37 @@ public class EclipseSourceLinks implements SourceLinks {
private static final Logger log = LoggerFactory.getLogger(EclipseSourceLinks.class);
@Override
public Optional<String> sourceLinkUrlForFQName(IJavaProject project, String fqName) {
return Optional.ofNullable(eclipseIntroUri(project, fqName)).map(uri -> uri.toString());
private JavaProjectFinder projectFinder;
public EclipseSourceLinks(JavaProjectFinder projectFinder) {
this.projectFinder = projectFinder;
}
@Override
public Optional<String> sourceLinkUrlForClasspathResource(IJavaProject project, String path) {
int idx = path.lastIndexOf(CLASS);
if (idx >= 0) {
Path p = Paths.get(path.substring(0, idx));
return sourceLinkUrlForFQName(project, p.toString().replace(File.separator, "."));
public Optional<String> sourceLinkUrlForFQName(IJavaProject project, String fqName) {
return findProjectForFQName(project, fqName).map(p -> eclipseIntroUri(p, fqName)).map(uri -> uri.toString());
}
private Optional<IJavaProject> findProjectForFQName(IJavaProject project, String fqName) {
if (project != null && project.findType(fqName) != null) {
return Optional.of(project);
} else {
for (IJavaProject jp : projectFinder.all()) {
if (jp != project) {
if (jp.findType(fqName) != null) {
return Optional.of(jp);
}
}
}
}
return Optional.empty();
}
@Override
public Optional<String> sourceLinkUrlForClasspathResource(String path) {
return SourceLinks.sourceLinkUrlForClasspathResource(this, projectFinder, path);
}
@Override
public Optional<String> sourceLinkForResourcePath(Path path) {
return Optional.ofNullable(eclipseIntroUri(path)).map(uri -> uri.toString());

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.links;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -20,15 +18,18 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
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.ls.JavaDataParams;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
public class JavaServerSourceLinks implements SourceLinks {
private SimpleLanguageServer server;
private JavaProjectFinder projectFinder;
public JavaServerSourceLinks(SimpleLanguageServer server) {
public JavaServerSourceLinks(SimpleLanguageServer server, JavaProjectFinder projectFinder) {
this.server = server;
this.projectFinder = projectFinder;
}
@Override
@@ -37,7 +38,8 @@ public class JavaServerSourceLinks implements SourceLinks {
bindingKey.append('L');
bindingKey.append(fqName.replace('.', '/'));
bindingKey.append(';');
CompletableFuture<Optional<String>> link = server.getClient().javadocHoverLink(new JavaDataParams(project.getLocationUri().toString(), bindingKey.toString()))
String projectUri = project == null ? null : project.getLocationUri().toString();
CompletableFuture<Optional<String>> link = server.getClient().javadocHoverLink(new JavaDataParams(projectUri, bindingKey.toString(), true))
.thenApply(response -> Optional.ofNullable(response.getLink()));
try {
return link.get(10, TimeUnit.SECONDS);
@@ -48,13 +50,8 @@ public class JavaServerSourceLinks implements SourceLinks {
}
@Override
public Optional<String> sourceLinkUrlForClasspathResource(IJavaProject project, String path) {
int idx = path.lastIndexOf(CLASS);
if (idx >= 0) {
Path p = Paths.get(path.substring(0, idx));
return sourceLinkUrlForFQName(project, p.toString().replace(File.separator, "."));
}
return Optional.empty();
public Optional<String> sourceLinkUrlForClasspathResource(String path) {
return SourceLinks.sourceLinkUrlForClasspathResource(this, projectFinder, path);
}
@Override

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -13,9 +13,9 @@ package org.springframework.ide.vscode.boot.java.links;
import java.nio.file.Path;
import java.util.Optional;
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.util.LspClient;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
@@ -35,7 +35,7 @@ public final class SourceLinkFactory {
}
@Override
public Optional<String> sourceLinkUrlForClasspathResource(IJavaProject project, String path) {
public Optional<String> sourceLinkUrlForClasspathResource(String path) {
return Optional.empty();
}
@@ -51,26 +51,20 @@ public final class SourceLinkFactory {
* @param server the boot LS
* @return appropriate source links object
*/
public static SourceLinks createSourceLinks(SimpleLanguageServer server, CompilationUnitCache cuCache) {
public static SourceLinks createSourceLinks(SimpleLanguageServer server, CompilationUnitCache cuCache, JavaProjectFinder projectFinder) {
switch (LspClient.currentClient()) {
case VSCODE:
return /*new VSCodeSourceLinks(cuCache);*/server == null ? new VSCodeSourceLinks(cuCache) :new JavaServerSourceLinks(server);
return /*new VSCodeSourceLinks(cuCache);*/server == null ? new VSCodeSourceLinks(cuCache, projectFinder) :new JavaServerSourceLinks(server, projectFinder);
case THEIA:
return new VSCodeSourceLinks(cuCache);
return new VSCodeSourceLinks(cuCache, projectFinder);
case ECLIPSE:
return /*new EclipseSourceLinks();*/server == null ? new EclipseSourceLinks() : new JavaServerSourceLinks(server);
return /*new EclipseSourceLinks();*/server == null ? new EclipseSourceLinks(projectFinder) : new JavaServerSourceLinks(server, projectFinder);
case ATOM:
return new AtomSourceLinks(cuCache);
return new AtomSourceLinks(cuCache, projectFinder);
default:
return NO_SOURCE_LINKS;
}
}
@Deprecated
public static SourceLinks createSourceLinks(BootJavaLanguageServerComponents server) {
return server == null
? createSourceLinks(null, (CompilationUnitCache)null)
: createSourceLinks(server.getServer(), server.getCompilationUnitCache());
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.links;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
@@ -18,6 +19,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.java.IClasspath;
@@ -25,6 +27,9 @@ import org.springframework.ide.vscode.commons.java.IClasspathUtil;
import org.springframework.ide.vscode.commons.java.IJavaModuleData;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.javadoc.TypeUrlProviderFromContainerUrl;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath.CPE;
/**
* Instance is able to provide client specific URL links to navigate to a
@@ -99,6 +104,36 @@ public interface SourceLinks {
return Optional.empty();
}
public static Optional<String> sourceLinkUrlForClasspathResource(SourceLinks sourceLinks, JavaProjectFinder projectFinder, String path) {
if (projectFinder != null) {
int idx = path.lastIndexOf(CLASS);
if (idx >= 0) {
Path filePath = Paths.get(path.substring(0, idx));
IJavaProject project = projectFinder.find(new TextDocumentIdentifier(filePath.toUri().toString())).orElse(null);
if (project != null) {
try {
for (CPE cpe : project.getClasspath().getClasspathEntries()) {
if (Classpath.isSource(cpe)) {
Path cpeBinaryPath = IClasspathUtil.binaryLocation(cpe).toPath();
if (filePath.startsWith(cpeBinaryPath)) {
String fqName = cpeBinaryPath.relativize(filePath).toString().replace(File.separator, ".");
Optional<String> link = sourceLinks.sourceLinkUrlForFQName(project, fqName);
if (link.isPresent()) {
return link;
}
}
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
}
return Optional.empty();
}
/**
* Creates link to source file defining the type passed with it's fully qualified name
@@ -114,7 +149,7 @@ public interface SourceLinks {
* @param path the path to the classpath resource
* @return the link URL optional
*/
Optional<String> sourceLinkUrlForClasspathResource(IJavaProject project, String path);
Optional<String> sourceLinkUrlForClasspathResource(String path);
/**
* Creates link to a file specified by it's path

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -17,6 +17,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.commons.java.IJavaModuleData;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.util.text.Region;
/**
@@ -27,8 +28,8 @@ import org.springframework.ide.vscode.commons.util.text.Region;
*/
public class VSCodeSourceLinks extends AbstractSourceLinks {
public VSCodeSourceLinks(CompilationUnitCache cuCache) {
super(cuCache);
public VSCodeSourceLinks(CompilationUnitCache cuCache, JavaProjectFinder projectFinder) {
super(cuCache, projectFinder);
}
@Override

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 Pivotal, Inc.
* Copyright (c) 2017, 2019 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
@@ -145,7 +145,7 @@ public class LiveHoverUtils {
LiveBeansModel beansModel = app.getBeans();
if (beansModel != null) {
List<LiveBean> relevantBeans = beansModel.getBeansOfName(definedBean.getId());
String type = definedBean.getType();
String type = definedBean.getType(true);
if (type != null) {
// TODO: check if we should check for bean type rather than id that we build ourselves based on type
// if (relevantBeans.isEmpty()) {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
@@ -241,18 +243,18 @@ public class SpringLiveChangeDetectionWatchdog {
for (IJavaProject project : projects) {
if (SpringResource.FILE.equals(type)) {
String relativePath = SpringResource.projectRelativePath(project, path);
if (relativePath != path && path.endsWith(SourceLinks.CLASS)) {
result = sourceLinks.sourceLinkUrlForClasspathResource(project, relativePath).get();
break;
} else {
result = sourceLinks.sourceLinkUrlForClasspathResource(path).get();
if (result == null) {
result = sourceLinks.sourceLinkForResourcePath(Paths.get(path)).get();
break;
}
break;
}
else if (SpringResource.CLASS_PATH_RESOURCE.equals(type)) {
result = sourceLinks.sourceLinkUrlForClasspathResource(project, path).get();
int idx = path.lastIndexOf(SourceLinks.CLASS);
if (idx >= 0) {
Path p = Paths.get(path.substring(0, idx));
result = sourceLinks.sourceLinkUrlForFQName(project, p.toString().replace(File.separator, ".")).get();
}
break;
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 Pivotal, Inc.
* Copyright (c) 2017, 2019 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
@@ -67,20 +67,22 @@ public class SpringResource {
if (type==null) {
return path; //path is just the raw text in this case
}
Optional<String> linkUrl;
Optional<String> linkUrl = Optional.empty();
switch (type) {
case FILE:
String relativePath = projectRelativePath(project, path);
if (relativePath != path && path.endsWith(SourceLinks.CLASS)) {
linkUrl = sourceLinks.sourceLinkUrlForClasspathResource(project, relativePath);
} else {
linkUrl = sourceLinks.sourceLinkUrlForClasspathResource(path);
if (!linkUrl.isPresent()) {
linkUrl = sourceLinks.sourceLinkForResourcePath(Paths.get(path));
}
// not a project relative path
return linkUrl.isPresent() ? Renderables.link(relativePath, linkUrl.get()).toMarkdown()
return linkUrl.isPresent() ? Renderables.link(projectRelativePath(project, path), linkUrl.get()).toMarkdown()
: "`" + projectRelativePath(project, path) + "`";
case CLASS_PATH_RESOURCE:
linkUrl = sourceLinks.sourceLinkUrlForClasspathResource(project, path);
int idx = path.lastIndexOf(SourceLinks.CLASS);
if (idx >= 0) {
Path p = Paths.get(path.substring(0, idx));
linkUrl = sourceLinks.sourceLinkUrlForFQName(project, p.toString().replace(File.separator, "."));
}
return linkUrl.isPresent() ? Renderables.link(path, linkUrl.get()).toMarkdown() : "`"+path+"`";
default:
return path;

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.jdt.ls;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@@ -24,6 +25,7 @@ import org.springframework.ide.vscode.commons.util.Assert;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import reactor.core.Disposable;
@@ -113,4 +115,18 @@ public class JavaProjectsServiceWithFallback implements JavaProjectsService {
return IJavadocProvider.NULL;
}
@Override
public Collection<? extends IJavaProject> all() {
if (mainServiceInitialized.isDone()) {
if (mainServiceInitialized.isCompletedExceptionally()) {
return fallback.get().all();
} else {
return main.all();
}
} else {
log.debug("find => NOT INITIALIZED YET");
}
return ImmutableList.of();
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -210,4 +210,9 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
}
});
}
@Override
public Collection<? extends IJavaProject> all() {
return table.values();
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -18,12 +18,14 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry.ValueProviderStrategy;
import org.springframework.ide.vscode.boot.metadata.hints.StsValueHint;
import org.springframework.ide.vscode.commons.java.Flags;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.java.IType;
import org.springframework.ide.vscode.commons.util.Log;
import org.springframework.ide.vscode.commons.util.StringUtil;
import com.google.common.cache.Cache;
@@ -40,36 +42,35 @@ import reactor.core.publisher.Flux;
* @author Alex Boyko
*/
public class ClassReferenceProvider extends CachingValueProvider {
private static final Logger log = LoggerFactory.getLogger(ClassReferenceProvider.class);
/**
* Default value for the 'concrete' parameter.
*/
private static final boolean DEFAULT_CONCRETE = true;
private static final ClassReferenceProvider UNTARGETTED_INSTANCE = new ClassReferenceProvider(null, DEFAULT_CONCRETE);
private static final ClassReferenceProvider UNTARGETTED_INSTANCE = new ClassReferenceProvider(null, DEFAULT_CONCRETE, null);
public static final Function<Map<String, Object>, ValueProviderStrategy> FACTORY = applyOn(
1, TimeUnit.MINUTES,
(params) -> {
String target = getTarget(params);
Boolean concrete = getConcrete(params);
if (target!=null || concrete!=null) {
if (concrete==null) {
concrete = DEFAULT_CONCRETE;
}
return new ClassReferenceProvider(target, concrete);
}
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) -> {
public static final Function<Map<String, Object>, ValueProviderStrategy> factory(SourceLinks sourceLinks) {
long duration = 1;
TimeUnit unit = TimeUnit.MINUTES;
Cache<Map<String, Object>, ValueProviderStrategy> cache = CacheBuilder.newBuilder().expireAfterAccess(duration, unit).expireAfterWrite(duration, unit).build();
return (params) -> {
try {
return cache.get(k, () -> func.apply(k));
return cache.get(params, () -> {
String target = getTarget(params);
Boolean concrete = getConcrete(params);
if (target!=null || concrete!=null) {
if (concrete==null) {
concrete = DEFAULT_CONCRETE;
}
return new ClassReferenceProvider(target, concrete, sourceLinks);
}
return UNTARGETTED_INSTANCE;
});
} catch (ExecutionException e) {
Log.log(e);
log.error("", e);
return null;
}
};
@@ -92,7 +93,7 @@ public class ClassReferenceProvider extends CachingValueProvider {
try {
return type.isInterface() || Flags.isAbstract(type.getFlags());
} catch (Exception e) {
Log.log(e);
log.error("", e);
return false;
}
}
@@ -109,7 +110,7 @@ public class ClassReferenceProvider extends CachingValueProvider {
}
}
} catch (Exception e) {
Log.log(e);
log.error("", e);
}
return null;
}
@@ -124,9 +125,12 @@ public class ClassReferenceProvider extends CachingValueProvider {
*/
private boolean concrete;
private ClassReferenceProvider(String target, boolean concrete) {
private SourceLinks sourceLinks;
private ClassReferenceProvider(String target, boolean concrete, SourceLinks sourceLinks) {
this.target = target;
this.concrete = concrete;
this.sourceLinks = sourceLinks;
}
@Override
@@ -147,7 +151,7 @@ public class ClassReferenceProvider extends CachingValueProvider {
.fuzzySearchTypes(query, type -> allSubclasses.contains(type))
.collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2()))
.flatMapIterable(l -> l)
.map(t -> StsValueHint.create(javaProject, t.getT1()));
.map(t -> StsValueHint.create(sourceLinks, javaProject, t.getT1()));
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -15,8 +15,8 @@ import java.util.Collection;
import java.util.Map;
import java.util.SortedMap;
import java.util.function.Function;
import java.util.function.Predicate;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry.ValueProviderStrategy;
import org.springframework.ide.vscode.boot.metadata.hints.StsValueHint;
import org.springframework.ide.vscode.commons.java.IJavaProject;
@@ -41,15 +41,17 @@ public class LoggerNameProvider extends CachingValueProvider {
private static final String LOGGING_GROUPS_PREFIX = "logging.group.";
private final ProjectBasedPropertyIndexProvider adhocProperties;
private final boolean includeGroups;
private final SourceLinks sourceLinks;
public LoggerNameProvider(ProjectBasedPropertyIndexProvider adhocProperties, boolean includeGroups) {
public LoggerNameProvider(ProjectBasedPropertyIndexProvider adhocProperties, boolean includeGroups, SourceLinks sourceLinks) {
this.adhocProperties = adhocProperties;
this.includeGroups = includeGroups;
this.sourceLinks = sourceLinks;
}
public static final Function<Map<String, Object>, ValueProviderStrategy> factory(ProjectBasedPropertyIndexProvider adhocProperties) {
public static final Function<Map<String, Object>, ValueProviderStrategy> factory(ProjectBasedPropertyIndexProvider adhocProperties, SourceLinks sourceLinks) {
return (params) -> {
return new LoggerNameProvider(adhocProperties, (boolean) params.getOrDefault("group", true));
return new LoggerNameProvider(adhocProperties, (boolean) params.getOrDefault("group", true), sourceLinks);
};
}
@@ -83,7 +85,7 @@ public class LoggerNameProvider extends CachingValueProvider {
.map(t -> Tuples.of(StsValueHint.create(t.getT1()), t.getT2())),
javaProject.getIndex()
.fuzzySearchTypes(query, null)
.map(t -> Tuples.of(StsValueHint.create(javaProject, t.getT1()), t.getT2()))
.map(t -> Tuples.of(StsValueHint.create(sourceLinks, javaProject, t.getT1()), t.getT2()))
)
.collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2()))
.flatMapIterable(l -> l)

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -15,8 +15,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation;
import org.springframework.ide.vscode.boot.configurationmetadata.ValueHint;
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.metadata.types.TypeUtil;
import org.springframework.ide.vscode.boot.metadata.util.DeprecationUtil;
@@ -63,8 +61,8 @@ public class StsValueHint {
/**
* Creates a hint out of an IJavaElement.
*/
public static StsValueHint create(String value, IJavaProject project, IJavaElement javaElement) {
return new StsValueHint(value, javaDocSnippet(project, javaElement), DeprecationUtil.extract(javaElement)) {
public static StsValueHint create(SourceLinks sourceLinks, String value, IJavaProject project, IJavaElement javaElement) {
return new StsValueHint(value, javaDocSnippet(sourceLinks, project, javaElement), DeprecationUtil.extract(javaElement)) {
@Override
public IJavaElement getJavaElement() {
return javaElement;
@@ -86,7 +84,7 @@ public class StsValueHint {
if (jp!=null) {
IType type = jp.findType(fqName);
if (type!=null) {
return create(jp, type);
return create(typeUtil.getSourceLinks(), jp, type);
}
}
} catch (Exception e) {
@@ -95,8 +93,8 @@ public class StsValueHint {
return null;
}
public static StsValueHint create(IJavaProject project, IType klass) {
return new StsValueHint(klass.getFullyQualifiedName(), javaDocSnippet(project, klass), DeprecationUtil.extract(klass)) {
public static StsValueHint create(SourceLinks sourceLinks, IJavaProject project, IType klass) {
return new StsValueHint(klass.getFullyQualifiedName(), javaDocSnippet(sourceLinks, project, klass), DeprecationUtil.extract(klass)) {
@Override
public IJavaElement getJavaElement() {
return klass;
@@ -122,9 +120,8 @@ public class StsValueHint {
return description;
}
private static Renderable javaDocSnippet(IJavaProject project, IJavaElement je) {
private static Renderable javaDocSnippet(SourceLinks sourceLinks, IJavaProject project, IJavaElement je) {
return Renderables.lazy(() -> {
SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks((BootJavaLanguageServerComponents)null);
return PropertyDocUtils.documentJavaElement(sourceLinks, project, je);
});
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -39,8 +39,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.convert.DurationStyle;
import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation;
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.metadata.ResourceHintProvider;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry.ValueProviderStrategy;
@@ -134,16 +132,18 @@ public class TypeUtil {
}
private IJavaProject javaProject;
private SourceLinks sourceLinks;
public TypeUtil(IJavaProject jp) {
public TypeUtil(SourceLinks sourceLinks, IJavaProject jp) {
//Note javaProject is allowed to be null, but only in unit testing context
// (This is so some tests can be run without an explicit jp needing to be created)
this.javaProject = jp;
this.sourceLinks = sourceLinks;
}
public TypeUtil(Optional<IJavaProject> maybeProject) {
this(maybeProject.orElse(null));
public TypeUtil(SourceLinks sourceLinks, Optional<IJavaProject> maybeProject) {
this(sourceLinks, maybeProject.orElse(null));
}
private static final Map<String, String> PRIMITIVE_TYPE_NAMES = new HashMap<>();
@@ -334,10 +334,10 @@ public class TypeUtil {
type.getFields().filter(f -> f.isEnumConstant()).forEach(f -> {
String rawName = f.getElementName();
if (addOriginal) {
enums.add(StsValueHint.create(rawName, javaProject, f));
enums.add(StsValueHint.create(sourceLinks, rawName, javaProject, f));
}
if (addLowerCased) {
enums.add(StsValueHint.create(StringUtil.upperCaseToHyphens(rawName), javaProject, f));
enums.add(StsValueHint.create(sourceLinks, StringUtil.upperCaseToHyphens(rawName), javaProject, f));
}
});
return enums.build();
@@ -655,6 +655,10 @@ public class TypeUtil {
valueHints("org.springframework.core.io.Resource", new ResourceHintProvider());
}
public SourceLinks getSourceLinks() {
return sourceLinks;
}
/**
* Determine properties that are setable on object of given type.
* <p>
@@ -695,7 +699,6 @@ public class TypeUtil {
//TODO: handle type parameters.
if (typeFromIndex != null) {
SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks((BootJavaLanguageServerComponents)null);
IJavaProject project = getJavaProject();
ArrayList<TypedProperty> properties = new ArrayList<>();
getGetterMethods(typeFromIndex).forEach(m -> {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -11,9 +11,10 @@
package org.springframework.ide.vscode.boot.metadata.types;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.commons.util.text.IDocument;
@FunctionalInterface
public interface TypeUtilProvider {
TypeUtil getTypeUtil(IDocument doc);
TypeUtil getTypeUtil(SourceLinks sourceLinks, IDocument doc);
}

View File

@@ -15,6 +15,7 @@ import java.util.Set;
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
import org.springframework.ide.vscode.boot.properties.completions.SpringPropertiesCompletionEngine;
@@ -80,7 +81,7 @@ public class BootPropertiesLanguageServerComponents implements LanguageServerCom
private SpringPropertiesReconcileEngine propertiesReconciler;
private ApplicationYamlReconcileEngine ymlReconciler;
private SourceLinks sourceLinks;
public BootPropertiesLanguageServerComponents(
SimpleLanguageServer server,
@@ -88,7 +89,8 @@ public class BootPropertiesLanguageServerComponents implements LanguageServerCom
JavaElementLocationProvider javaElementLocationProvider,
YamlASTProvider parser,
YamlStructureProvider yamlStructureProvider,
YamlAssistContextProvider yamlAssistContextProvider) {
YamlAssistContextProvider yamlAssistContextProvider,
SourceLinks sourceLinks) {
this.server = server;
this.parser = parser;
this.indexProvider = serverParams.indexProvider;
@@ -97,15 +99,16 @@ public class BootPropertiesLanguageServerComponents implements LanguageServerCom
this.projectObserver = serverParams.projectObserver;
this.yamlStructureProvider = yamlStructureProvider;
this.yamlAssistContextProvider = yamlAssistContextProvider;
this.sourceLinks = sourceLinks;
server.getClientCapabilities().thenAccept(clientCapabilities -> {
CommonQuickfixes commonQuickfixes = new CommonQuickfixes(server.getQuickfixRegistry(), javaProjectFinder,
clientCapabilities);
this.propertiesReconciler = new SpringPropertiesReconcileEngine(indexProvider,
typeUtilProvider, new AppPropertiesQuickFixes(server.getQuickfixRegistry(), commonQuickfixes));
typeUtilProvider, new AppPropertiesQuickFixes(server.getQuickfixRegistry(), commonQuickfixes), sourceLinks);
this.ymlReconciler = new ApplicationYamlReconcileEngine(parser, indexProvider, typeUtilProvider,
new AppYamlQuickfixes(server.getQuickfixRegistry(), server.getTextDocumentService(),
yamlStructureProvider, commonQuickfixes));
yamlStructureProvider, commonQuickfixes), sourceLinks);
});
indexProvider.onChange(() -> {
@@ -125,7 +128,7 @@ public class BootPropertiesLanguageServerComponents implements LanguageServerCom
@Override
public ICompletionEngine getCompletionEngine() {
ICompletionEngine propertiesCompletions = new SpringPropertiesCompletionEngine(indexProvider, typeUtilProvider, javaProjectFinder);
ICompletionEngine propertiesCompletions = new SpringPropertiesCompletionEngine(indexProvider, typeUtilProvider, javaProjectFinder, sourceLinks);
ICompletionEngine yamlCompletions = new YamlCompletionEngine(yamlStructureProvider, yamlAssistContextProvider, COMPLETION_OPTIONS);
return (TextDocument document, int offset) -> {
String uri = document.getUri();
@@ -142,7 +145,7 @@ public class BootPropertiesLanguageServerComponents implements LanguageServerCom
@Override
public HoverHandler getHoverProvider() {
HoverInfoProvider propertiesHovers = new PropertiesHoverInfoProvider(indexProvider, typeUtilProvider, javaProjectFinder);
HoverInfoProvider propertiesHovers = new PropertiesHoverInfoProvider(indexProvider, typeUtilProvider, javaProjectFinder, sourceLinks);
HoverInfoProvider ymlHovers = new YamlHoverInfoProvider(parser, yamlStructureProvider, yamlAssistContextProvider);
HoverInfoProvider combined = (IDocument document, int offset) -> {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -14,6 +14,7 @@ package org.springframework.ide.vscode.boot.properties.completions;
import java.util.Collection;
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine;
@@ -32,15 +33,17 @@ public class SpringPropertiesCompletionEngine implements ICompletionEngine {
private SpringPropertyIndexProvider indexProvider;
private TypeUtilProvider typeUtilProvider;
private PropertyCompletionFactory completionFactory = null;
private SourceLinks sourceLinks;
/**
* Constructor used in 'production'. Wires up stuff properly for running inside a normal
* Eclipse runtime.
*/
public SpringPropertiesCompletionEngine(SpringPropertyIndexProvider indexProvider, TypeUtilProvider typeUtilProvider, JavaProjectFinder projectFinder) {
public SpringPropertiesCompletionEngine(SpringPropertyIndexProvider indexProvider, TypeUtilProvider typeUtilProvider, JavaProjectFinder projectFinder, SourceLinks sourceLinks) {
this.indexProvider = indexProvider;
this.typeUtilProvider = typeUtilProvider;
this.completionFactory = new PropertyCompletionFactory();
this.sourceLinks = sourceLinks;
}
/**
@@ -49,7 +52,7 @@ public class SpringPropertiesCompletionEngine implements ICompletionEngine {
@Override
public Collection<ICompletionProposal> getCompletions(TextDocument doc, int offset) throws BadLocationException {
return new PropertiesCompletionProposalsCalculator(indexProvider.getIndex(doc),
typeUtilProvider.getTypeUtil(doc), completionFactory, doc, offset, preferLowerCaseEnums).calculate();
typeUtilProvider.getTypeUtil(sourceLinks, doc), completionFactory, doc, offset, preferLowerCaseEnums).calculate();
}
public boolean getPreferLowerCaseEnums() {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -11,12 +11,9 @@
package org.springframework.ide.vscode.boot.properties.hover;
import java.util.Optional;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
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.hover.HoverInfoProvider;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.util.Renderable;
@@ -26,20 +23,22 @@ import org.springframework.ide.vscode.commons.util.text.IRegion;
import reactor.util.function.Tuple2;
public class PropertiesHoverInfoProvider implements HoverInfoProvider {
private SpringPropertyIndexProvider indexProvider;
private TypeUtilProvider typeUtilProvider;
private JavaProjectFinder projectFinder;
public PropertiesHoverInfoProvider(SpringPropertyIndexProvider indexProvider, TypeUtilProvider typeUtilProvider, JavaProjectFinder projectFinder) {
private SourceLinks sourceLinks;
public PropertiesHoverInfoProvider(SpringPropertyIndexProvider indexProvider, TypeUtilProvider typeUtilProvider, JavaProjectFinder projectFinder, SourceLinks sourceLinks) {
this.indexProvider = indexProvider;
this.typeUtilProvider = typeUtilProvider;
this.projectFinder = projectFinder;
this.sourceLinks = sourceLinks;
}
@Override
public Tuple2<Renderable, IRegion> getHoverInfo(IDocument document, int offset) throws Exception {
return new PropertiesHoverCalculator(indexProvider.getIndex(document),
typeUtilProvider.getTypeUtil(document), document, offset).calculate();
typeUtilProvider.getTypeUtil(sourceLinks, document), document, offset).calculate();
}
}

View File

@@ -21,6 +21,7 @@ import java.util.regex.Pattern;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndex;
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
@@ -78,11 +79,13 @@ public class SpringPropertiesReconcileEngine implements IReconcileEngine {
private TypeUtilProvider typeUtilProvider;
private Parser parser = new AntlrParser();
private AppPropertiesQuickFixes quickFixes;
private SourceLinks sourceLinks;
public SpringPropertiesReconcileEngine(SpringPropertyIndexProvider provider, TypeUtilProvider typeUtilProvider, AppPropertiesQuickFixes quickFixes) {
public SpringPropertiesReconcileEngine(SpringPropertyIndexProvider provider, TypeUtilProvider typeUtilProvider, AppPropertiesQuickFixes quickFixes, SourceLinks sourceLinks) {
this.fIndexProvider = provider;
this.typeUtilProvider = typeUtilProvider;
this.quickFixes = quickFixes;
this.sourceLinks = sourceLinks;
}
@Override
@@ -119,7 +122,7 @@ public class SpringPropertiesReconcileEngine implements IReconcileEngine {
problemCollector.accept(problemDeprecated(propertyNameRegion, validProperty, quickFixes.DEPRECATED_PROPERTY));
}
int offset = validProperty.getId().length() + propertyNameRegion.getStart();
PropertyNavigator navigator = new PropertyNavigator(doc, problemCollector, typeUtilProvider.getTypeUtil(doc), propertyNameRegion);
PropertyNavigator navigator = new PropertyNavigator(doc, problemCollector, typeUtilProvider.getTypeUtil(sourceLinks, doc), propertyNameRegion);
Type valueType = navigator.navigate(offset, TypeParser.parse(validProperty.getType()));
if (valueType!=null) {
reconcileType(doc, valueType, pair.getValue(), problemCollector);
@@ -207,7 +210,7 @@ public class SpringPropertiesReconcileEngine implements IReconcileEngine {
}
private void reconcileType(DocumentRegion escapedValue, Type expectType, IProblemCollector problems) {
TypeUtil typeUtil = typeUtilProvider.getTypeUtil(escapedValue.getDocument());
TypeUtil typeUtil = typeUtilProvider.getTypeUtil(sourceLinks, escapedValue.getDocument());
ValueParser parser = typeUtil.getValueParser(expectType);
if (parser!=null) {
try {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2018 Pivotal, Inc.
* Copyright (c) 2015, 2019 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
@@ -613,7 +613,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon
if (jes != null) {
for (IJavaElement je : jes) {
if (je instanceof IMember) {
SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks((BootJavaLanguageServerComponents)null);
SourceLinks sourceLinks = typeUtil.getSourceLinks();
IJavaProject project = typeUtil.getJavaProject();
return PropertyDocUtils.documentJavaElement(sourceLinks, project, je);
}

View File

@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.yaml.reconcile;
import static org.springframework.ide.vscode.boot.yaml.reconcile.ApplicationYamlProblems.Type.YAML_SYNTAX_ERROR;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.metadata.IndexNavigator;
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
@@ -30,12 +31,14 @@ public class ApplicationYamlReconcileEngine extends YamlReconcileEngine {
private SpringPropertyIndexProvider indexProvider;
private TypeUtilProvider typeUtilProvider;
private AppYamlQuickfixes quickFixes;
private SourceLinks sourceLinks;
public ApplicationYamlReconcileEngine(YamlASTProvider astProvider, SpringPropertyIndexProvider indexProvider, TypeUtilProvider typeUtilProvider, AppYamlQuickfixes quickFixes) {
public ApplicationYamlReconcileEngine(YamlASTProvider astProvider, SpringPropertyIndexProvider indexProvider, TypeUtilProvider typeUtilProvider, AppYamlQuickfixes quickFixes, SourceLinks sourceLinks) {
super(astProvider);
this.indexProvider = indexProvider;
this.typeUtilProvider = typeUtilProvider;
this.quickFixes = quickFixes;
this.sourceLinks = sourceLinks;
}
@Override
@@ -43,7 +46,7 @@ public class ApplicationYamlReconcileEngine extends YamlReconcileEngine {
FuzzyMap<PropertyInfo> index = indexProvider.getIndex(doc);
if (index!=null && !index.isEmpty()) {
IndexNavigator nav = IndexNavigator.with(index);
return new ApplicationYamlASTReconciler(problemCollector, nav, typeUtilProvider.getTypeUtil(doc), quickFixes);
return new ApplicationYamlASTReconciler(problemCollector, nav, typeUtilProvider.getTypeUtil(sourceLinks, doc), quickFixes);
}
return null;
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -59,7 +59,7 @@ public class PropertyEditorTestConf {
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, PropertyIndexHarness indexHarness) {
JavaProjectFinder projectFinder = indexHarness.getProjectFinder();
TypeUtilProvider typeUtilProvider = (IDocument doc) -> new TypeUtil(projectFinder.find(new TextDocumentIdentifier(doc.getUri())));
TypeUtilProvider typeUtilProvider = (SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, projectFinder.find(new TextDocumentIdentifier(doc.getUri())));
return new BootLanguageServerParams(
projectFinder,

View File

@@ -39,6 +39,8 @@ import org.springframework.ide.vscode.languageserver.testharness.Editor;
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
import com.google.common.collect.ImmutableList;
public abstract class AbstractPropsEditorTest {
public static final String INTEGER = Integer.class.getName();
@@ -61,6 +63,11 @@ public abstract class AbstractPropsEditorTest {
public Optional<IJavaProject> find(TextDocumentIdentifier doc) {
return Optional.ofNullable(getTestProject());
}
@Override
public Collection<? extends IJavaProject> all() {
return getTestProject() == null ? ImmutableList.of() : ImmutableList.of(getTestProject());
}
}));
abstract public Editor newEditor(String contents) throws Exception;

View File

@@ -10,11 +10,15 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.editor.harness;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.gradle.internal.impldep.com.google.common.collect.ImmutableList;
import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty;
import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation;
import org.springframework.ide.vscode.boot.configurationmetadata.ValueHint;
@@ -574,7 +578,19 @@ public class PropertyIndexHarness {
}
public JavaProjectFinder getProjectFinder() {
return (doc) -> Optional.ofNullable(testProject);
return new JavaProjectFinder() {
@Override
public Optional<IJavaProject> find(TextDocumentIdentifier doc) {
return Optional.ofNullable(testProject);
}
@Override
public Collection<? extends IJavaProject> all() {
// TODO Auto-generated method stub
return testProject == null ? Collections.emptyList() : ImmutableList.of(testProject);
}
};
}
public IJavaProject getTestProject() {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 Pivotal, Inc.
* Copyright (c) 2017, 2019 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
@@ -163,6 +163,59 @@ public class ComponentInjectionsHoverProviderTest {
);
}
@Test
public void componentWithOneCGILibInjection() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()
.add(LiveBean.builder()
.id("fooImplementation")
.type("com.example.FooImplementation$$EnhancerBySpringCGLIB$$Blah")
.build()
)
.add(LiveBean.builder()
.id("myController")
.type("com.example.MyController$$EnhancerBySpringCGLIB$$Blah")
.dependencies("fooImplementation")
.build()
)
.add(LiveBean.builder()
.id("irrelevantBean")
.type("com.example.IrrelevantBean$$EnhancerBySpringCGLIB$$Blah")
.dependencies("myController")
.build()
)
.build();
mockAppProvider.builder()
.isSpringBootApp(true)
.processId("111")
.processName("the-app")
.beans(beans)
.build();
Editor editor = harness.newEditor(LanguageId.JAVA,
"package com.example;\n" +
"\n" +
"import org.springframework.stereotype.Component;\n" +
"\n" +
"@Component\n" +
"public class FooImplementation implements Foo {\n" +
"\n" +
" @Override\n" +
" public void doSomeFoo() {\n" +
" System.out.println(\"Foo do do do!\");\n" +
" }\n" +
"}\n"
);
editor.assertHighlights("@Component");
editor.assertTrimmedHover("@Component",
"**&#8594; `MyController`**\n" +
"- Bean: `myController` \n" +
" Type: `com.example.MyController`\n" +
" \n" +
"Bean id: `fooImplementation` \n" +
"Process [PID=111, name=`the-app`]\n"
);
}
@Test
public void componentWithMultipleInjections() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -56,7 +56,7 @@ public class VSCodeSourceLinksTest {
@Test
public void testJavaSourceUrl() throws Exception {
MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
Optional<String> url = new VSCodeSourceLinks(new CompilationUnitCache(null, null, null)).sourceLinkUrlForFQName(project, "com.example.EmptyBoot15WebAppApplication");
Optional<String> url = new VSCodeSourceLinks(new CompilationUnitCache(null, null, null), null).sourceLinkUrlForFQName(project, "com.example.EmptyBoot15WebAppApplication");
assertTrue(url.isPresent());
Path projectPath = Paths.get(project.pom().getParent());
URI uri = URI.create(url.get());
@@ -73,7 +73,7 @@ public class VSCodeSourceLinksTest {
@Test
public void testJarUrl() throws Exception {
MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
Optional<String> url = new VSCodeSourceLinks(new CompilationUnitCache(null, null, null)).sourceLinkUrlForFQName(project, "org.springframework.boot.autoconfigure.SpringBootApplication");
Optional<String> url = new VSCodeSourceLinks(new CompilationUnitCache(null, null, null), null).sourceLinkUrlForFQName(project, "org.springframework.boot.autoconfigure.SpringBootApplication");
assertTrue(url.isPresent());
String headerPart = url.get().substring(0, url.get().indexOf('?'));
assertEquals("jdt://contents/spring-boot-autoconfigure-1.5.8.RELEASE.jar/org.springframework.boot.autoconfigure/SpringBootApplication.class", headerPart);
@@ -84,7 +84,7 @@ public class VSCodeSourceLinksTest {
@Test
public void testJarUrlInnerType() throws Exception {
MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
Optional<String> url = new VSCodeSourceLinks(new CompilationUnitCache(null, null, null)).sourceLinkUrlForFQName(project, "org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback");
Optional<String> url = new VSCodeSourceLinks(new CompilationUnitCache(null, null, null), null).sourceLinkUrlForFQName(project, "org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback");
assertTrue(url.isPresent());
String headerPart = url.get().substring(0, url.get().indexOf('?'));
assertEquals("jdt://contents/spring-web-4.3.12.RELEASE.jar/org.springframework.web.client/RestTemplate$AcceptHeaderRequestCallback.class", headerPart);

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -63,6 +63,11 @@ public class MockProjects {
return Optional.empty();
}
}
@Override
public Collection<? extends IJavaProject> all() {
return projectsByName.values();
}
};
public MockFileObserver fileObserver = new MockFileObserver();

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* Copyright (c) 2017, 2019 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
@@ -14,12 +14,16 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.apache.commons.io.IOUtils;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.xtend.lib.annotations.Accessors;
import org.gradle.internal.impldep.com.google.common.collect.ImmutableList;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -86,7 +90,19 @@ public class ValueCompletionTest {
}
@Bean JavaProjectFinder projectFinder(MavenJavaProject testProject) {
return (doc) -> Optional.of(testProject);
return new JavaProjectFinder() {
@Override
public Optional<IJavaProject> find(TextDocumentIdentifier doc) {
return Optional.ofNullable(testProject);
}
@Override
public Collection<? extends IJavaProject> all() {
// TODO Auto-generated method stub
return testProject == null ? Collections.emptyList() : ImmutableList.of(testProject);
}
};
}
@Bean BootLanguageServerHarness harness(SimpleLanguageServer server, BootLanguageServerParams serverParams, PropertyIndexHarness indexHarness, JavaProjectFinder projectFinder) throws Exception {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* Copyright (c) 2017, 2019 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
@@ -121,7 +121,7 @@ public class LoggerNameProviderTest {
}
private LoggerNameProvider create() {
return (LoggerNameProvider) LoggerNameProvider.factory(null).apply(ImmutableMap.of());
return (LoggerNameProvider) LoggerNameProvider.factory(null, null).apply(ImmutableMap.of());
}
private void assertElementsAtLeast(List<String> results, String[] expecteds) {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Pivotal, Inc.
* Copyright (c) 2015, 2019 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
@@ -29,17 +29,17 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
/**
* Tests for TypeUtil
*
*
* @author Kris De Volder
* @author Alex Boyko
* @author Alex Boyko
*
*/
public class TypeUtilTest {
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
private IJavaProject project;
private TypeUtil typeUtil;
private Type getPropertyType(Type type, String propName, EnumCaseMode enumMode, BeanPropertyNameMode beanMode) {
List<TypedProperty> props = getProperties(type, enumMode, beanMode);
assertNotNull(props);
@@ -139,7 +139,7 @@ public class TypeUtilTest {
private void useProject(String name) throws Exception {
project = projects.mavenProject(name);;
typeUtil = new TypeUtil(project);
typeUtil = new TypeUtil(null, project);
}
}