void (@NotNull Collection<? extends ImplementationViewElement> elements, @NotNull PairFunction<? super ImplementationViewElement[], ? super List<FileDescriptor>, Boolean> fun) { List<ImplementationViewElement> candidates = new ArrayList<>(elements.size()); List<FileDescriptor> files = new ArrayList<>(elements.size()); final Set<String> names = new HashSet<>(); for (ImplementationViewElement element : elements) { if (element.isNamed()) { names.add(element.getName()); } if (names.size() > 1) { break; } } for (ImplementationViewElement element : elements) { VirtualFile file = element.getContainingFile(); if (file == null) continue; if (names.size() > 1) { files.add(new FileDescriptor(file, candidates.size(), getPresentation(element))); } else { files.add(new FileDescriptor(file, candidates.size(), getPresentation(element.getContainingMemberOrSelf()))); } candidates.add(element); } fun.fun(candidates.toArray(new ImplementationViewElement[0]), files); }