From 525a42d8511fff86907357c7c133e9804beb7097 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 4 Apr 2017 16:00:47 +0300 Subject: [PATCH] javac ast indices: cleanup, dead code --- .../backwardRefs/CompilerReferenceServiceEx.java | 2 +- .../backwardRefs/CompilerReferenceServiceImpl.java | 9 +++------ .../compiler/chainsSearch/ChainsSearcher.java | 12 ++---------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceEx.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceEx.java index 9ed128cea6a1..af999b0f797f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceEx.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceEx.java @@ -32,7 +32,7 @@ public abstract class CompilerReferenceServiceEx extends CompilerReferenceServic } @NotNull - public abstract SortedSet> findMethodReferenceOccurrences(@NotNull String rawReturnType, boolean onlyStatic) + public abstract SortedSet> findMethodReferenceOccurrences(@NotNull String rawReturnType) throws ReferenceIndexUnavailableException; public abstract boolean mayHappen(@NotNull LightRef ref1, @NotNull LightRef ref2, int correlationThreshold) diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java index 62f4c8cdd6ea..41e127c36acf 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java @@ -222,17 +222,14 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceServiceEx imp @NotNull @Override - public SortedSet> findMethodReferenceOccurrences(@NotNull String rawReturnType, boolean onlyStatic) { + public SortedSet> findMethodReferenceOccurrences(@NotNull String rawReturnType) { try { myReadDataLock.lock(); if (myReader == null) throw new ReferenceIndexUnavailableException(); try { final int type = myReader.getNameEnumerator().tryEnumerate(rawReturnType); - Stream.Builder builder = Stream.builder().add(new SignatureData(type, true)); - if (!onlyStatic) { - builder.accept(new SignatureData(type, false)); - } - return builder.build() + if (type == 0) return Collections.emptySortedSet(); + return Stream.of(new SignatureData(type, true), new SignatureData(type, false)) .flatMap(sd -> myReader.getMembersFor(sd) .stream() .filter(r -> r instanceof LightRef.JavaLightMethodRef) diff --git a/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainsSearcher.java b/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainsSearcher.java index 407b8fa2e775..01da3aae1802 100644 --- a/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainsSearcher.java +++ b/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainsSearcher.java @@ -56,7 +56,7 @@ public class ChainsSearcher { private static SearchInitializer createInitializer(TargetType target, CompilerReferenceServiceEx compilerReferenceServiceEx, ChainCompletionContext context) { - SortedSet> methods = compilerReferenceServiceEx.findMethodReferenceOccurrences(target.getClassQName(), false); + SortedSet> methods = compilerReferenceServiceEx.findMethodReferenceOccurrences(target.getClassQName()); return new SearchInitializer(methods, context); } @@ -80,14 +80,6 @@ public class ChainsSearcher { .filter(Objects::nonNull) .collect(Collectors.toCollection(LinkedList::new)); - - int maxWeight = 0; - for (MethodsChain methodsChain : knownDistance.values()) { - if (methodsChain.getChainWeight() > maxWeight) { - maxWeight = methodsChain.getChainWeight(); - } - } - ResultHolder result = new ResultHolder(context.getPsiManager()); while (!q.isEmpty()) { ProgressManager.checkCanceled(); @@ -104,7 +96,7 @@ public class ChainsSearcher { continue; } String currentReturnType = headSignature.getOwner(); - SortedSet> nextMethods = indexReader.findMethodReferenceOccurrences(currentReturnType, false); + SortedSet> nextMethods = indexReader.findMethodReferenceOccurrences(currentReturnType); MaxSizeTreeSet> currentSignatures = new MaxSizeTreeSet<>(maxResultSize); for (OccurrencesAware indexValue : nextMethods) {