PT #164216122: JDT LS search performance improvement 1
This commit is contained in:
@@ -22,6 +22,7 @@ import org.springframework.ide.vscode.boot.metadata.hints.StsValueHint;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMatcher;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
|
||||
@@ -84,8 +85,8 @@ public class LoggerNameProvider extends CachingValueProvider {
|
||||
.fuzzySearchPackages(query, true, false)
|
||||
.map(t -> Tuples.of(StsValueHint.create(t.getT1()), t.getT2())),
|
||||
javaProject.getIndex()
|
||||
.fuzzySearchTypes(query, true, false, null)
|
||||
.map(t -> Tuples.of(StsValueHint.create(sourceLinks, javaProject, t.getT1()), t.getT2()))
|
||||
.fuzzySearchTypes(query, true, false)
|
||||
.map(t -> Tuples.of(StsValueHint.create(sourceLinks, t.getT1(), javaProject, Suppliers.memoize(() -> javaProject.getIndex().findType(t.getT1()))), t.getT2()))
|
||||
)
|
||||
.collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2()))
|
||||
.flatMapIterable(l -> l)
|
||||
|
||||
@@ -27,6 +27,9 @@ import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.util.Renderables;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
|
||||
/**
|
||||
* Sts version of {@link ValueHint} contains similar data, but accomoates
|
||||
* a html snippet to be computed lazyly for the description.
|
||||
@@ -43,7 +46,7 @@ public class StsValueHint {
|
||||
|
||||
private final String value;
|
||||
private final Renderable description;
|
||||
private final Deprecation deprecation;
|
||||
private final Supplier<Deprecation> deprecation;
|
||||
|
||||
/**
|
||||
* Create a hint with a textual description.
|
||||
@@ -51,7 +54,7 @@ public class StsValueHint {
|
||||
* This constructor is private. Use one of the provided
|
||||
* static 'create' methods instead.
|
||||
*/
|
||||
private StsValueHint(String value, Renderable description, Deprecation deprecation) {
|
||||
private StsValueHint(String value, Renderable description, Supplier<Deprecation> deprecation) {
|
||||
this.value = value==null?"null":value.toString();
|
||||
Assert.isLegal(!this.value.startsWith("StsValueHint"));
|
||||
this.description = description;
|
||||
@@ -62,7 +65,7 @@ public class StsValueHint {
|
||||
* Creates a hint out of an IJavaElement.
|
||||
*/
|
||||
public static StsValueHint create(SourceLinks sourceLinks, String value, IJavaProject project, IJavaElement javaElement) {
|
||||
return new StsValueHint(value, javaDocSnippet(sourceLinks, project, javaElement), DeprecationUtil.extract(javaElement)) {
|
||||
return new StsValueHint(value, javaDocSnippet(sourceLinks, project, () -> javaElement), () -> DeprecationUtil.extract(javaElement)) {
|
||||
@Override
|
||||
public IJavaElement getJavaElement() {
|
||||
return javaElement;
|
||||
@@ -70,6 +73,18 @@ public class StsValueHint {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a hint out of an Supplier<IJavaElement>.
|
||||
*/
|
||||
public static StsValueHint create(SourceLinks sourceLinks, String value, IJavaProject project, Supplier<IJavaElement> elementSupplier) {
|
||||
return new StsValueHint(value, javaDocSnippet(sourceLinks, project, elementSupplier), Suppliers.memoize(() -> DeprecationUtil.extract(elementSupplier.get()))) {
|
||||
@Override
|
||||
public IJavaElement getJavaElement() {
|
||||
return elementSupplier.get();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static StsValueHint create(String value) {
|
||||
return new StsValueHint(value, Renderables.NO_DESCRIPTION, null);
|
||||
}
|
||||
@@ -94,7 +109,7 @@ public class StsValueHint {
|
||||
}
|
||||
|
||||
public static StsValueHint create(SourceLinks sourceLinks, IJavaProject project, IType klass) {
|
||||
return new StsValueHint(klass.getFullyQualifiedName(), javaDocSnippet(sourceLinks, project, klass), DeprecationUtil.extract(klass)) {
|
||||
return new StsValueHint(klass.getFullyQualifiedName(), javaDocSnippet(sourceLinks, project, () -> klass), Suppliers.memoize(() -> DeprecationUtil.extract(klass))) {
|
||||
@Override
|
||||
public IJavaElement getJavaElement() {
|
||||
return klass;
|
||||
@@ -120,9 +135,9 @@ public class StsValueHint {
|
||||
return description;
|
||||
}
|
||||
|
||||
private static Renderable javaDocSnippet(SourceLinks sourceLinks, IJavaProject project, IJavaElement je) {
|
||||
private static Renderable javaDocSnippet(SourceLinks sourceLinks, IJavaProject project, Supplier<IJavaElement> je) {
|
||||
return Renderables.lazy(() -> {
|
||||
return PropertyDocUtils.documentJavaElement(sourceLinks, project, je);
|
||||
return PropertyDocUtils.documentJavaElement(sourceLinks, project, je.get());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,7 +147,7 @@ public class StsValueHint {
|
||||
}
|
||||
|
||||
public Deprecation getDeprecation() {
|
||||
return deprecation;
|
||||
return deprecation.get();
|
||||
}
|
||||
|
||||
public IJavaElement getJavaElement() {
|
||||
|
||||
@@ -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
|
||||
@@ -147,7 +147,7 @@ public class PropertiesCompletionProposalsCalculator {
|
||||
PropertyInfo prop = findLongestValidProperty(index, navPrefix);
|
||||
if (prop!=null) {
|
||||
int regionStart = navOffset-navPrefix.length();
|
||||
Collection<ICompletionProposal> hintProposals = getKeyHintProposals(prop, navOffset);
|
||||
Collection<ICompletionProposal> hintProposals = getKeyHintProposals(prop, regionStart + prop.getId().length());
|
||||
if (CollectionUtil.hasElements(hintProposals)) {
|
||||
return hintProposals;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user