Missing changes from JDT Index adoption

This commit is contained in:
BoykoAlex
2019-02-23 00:52:35 -05:00
parent a3aabe534a
commit 529e91e82c
3 changed files with 21 additions and 4 deletions

View File

@@ -110,6 +110,15 @@ public class JavaLangugeClientTest {
assertEquals("io.netty.util.Mapping", closeMatches.get(0).getFqName());
}
@Test
public void fuzzyFindAllTypesExcludingSysLibs() throws Exception {
List<TypeData> data = client
.javaSearchTypes(new JavaSearchParams(project.getLocationURI().toString(), "", true, false))
.get(1000, TimeUnit.SECONDS);
assertNotNull(data);
assertTrue(data.size() > 10000);
}
@Test
public void searchPackagesIncludingSysLibs() throws Exception {
List<String> packages = client.javaSearchPackages(new JavaSearchParams(project.getLocationURI().toString(), "java.lang", true, true)).get(30, TimeUnit.SECONDS);
@@ -124,6 +133,12 @@ public class JavaLangugeClientTest {
assertTrue(packages.contains("org.test"));
}
@Test
public void searchAllPackagesExcludingSysLibs() throws Exception {
List<String> packages = client.javaSearchPackages(new JavaSearchParams(project.getLocationURI().toString(), "", true, false)).get(30, TimeUnit.SECONDS);
assertTrue(packages.size() > 1000);
}
@Test
public void map_Subtypes() throws Exception {
List<TypeData> data = client

View File

@@ -58,10 +58,10 @@ public interface STS4LanguageClient extends LanguageClient {
@JsonRequest("sts/javaLocation")
CompletableFuture<Location> javaLocation(JavaDataParams params);
@JsonRequest("sts/searchJavaTypes")
@JsonRequest("sts/javaSearchTypes")
CompletableFuture<List<TypeData>> javaSearchTypes(JavaSearchParams params);
@JsonRequest("sts/searchJavaPackages")
@JsonRequest("sts/javaSearchPackages")
CompletableFuture<List<String>> javaSearchPackages(JavaSearchParams params);
@JsonRequest("sts/javaSubTypes")

View File

@@ -26,12 +26,14 @@ 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.FuzzyMatcher;
import org.springframework.ide.vscode.commons.util.StringUtil;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import reactor.core.publisher.Flux;
import reactor.util.function.Tuples;
/**
* Provides the algorithm for 'class-reference' valueProvider.
@@ -147,8 +149,8 @@ public class ClassReferenceProvider extends CachingValueProvider {
if (allSubclasses.isEmpty()) {
return Flux.empty();
} else {
return javaProject.getIndex()
.fuzzySearchTypes(query, true, false, type -> allSubclasses.contains(type))
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()));