boolean (@NotNull ChooseByNameViewModel base, boolean everywhere, @NotNull ProgressIndicator indicator, @Nullable PsiElement context, @NotNull Processor<? super FoundItemDescriptor<?>> consumer, @NotNull List<? extends MatchResult> namesList, @NotNull FindSymbolParameters parameters) { List<Pair<Object, MatchResult>> sameNameElements = new SmartList<>(); ChooseByNameModel model = base.getModel(); Comparator<Pair<Object, MatchResult>> weightComparator = new Comparator<>() { @SuppressWarnings("unchecked") final Comparator<Object> modelComparator = model instanceof Comparator ? (Comparator<Object>)model : new PathProximityComparator(context); @Override public int compare(Pair<Object, MatchResult> o1, Pair<Object, MatchResult> o2) { int result = modelComparator.compare(o1.first, o2.first); return result != 0 ? result : o1.second.compareTo(o2.second); } }; MinusculeMatcher fullMatcher = getFullMatcher(parameters, base); for (MatchResult result : namesList) { indicator.checkCanceled(); String name = result.elementName; // use interruptible call if possible Object[] elements = model instanceof ContributorsBasedGotoByModel ? ((ContributorsBasedGotoByModel)model).getElementsByName(name, parameters, indicator) : model.getElementsByName(name, everywhere, getNamePattern(base, parameters.getCompletePattern())); if (elements.length > 1) { sameNameElements.clear(); for (final Object element : elements) { indicator.checkCanceled(); MatchResult qualifiedResult = matchQualifiedName(model, fullMatcher, element); if (qualifiedResult != null) { sameNameElements.add(Pair.create(element, qualifiedResult)); } } sameNameElements.sort(weightComparator); List<FoundItemDescriptor<?>> processedItems = ContainerUtil.map(sameNameElements, p -> new FoundItemDescriptor<>(p.first, result.matchingDegree)); if (!ContainerUtil.process(processedItems, consumer)) return false; } else if (elements.length == 1) { if (matchQualifiedName(model, fullMatcher, elements[0]) != null) { if (!consumer.process(new FoundItemDescriptor<>(elements[0], result.matchingDegree))) return false; } } } return true; }