private static void update(@NotNull Collection<? extends ImplementationViewElement> viewElements,
                             @NotNull PairFunction<? super ImplementationViewElement[], ? super List<FileDescriptor>, Boolean> fun) {
    List<ImplementationViewElement> candidates = new ArrayList<>(viewElements.size());
    List<FileDescriptor> files = new ArrayList<>(viewElements.size());
    final Set<String> names = new HashSet<>();
    for (ImplementationViewElement viewElement : viewElements) {
      if (viewElement.isNamed()) {
        names.add(viewElement.getName());
      }
      if (names.size() > 1) {
        break;
      }
    }

    for (ImplementationViewElement element : viewElements) {
      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);
  }
private static void update(@NotNull Collection<? extends ImplementationViewElement> viewElements,
                             @NotNull PairFunction<? super ImplementationViewElement[], ? super List<FileDescriptor>, Boolean> fun)