JDT LS based index for searches and refactorings to replace Jandex

This commit is contained in:
BoykoAlex
2019-02-12 00:09:09 -05:00
parent 4d6634e09a
commit 2b2413ee60
158 changed files with 115097 additions and 1687 deletions

View File

@@ -40,11 +40,11 @@ import org.springframework.ide.vscode.commons.languageserver.java.CompositeProje
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.java.JavadocService;
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath.CPE;
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;
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
import org.springframework.ide.vscode.commons.util.Assert;
import org.springframework.ide.vscode.commons.util.FileObserver;
import org.springframework.ide.vscode.commons.util.text.IDocument;

View File

@@ -272,10 +272,10 @@ public class AutowiredHoverProvider implements HoverProvider {
if (liveBeanTypeFQName.replace('$', '.').equals(bindingQualifiedName)) {
return true;
} else {
IType type = jp.findType(liveBeanTypeFQName);
IType type = jp.getIndex().findType(liveBeanTypeFQName);
String fqTypeName = bindingQualifiedName;
if (type != null) {
return jp.allSuperTypesOf(type).map(IType::getFullyQualifiedName)
return jp.getIndex().allSuperTypesOf(type).map(IType::getFullyQualifiedName)
.filter(fqn -> fqTypeName.equals(fqn.replace('$', '.'))).blockFirst() != null;
}
}

View File

@@ -44,6 +44,7 @@ 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.HoverHandler;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
import org.springframework.ide.vscode.commons.util.text.IDocument;
import org.springframework.ide.vscode.commons.util.text.TextDocument;

View File

@@ -18,8 +18,8 @@ import java.util.Set;
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
import org.springframework.ide.vscode.commons.java.IClasspath;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath.CPE;
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
import org.springframework.ide.vscode.commons.util.CollectorUtil;
/**

View File

@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.commons.java.IClasspath;
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;
@@ -117,7 +118,7 @@ public abstract class AbstractSourceLinks implements SourceLinks {
}
private Optional<CompilationUnit> findCUForFQNameFromJar(IJavaProject project, IJavaModuleData jarModuleData, String fqName) {
return project.sourceContainer(jarModuleData.getContainer()).map(url -> {
return IClasspathUtil.sourceContainer(project.getClasspath(), jarModuleData.getContainer()).map(url -> {
try {
return TypeUrlProviderFromContainerUrl.JAR_SOURCE_URL_PROVIDER.url(url, fqName, jarModuleData.getModule());
} catch (Exception e) {

View File

@@ -58,12 +58,12 @@ public class EclipseSourceLinks implements SourceLinks {
}
private Optional<IJavaProject> findProjectForFQName(IJavaProject project, String fqName) {
if (project != null && project.findType(fqName) != null) {
if (project != null && project.getIndex().findType(fqName) != null) {
return Optional.of(project);
} else {
for (IJavaProject jp : projectFinder.all()) {
if (jp != project) {
if (jp.findType(fqName) != null) {
if (jp.getIndex().findType(fqName) != null) {
return Optional.of(jp);
}
}
@@ -103,7 +103,7 @@ public class EclipseSourceLinks implements SourceLinks {
}
public static URI eclipseIntroUri(IJavaProject project, String fqName) {
IType type = project.findType(fqName);
IType type = project.getIndex().findType(fqName);
return type == null ? null : eclipseIntroUri(project, type);
}

View File

@@ -19,8 +19,8 @@ import org.slf4j.Logger;
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.languageserver.java.ls.JavaDataParams;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
import org.springframework.ide.vscode.commons.protocol.java.JavaDataParams;
public class JavaServerElementLocationProvider implements JavaElementLocationProvider {

View File

@@ -19,8 +19,8 @@ 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;
import org.springframework.ide.vscode.commons.protocol.java.JavaDataParams;
public class JavaServerSourceLinks implements SourceLinks {
@@ -40,7 +40,7 @@ public class JavaServerSourceLinks implements SourceLinks {
bindingKey.append(';');
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()));
.thenApply(l -> Optional.ofNullable(l));
try {
return link.get(10, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {

View File

@@ -31,8 +31,8 @@ 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;
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
/**
* Instance is able to provide client specific URL links to navigate to a
@@ -84,9 +84,9 @@ public interface SourceLinks {
public static Optional<URL> source(IJavaProject project, String fqName) {
// Try to find in a source JAR
IJavaModuleData classpathResourceContainer = project.findClasspathResourceContainer(fqName);
IJavaModuleData classpathResourceContainer = project.getIndex().findClasspathResourceContainer(fqName);
if (classpathResourceContainer != null) {
Optional<URL> url = project.sourceContainer(classpathResourceContainer.getContainer()).map(file -> {
Optional<URL> url = IClasspathUtil.sourceContainer(project.getClasspath(), classpathResourceContainer.getContainer()).map(file -> {
try {
return TypeUrlProviderFromContainerUrl.JAR_SOURCE_URL_PROVIDER.url(file, fqName, classpathResourceContainer.getModule());
} catch (Exception e) {

View File

@@ -31,10 +31,10 @@ import org.springframework.ide.vscode.boot.java.handlers.RunningAppMatcher;
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.HighlightParams;
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.SimpleLanguageServer;
import org.springframework.ide.vscode.commons.protocol.HighlightParams;
import org.springframework.ide.vscode.commons.util.MemoizingProxy;
import org.springframework.ide.vscode.commons.util.text.TextDocument;

View File

@@ -21,8 +21,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.java.IJavadocProvider;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath.CPE;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
import org.springframework.ide.vscode.commons.util.Assert;
import com.google.common.base.Supplier;

View File

@@ -29,10 +29,11 @@ import org.springframework.ide.vscode.commons.java.ClasspathData;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.java.IJavadocProvider;
import org.springframework.ide.vscode.commons.java.JavaProject;
import org.springframework.ide.vscode.commons.java.JdtLsJavaProject;
import org.springframework.ide.vscode.commons.javadoc.JdtLsJavadocProvider;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath.CPE;
import org.springframework.ide.vscode.commons.languageserver.java.ls.ClasspathListener;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
import org.springframework.ide.vscode.commons.util.FileObserver;
import org.springframework.ide.vscode.commons.util.UriUtil;
@@ -42,8 +43,10 @@ import reactor.core.publisher.Mono;
public class JdtLsProjectCache implements InitializableJavaProjectsService {
private static final boolean IS_JANDEX_INDEX = Boolean.getBoolean("sts.lsp.jandex.index");
private SimpleLanguageServer server;
private Map<String, JavaProject> table = new HashMap<String, JavaProject>();
private Map<String, IJavaProject> table = new HashMap<String, IJavaProject>();
private Logger log = LoggerFactory.getLogger(JdtLsProjectCache.class);
private List<Listener> listeners = new ArrayList<>();
@@ -79,7 +82,7 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
}
}
private void notifyCreated(JavaProject newProject) {
private void notifyCreated(IJavaProject newProject) {
logEvent("Created", newProject);
synchronized (listeners) {
@@ -96,17 +99,19 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
}
}
private void notifyDelete(JavaProject deleted) {
private void notifyDelete(IJavaProject deleted) {
logEvent("Deleted", deleted);
synchronized (listeners) {
for (Listener listener : listeners) {
listener.deleted(deleted);
}
}
deleted.dispose();
if (deleted instanceof Disposable) {
((Disposable)deleted).dispose();
}
}
private void notifyChanged(JavaProject newProject) {
private void notifyChanged(IJavaProject newProject) {
logEvent("Changed", newProject);
synchronized (listeners) {
for (Listener listener : listeners) {
@@ -115,7 +120,7 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
}
}
private void logEvent(String type, JavaProject project) {
private void logEvent(String type, IJavaProject project) {
try {
log.info("Project "+type+": " + project.getLocationUri());
log.info("Classpath has "+project.getClasspath().getClasspathEntries().size()+" entries "
@@ -147,7 +152,7 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
synchronized (table) {
String foundUri = null;
IJavaProject foundProject = null;
for (Entry<String, JavaProject> e : table.entrySet()) {
for (Entry<String, IJavaProject> e : table.entrySet()) {
String projectUri = e.getKey();
log.debug("projectUri = '{}'", projectUri);
if (UriUtil.contains(projectUri, uri)) {
@@ -187,7 +192,7 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
log.debug("uri = {}", uri);
if (event.deleted) {
log.debug("event.deleted = true");
JavaProject deleted = table.remove(uri);
IJavaProject deleted = table.remove(uri);
if (deleted!=null) {
log.debug("removed from table = true");
notifyDelete(deleted);
@@ -196,8 +201,13 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
}
} else {
log.debug("deleted = false");
JavaProject newProject = new JavaProject(getFileObserver(), new URI(uri), new ClasspathData(event.name, event.classpath.getEntries()), JdtLsProjectCache.this);
JavaProject oldProject = table.put(uri, newProject);
URI projectUri = new URI(uri);
ClasspathData classpath = new ClasspathData(event.name, event.classpath.getEntries());
IJavaProject newProject = IS_JANDEX_INDEX
? new JavaProject(getFileObserver(), projectUri, classpath,
JdtLsProjectCache.this)
: new JdtLsJavaProject(server.getClient(), projectUri, classpath);
IJavaProject oldProject = table.put(uri, newProject);
if (oldProject != null) {
notifyChanged(newProject);
} else {

View File

@@ -135,11 +135,11 @@ public class ClassReferenceProvider extends CachingValueProvider {
@Override
protected Flux<StsValueHint> getValuesAsync(IJavaProject javaProject, String query) {
IType targetType = target == null || target.isEmpty() ? javaProject.findType("java.lang.Object") : javaProject.findType(target);
IType targetType = target == null || target.isEmpty() ? javaProject.getIndex().findType("java.lang.Object") : javaProject.getIndex().findType(target);
if (targetType == null) {
return Flux.empty();
}
Set<IType> allSubclasses = javaProject
Set<IType> allSubclasses = javaProject.getIndex()
.allSubtypesOf(targetType)
.filter(t -> Flags.isPublic(t.getFlags()) && !concrete || !isAbstract(t))
.collect(Collectors.toSet())
@@ -147,8 +147,8 @@ public class ClassReferenceProvider extends CachingValueProvider {
if (allSubclasses.isEmpty()) {
return Flux.empty();
} else {
return javaProject
.fuzzySearchTypes(query, type -> allSubclasses.contains(type))
return javaProject.getIndex()
.fuzzySearchTypes(query, true, false, type -> allSubclasses.contains(type))
.collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2()))
.flatMapIterable(l -> l)
.map(t -> StsValueHint.create(sourceLinks, javaProject, t.getT1()));

View File

@@ -81,10 +81,10 @@ public class LoggerNameProvider extends CachingValueProvider {
.map(loggerName -> Tuples.of(StsValueHint.create(loggerName), FuzzyMatcher.matchScore(query, loggerName)))
.filter(t -> t.getT2()!=0.0),
javaProject.getIndex()
.fuzzySearchPackages(query)
.fuzzySearchPackages(query, true, false)
.map(t -> Tuples.of(StsValueHint.create(t.getT1()), t.getT2())),
javaProject.getIndex()
.fuzzySearchTypes(query, null)
.fuzzySearchTypes(query, true, false, null)
.map(t -> Tuples.of(StsValueHint.create(sourceLinks, javaProject, t.getT1()), t.getT2()))
)
.collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2()))

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
@@ -16,6 +16,7 @@ import java.util.stream.Collectors;
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.IClasspathUtil;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import com.google.common.collect.ImmutableList;
@@ -64,7 +65,7 @@ public class ResourceHintProvider implements ValueProviderStrategy {
@Override
protected Flux<StsValueHint> getValuesAsync(IJavaProject javaProject, String query) {
return Flux.fromStream(
javaProject.getClasspathResources().stream()
IClasspathUtil.getClasspathResources(javaProject.getClasspath()).stream()
.distinct().map(r -> r.replaceAll("\\\\", "/"))
.map(StsValueHint::create)
);

View File

@@ -82,7 +82,7 @@ public class StsValueHint {
try {
IJavaProject jp = typeUtil.getJavaProject();
if (jp!=null) {
IType type = jp.findType(fqName);
IType type = jp.getIndex().findType(fqName);
if (type!=null) {
return create(typeUtil.getSourceLinks(), jp, type);
}

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
@@ -123,7 +123,7 @@ public class Type implements YType {
// }
// return null;
// }
public static Type fromJavaType(IJavaType javaType) {
if (javaType instanceof IPrimitiveType || javaType instanceof IVoidType) {
Type type = TYPE_FROM_SIG.get(javaType.name());
@@ -131,11 +131,12 @@ public class Type implements YType {
return type;
}
} else if (javaType instanceof IClassType) {
return new Type(javaType.name(), null);
return new Type(((IClassType)javaType).getFQName(), null);
} else if (javaType instanceof IParameterizedType) {
IParameterizedType parameterizedType = (IParameterizedType) javaType;
List<Type> arguments = parameterizedType.arguments().map(Type::fromJavaType).collect(Collectors.toList());
return new Type(parameterizedType.name(), arguments.toArray(new Type[arguments.size()]));
Type owner = fromJavaType(parameterizedType.owner());
return new Type(owner.getErasure(), arguments.toArray(new Type[arguments.size()]));
} else if (javaType instanceof IArrayType) {
IArrayType arrayType = (IArrayType) javaType;
Type elementType = fromJavaType(arrayType.component());
@@ -143,10 +144,10 @@ public class Type implements YType {
return elementType.asArray(arrayType.dimensions());
}
}
return null;
}
public Type asArray(int arrayCount) {
Assert.isLegal(arrayCount>0);
StringBuilder arrayErasure = new StringBuilder(erasure);
@@ -205,7 +206,7 @@ public class Type implements YType {
private static void sig2type(String sig, Class<?> cls) {
TYPE_FROM_SIG.put(sig, TypeParser.parse(cls.getName()));
}
@Override
public int hashCode() {
final int prime = 31;

View File

@@ -587,7 +587,7 @@ public class TypeUtil {
* has '.' as the separator. Replace '.' with '$' to find inner type
*/
String fqName = switchInnerTypeSeparator(typeName);
return javaProject.findType(fqName);
return javaProject.getIndex().findType(fqName);
}
} catch (Exception e) {
log.error("", e);

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 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
@@ -42,7 +42,7 @@ public class DeprecationUtil {
* Extract {@link Deprecation} info from annotations on a {@link IJavaElement}
*/
private static Optional<Deprecation> extract(IAnnotatable m) {
return m.getAnnotations().filter(a -> DEPRECATED_ANOT_NAMES.contains(a.getElementName())).map(a -> {
return m.getAnnotations().filter(a -> DEPRECATED_ANOT_NAMES.contains(a.fqName())).map(a -> {
Deprecation d = new Deprecation();
a.getMemberValuePairs().forEach(pair -> {
String name = pair.getMemberName();

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
@@ -67,7 +67,7 @@ public class PropertiesDefinitionCalculator {
for (PropertySource source : sources) {
String typeName = source.getSourceType();
if (typeName!=null) {
IType type = project.findType(typeName);
IType type = project.getIndex().findType(typeName);
IMethod method = null;
if (type!=null) {
String methodSig = source.getSourceMethod();
@@ -198,7 +198,7 @@ public class PropertiesDefinitionCalculator {
}
private static List<Location> getEnumValueDefinitionLocation(JavaElementLocationProvider javaElementLocationProvider, IJavaProject project, Type type, String value) {
IType javaType = project.findType(type.getErasure());
IType javaType = project.getIndex().findType(type.getErasure());
if (javaType != null) {
IField field = getEnumField(javaType, value);
if (field != null) {
@@ -212,7 +212,7 @@ public class PropertiesDefinitionCalculator {
}
private static List<Location> getClassValueDefinitionLocation(JavaElementLocationProvider javaElementLocationProvider, IJavaProject project, String value) {
IType javaType = project.findType(value);
IType javaType = project.getIndex().findType(value);
if (javaType != null) {
Location location = javaElementLocationProvider.findLocation(project, javaType);
if (location != null) {

View File

@@ -16,9 +16,9 @@ import org.eclipse.lsp4j.WorkspaceEdit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit.CursorMovement;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixRegistry;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixType;
import org.springframework.ide.vscode.commons.protocol.CursorMovement;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

View File

@@ -406,7 +406,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon
String keyValue = contextPath.getLastSegment().toPropString();
return PropertiesDefinitionCalculator.getValueDefinitionLocations(javaElementLocationProvider, typeUtil, keyType, keyValue);
} else {
IType javaType = javaProject.findType(parentType.getErasure());
IType javaType = javaProject.getIndex().findType(parentType.getErasure());
if (javaType != null) {
IMethod method = PropertiesDefinitionCalculator.getPropertyMethod(javaType, propName);
if (method != null) {

View File

@@ -17,10 +17,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.properties.quickfix.CommonQuickfixes;
import org.springframework.ide.vscode.boot.properties.quickfix.DeprecatedPropertyData;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit.CursorMovement;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixRegistry;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixType;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
import org.springframework.ide.vscode.commons.protocol.CursorMovement;
import org.springframework.ide.vscode.commons.util.text.TextDocument;
import org.springframework.ide.vscode.commons.yaml.completion.YamlPathEdits;
import org.springframework.ide.vscode.commons.yaml.path.YamlPath;

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
@@ -142,7 +142,7 @@ public class AutowiredHoverProviderTest {
@Before
public void setup() throws Exception {
MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", FOO_INTERFACE);
assertTrue(jp.findType("com.example.Foo").exists());
assertTrue(jp.getIndex().findType("com.example.Foo").exists());
harness.useProject(jp);
harness.intialize(null);
}

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
@@ -82,7 +82,7 @@ public class BeanInjectedIntoHoverProviderTest {
@Before
public void setup() throws Exception {
MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", FOO_INTERFACE);
assertTrue(jp.findType("hello.Foo").exists());
assertTrue(jp.getIndex().findType("hello.Foo").exists());
harness.useProject(jp);
harness.intialize(null);
}

View File

@@ -68,7 +68,7 @@ public class ComponentInjectionsHoverProviderTest {
@Before
public void setup() throws Exception {
MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", EXTRA_TYPES);
assertTrue(jp.findType("com.example.Foo").exists());
assertTrue(jp.getIndex().findType("com.example.Foo").exists());
harness.useProject(jp);
harness.intialize(null);
}

View File

@@ -34,8 +34,8 @@ 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.java.ProjectObserver.Listener;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath.CPE;
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
import org.springframework.ide.vscode.commons.util.FileObserver;
import org.springframework.ide.vscode.commons.util.IOUtil;
@@ -90,7 +90,9 @@ public class MockProjects {
public Collection<CPE> getClasspathEntries() throws Exception {
List<CPE> cp = new ArrayList<>();
for (File sf : sourceFolders) {
cp.add(new CPE(Classpath.ENTRY_KIND_SOURCE, sf.getAbsolutePath()).setOutputFolder(defaultOutputFolder.getAbsolutePath()));
CPE cpe = new CPE(Classpath.ENTRY_KIND_SOURCE, sf.getAbsolutePath());
cpe.setOutputFolder(defaultOutputFolder.getAbsolutePath());
cp.add(cpe);
}
return cp;
}

View File

@@ -68,8 +68,8 @@ public class TypeUtilTest {
@Test
public void testGetProperties() throws Exception {
useProject("enums-boot-1.3.2-app");
assertNotNull(project.findType("demo.Color"));
assertNotNull(project.findType("demo.ColorData"));
assertNotNull(project.getIndex().findType("demo.Color"));
assertNotNull(project.getIndex().findType("demo.ColorData"));
Type data = TypeParser.parse("demo.ColorData");

View File

@@ -267,7 +267,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
@Test public void testPredefinedProject() throws Exception {
IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
IType type = p.findType("demo.DemoApplication");
IType type = p.getIndex().findType("demo.DemoApplication");
assertNotNull(type);
}
@@ -340,7 +340,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
useProject(p);
assertNotNull(p.findType("demo.Foo"));
assertNotNull(p.getIndex().findType("demo.Foo"));
Editor editor = newEditor(
"token.bad.guy=problem\n"+
@@ -365,7 +365,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
useProject(p);
assertNotNull(p.findType("demo.Foo"));
assertNotNull(p.getIndex().findType("demo.Foo"));
assertCompletionsVariations("volder.foo.l<*>", "volder.foo.list[<*>");
assertCompletionsDisplayStringAndDetail("volder.foo.list[0].<*>",
@@ -514,7 +514,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.Color"));
data("foo.colors", "java.util.List<demo.Color>", null, "A foonky list");
@@ -537,7 +537,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.Color"));
data("foo.color", "demo.Color", null, "A foonky colour");
@@ -556,7 +556,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.Color"));
data("foo.color", "demo.Color", null, "A foonky colour");
Editor editor = newEditor(
@@ -579,7 +579,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.Color"));
assertCompletionsVariations("foo.nam<*>",
"foo.name-colors.<*>",
@@ -598,7 +598,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
useProject(p);
data("foo.name-colors", "java.util.Map<java.lang.String,demo.Color>", null, "Map with colors in its values");
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.Color"));
Editor editor = newEditor(
"foo.name-colors.jacket=BLUE\n" +
@@ -617,8 +617,8 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
useProject(p);
data("foo.color-names", "java.util.Map<demo.Color,java.lang.String>", null, "Map with colors in its keys");
data("foo.color-data", "java.util.Map<demo.Color,demo.ColorData>", null, "Map with colors in its keys, and pojo in values");
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.findType("demo.ColorData"));
assertNotNull(p.getIndex().findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.ColorData"));
//Map Enum -> String:
assertCompletionsVariations("foo.colnam<*>", "foo.color-names.<*>");
@@ -657,8 +657,8 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.findType("demo.ColorData"));
assertNotNull(p.getIndex().findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.ColorData"));
Editor editor = newEditor(
"foo.color-names.RED=Rood\n"+
@@ -677,8 +677,8 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.findType("demo.ColorData"));
assertNotNull(p.getIndex().findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.ColorData"));
assertCompletion("foo.dat<*>", "foo.data.<*>");
@@ -712,8 +712,8 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.findType("demo.ColorData"));
assertNotNull(p.getIndex().findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.ColorData"));
Editor editor = newEditor(
"foo.data.bogus=Something\n" +
@@ -747,8 +747,8 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.findType("demo.ColorData"));
assertNotNull(p.getIndex().findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.ColorData"));
data("atommap", "java.util.Map<java.lang.String,java.lang.Integer>", null, "map of atomic data");
data("objectmap", "java.util.Map<java.lang.String,java.lang.Object>", null, "map of atomic object (recursive map)");
@@ -787,8 +787,8 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.findType("demo.ColorData"));
assertNotNull(p.getIndex().findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.ColorData"));
Editor editor = newEditor(
"foo.color-names.BLUE.dot=Blauw\n"+
@@ -813,7 +813,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.ClothingSize"));
assertNotNull(p.getIndex().findType("demo.ClothingSize"));
data("simple.pants.size", "demo.ClothingSize", null, "The simple pant's size");
@@ -857,7 +857,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.ClothingSize"));
assertNotNull(p.getIndex().findType("demo.ClothingSize"));
data("simple.pants.size", "demo.ClothingSize", null, "The simple pant's size");
@@ -1573,7 +1573,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.Color"));
data("my.colors", collectionType+"<demo.Color>", null, "Ooh! nice colors!");

View File

@@ -809,7 +809,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
@Test public void testReconcileBeanPropName() throws Exception {
IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
useProject(p);
assertNotNull(p.findType("demo.Foo"));
assertNotNull(p.getIndex().findType("demo.Foo"));
data("some-foo", "demo.Foo", null, "some Foo pojo property");
Editor editor = newEditor(
"some-foo:\n" +
@@ -841,7 +841,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
@Test public void testReconcilePojoArray() throws Exception {
IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
useProject(p);
assertNotNull(p.findType("demo.Foo"));
assertNotNull(p.getIndex().findType("demo.Foo"));
{
Editor editor = newEditor(
@@ -918,7 +918,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
@Test public void testEnumPropertyReconciling() throws Exception {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.Color"));
assertNotNull(p.getIndex().findType("demo.Color"));
data("foo.color", "demo.Color", null, "A foonky colour");
Editor editor = newEditor(
@@ -2118,7 +2118,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
@Ignore @Test public void testEnumsInLowerCaseContentAssist() throws Exception {
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
useProject(p);
assertNotNull(p.findType("demo.ClothingSize"));
assertNotNull(p.getIndex().findType("demo.ClothingSize"));
data("simple.pants.size", "demo.ClothingSize", null, "The simple pant's size");

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
@@ -19,9 +19,9 @@ import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
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;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath;
import org.springframework.ide.vscode.commons.languageserver.java.ls.Classpath.CPE;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
import org.springframework.ide.vscode.commons.util.text.LanguageId;
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;