diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java index 1cf674f31c09..169961edeb29 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java @@ -346,14 +346,11 @@ public class MarkerType { return; } - final PsiElementProcessor.CollectElementsWithLimit collectProcessor = new PsiElementProcessor.CollectElementsWithLimit<>(2, - new THashSet<>()); - final PsiElementProcessor.CollectElementsWithLimit collectExprProcessor = - new PsiElementProcessor.CollectElementsWithLimit<>(1, - new THashSet<>()); + final PsiElementProcessor.FindElement collectProcessor = new PsiElementProcessor.FindElement<>(); + final PsiElementProcessor.FindElement collectExprProcessor = new PsiElementProcessor.FindElement<>(); if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ClassInheritorsSearch.search(aClass).forEach(new PsiElementProcessorAdapter<>(collectProcessor)); - if (collectProcessor.getCollection().size() < 1) { + if (collectProcessor.getFoundElement() == null) { FunctionalExpressionSearch.search(aClass).forEach(new PsiElementProcessorAdapter<>(collectExprProcessor)); } }, SEARCHING_FOR_OVERRIDDEN_METHODS, true, aClass.getProject(), (JComponent)e.getComponent())) { @@ -361,8 +358,8 @@ public class MarkerType { } final List inheritors = new ArrayList<>(); - inheritors.addAll(collectProcessor.getCollection()); - inheritors.addAll(collectExprProcessor.getCollection()); + ContainerUtil.addIfNotNull(inheritors, collectProcessor.getFoundElement()); + ContainerUtil.addIfNotNull(inheritors, collectExprProcessor.getFoundElement()); if (inheritors.isEmpty()) return; final PsiClassOrFunctionalExpressionListCellRenderer renderer = new PsiClassOrFunctionalExpressionListCellRenderer(); final SubclassUpdater subclassUpdater = new SubclassUpdater(aClass, renderer); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java index ca0516e2eb41..3bafb52b20a2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java @@ -34,7 +34,6 @@ import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.DefinitionsScopedSearch; import com.intellij.util.CommonProcessors; import com.intellij.util.Query; -import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -127,9 +126,8 @@ public class ImplementationSearcher { return new PsiElement[]{element}; } - PsiElementProcessor.CollectElementsWithLimit collectProcessor = - new PsiElementProcessor.CollectElementsWithLimit<>(1, new THashSet<>()); - PsiElement[][] result = new PsiElement[1][]; + PsiElementProcessor.FindElement collectProcessor = new PsiElementProcessor.FindElement<>(); + PsiElement[] result = new PsiElement[1]; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { @@ -140,7 +138,7 @@ public class ImplementationSearcher { return !accept(element) || super.processInReadAction(element); } }); - result[0] = collectProcessor.toArray(); + result[0] = collectProcessor.getFoundElement(); } catch (IndexNotReadyException e) { ImplementationSearcher.dumbModeNotification(element); @@ -150,7 +148,8 @@ public class ImplementationSearcher { }, SEARCHING_FOR_IMPLEMENTATIONS, true, element.getProject())) { return null; } - return result[0]; + PsiElement foundElement = result[0]; + return foundElement != null ? new PsiElement[] {foundElement} : null; } protected boolean canShowPopupWithOneItem(PsiElement element) {