JDT Camelcase search

This commit is contained in:
BoykoAlex
2019-04-08 17:46:23 -04:00
parent 0c6b69c828
commit 4e2d29de47
11 changed files with 184 additions and 47 deletions

View File

@@ -105,6 +105,12 @@ public final class JandexClasspath implements ClasspathIndex {
return javaIndex.get().fuzzySearchITypes(searchTerm);
}
@Override
public Flux<Tuple2<IType, Double>> camelcaseSearchTypes(String searchTerm, boolean includeBinaries,
boolean includeSystemLibs) {
throw new UnsupportedOperationException("Not implemented for Jandex index!");
}
@Override
public Flux<Tuple2<String, Double>> fuzzySearchPackages(String searchTerm, boolean includeBinaries, boolean includeSystemLibs) {
return javaIndex.get().fuzzySearchPackages(searchTerm);

View File

@@ -18,6 +18,7 @@ public interface ClasspathIndex extends Disposable {
IType findType(String fqName);
Flux<Tuple2<IType, Double>> fuzzySearchTypes(String searchTerm, boolean includeBinaries, boolean includeSystemLibs);
Flux<Tuple2<IType, Double>> camelcaseSearchTypes(String searchTerm, boolean includeBinaries, boolean includeSystemLibs);
Flux<Tuple2<String, Double>> fuzzySearchPackages(String searchTerm, boolean includeBinaries, boolean includeSystemLibs);
Flux<IType> allSubtypesOf(String fqName, boolean includeFocusType);
Flux<IType> allSuperTypesOf(String fqName, boolean includeFocusType);

View File

@@ -33,6 +33,7 @@ import org.springframework.ide.vscode.commons.protocol.STS4LanguageClient;
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
import org.springframework.ide.vscode.commons.protocol.java.JavaDataParams;
import org.springframework.ide.vscode.commons.protocol.java.JavaSearchParams;
import org.springframework.ide.vscode.commons.protocol.java.JavaSearchParams.SearchType;
import org.springframework.ide.vscode.commons.protocol.java.JavaTypeHierarchyParams;
import org.springframework.ide.vscode.commons.protocol.java.TypeData;
import org.springframework.ide.vscode.commons.protocol.java.TypeDescriptorData;
@@ -146,7 +147,7 @@ public class JdtLsIndex implements ClasspathIndex {
@Override
public Flux<Tuple2<IType, Double>> fuzzySearchTypes(String searchTerm, boolean includeBinaries, boolean includeSystemLibs) {
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, SearchType.FUZZY, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
return Mono.fromFuture(client.javaSearchTypes(searchParams))
.flatMapMany(results -> Flux.fromIterable(results).publishOn(Schedulers.parallel()))
.filter(Objects::nonNull)
@@ -156,13 +157,24 @@ public class JdtLsIndex implements ClasspathIndex {
@Override
public Flux<Tuple2<String, Double>> fuzzySearchPackages(String searchTerm, boolean includeBinaries, boolean includeSystemLibs) {
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, SearchType.FUZZY, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
return Mono.fromFuture(client.javaSearchPackages(searchParams))
.flatMapMany(results -> Flux.fromIterable(results).publishOn(Schedulers.parallel()))
.filter(Objects::nonNull)
.map(p -> Tuples.of(p, FuzzyMatcher.matchScore(searchTerm, p)))
.filter(tuple -> tuple.getT2() != 0.0);
}
@Override
public Flux<Tuple2<IType, Double>> camelcaseSearchTypes(String searchTerm, boolean includeBinaries,
boolean includeSystemLibs) {
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, SearchType.CAMELCASE, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
return Mono.fromFuture(client.javaSearchTypes(searchParams))
.flatMapMany(results -> Flux.fromIterable(results).publishOn(Schedulers.parallel()))
.filter(Objects::nonNull)
.map(type -> Tuples.of(toTypeFromDescriptor(type), FuzzyMatcher.matchScore(searchTerm, type.getFqName())))
.filter(tuple -> tuple.getT2() != 0.0);
}
private List<IType> convertTypeDescriptors(List<TypeDescriptorData> descriptors) {
List<IType> types = new ArrayList<>(descriptors.size());