private static <T> ElementsChooser<T> createChooser(@NotNull PersistentSearchEverywhereContributorFilter<T> filter,
                                                      @NotNull Runnable rebuildRunnable,
                                                      @Nullable ElementsChooser.StatisticsCollector<T> statisticsCollector) {
    ElementsChooser<T> res = new ElementsChooser<>(filter.getAllElements(), false) {
      @Override
      protected String getItemText(@NotNull T value) {
        return filter.getElementText(value);
      }

      @Nullable
      @Override
      protected Icon getItemIcon(@NotNull T value) {
        return filter.getElementIcon(value);
      }
    };
    res.markElements(filter.getSelectedElements());
    ElementsChooser.ElementsMarkListener<T> listener = (element, isMarked) -> {
      filter.setSelected(element, isMarked);
      rebuildRunnable.run();
    };
    res.addElementsMarkListener(listener);

    if (statisticsCollector != null) {
      res.addStatisticsCollector(statisticsCollector);
    }

    return res;
  }
private static <T> ElementsChooser<T> createChooser(@NotNull PersistentSearchEverywhereContributorFilter<T> filter,
                                                      @NotNull Runnable rebuildRunnable,
                                                      @Nullable ElementsChooser.StatisticsCollector<T> statisticsCollector)