PT #164474609: Light TypeDescriptorData and caching super, sub-types
This commit is contained in:
@@ -242,9 +242,9 @@ public class AutowiredHoverProvider implements HoverProvider {
|
||||
// Raw collections shouldn't match any beans
|
||||
return type.getTypeArguments().length == 1 ? matchBeansByType(project, beans, type.getTypeArguments()[0].getQualifiedName(), false) : ImmutableList.of();
|
||||
} else if (type.isArray() && type.getDimensions() == 1) {
|
||||
return matchBeansByType(project, beans, type.getElementType().getErasure().getQualifiedName(), false);
|
||||
return matchBeansByType(project, beans, type.getElementType().getErasure().getBinaryName(), false);
|
||||
} else {
|
||||
return matchBeansByType(project, beans, type.getErasure().getQualifiedName(), true);
|
||||
return matchBeansByType(project, beans, type.getErasure().getBinaryName(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,16 +269,8 @@ public class AutowiredHoverProvider implements HoverProvider {
|
||||
// Trim the generic parameters part if it's present
|
||||
String liveBeanTypeFQName = idx < 0 ? rawLiveBeanFqName : rawLiveBeanFqName.substring(0, idx);
|
||||
if (liveBeanTypeFQName != null) {
|
||||
if (liveBeanTypeFQName.replace('$', '.').equals(bindingQualifiedName)) {
|
||||
return true;
|
||||
} else {
|
||||
IType type = jp.getIndex().findType(liveBeanTypeFQName);
|
||||
String fqTypeName = bindingQualifiedName;
|
||||
if (type != null) {
|
||||
return jp.getIndex().allSuperTypesOf(type).map(IType::getFullyQualifiedName)
|
||||
.filter(fqn -> fqTypeName.equals(fqn.replace('$', '.'))).blockFirst() != null;
|
||||
}
|
||||
}
|
||||
return jp.getIndex().allSuperTypesOf(liveBeanTypeFQName, true).map(IType::getFullyQualifiedName)
|
||||
.filter(fqn -> bindingQualifiedName.equals(fqn)).blockFirst() != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,9 @@
|
||||
package org.springframework.ide.vscode.boot.metadata;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -33,6 +31,7 @@ import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.util.function.Tuple2;
|
||||
import reactor.util.function.Tuples;
|
||||
|
||||
/**
|
||||
@@ -137,24 +136,17 @@ public class ClassReferenceProvider extends CachingValueProvider {
|
||||
|
||||
@Override
|
||||
protected Flux<StsValueHint> getValuesAsync(IJavaProject javaProject, String query) {
|
||||
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.getIndex()
|
||||
.allSubtypesOf(targetType)
|
||||
.filter(t -> Flags.isPublic(t.getFlags()) && !concrete || !isAbstract(t))
|
||||
.collect(Collectors.toSet())
|
||||
.block();
|
||||
if (allSubclasses.isEmpty()) {
|
||||
return Flux.empty();
|
||||
Flux<Tuple2<IType, Double>> typesWithScoresFlux = Flux.empty();
|
||||
|
||||
if (target == null) {
|
||||
typesWithScoresFlux = javaProject.getIndex().fuzzySearchTypes(query, true, false);
|
||||
} else {
|
||||
return Flux.fromIterable(allSubclasses)
|
||||
.map(type -> Tuples.of(type, FuzzyMatcher.matchScore(query, type.getFullyQualifiedName())))
|
||||
.collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2()))
|
||||
.flatMapIterable(l -> l)
|
||||
.map(t -> StsValueHint.create(sourceLinks, javaProject, t.getT1()));
|
||||
typesWithScoresFlux = javaProject.getIndex().allSubtypesOf(target, true)
|
||||
.filter(t -> Flags.isPublic(t.getFlags()) && !concrete || !isAbstract(t))
|
||||
.map(type -> Tuples.of(type, FuzzyMatcher.matchScore(query, type.getFullyQualifiedName())));
|
||||
}
|
||||
return typesWithScoresFlux.collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2()))
|
||||
.flatMapIterable(l -> l).map(t -> StsValueHint.create(sourceLinks, javaProject, t.getT1()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ 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;
|
||||
|
||||
@@ -90,7 +89,7 @@ public class LoggerNameProvider implements ValueProviderStrategy {
|
||||
.map(t -> Tuples.of(StsValueHint.create(t.getT1()), t.getT2())),
|
||||
javaProject.getIndex()
|
||||
.fuzzySearchTypes(query, true, false)
|
||||
.map(t -> Tuples.of(StsValueHint.create(sourceLinks, t.getT1(), javaProject, Suppliers.memoize(() -> javaProject.getIndex().findType(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)
|
||||
|
||||
Reference in New Issue
Block a user