void (@NotNull AnActionEvent e) { stopSearching(); Collection<SearchEverywhereContributor<?>> contributors = myHeader.getSelectedTab().getContributors(); contributors = ContainerUtil.filter(contributors, SearchEverywhereContributor::showInFindResults); if (contributors.isEmpty()) { return; } String searchText = getSearchPattern(); String contributorsString = contributors.stream() .map(SearchEverywhereContributor::getGroupName) .collect(Collectors.joining(", ")); UsageViewPresentation presentation = new UsageViewPresentation(); String tabCaptionText = IdeBundle.message("searcheverywhere.found.matches.title", searchText, contributorsString); presentation.setCodeUsagesString(tabCaptionText); presentation.setTargetsNodeText(IdeBundle.message("searcheverywhere.found.targets.title", searchText, contributorsString)); presentation.setTabName(tabCaptionText); presentation.setTabText(tabCaptionText); Collection<Usage> usages = new LinkedHashSet<>(); Collection<PsiElement> targets = new LinkedHashSet<>(); Collection<Object> cached = contributors.stream() .flatMap(contributor -> myListModel.getFoundItems(contributor).stream()) .collect(Collectors.toSet()); fillUsages(cached, usages, targets); Collection<SearchEverywhereContributor<?>> contributorsForAdditionalSearch; contributorsForAdditionalSearch = ContainerUtil.filter(contributors, contributor -> myListModel.hasMoreElements(contributor)); if (!contributorsForAdditionalSearch.isEmpty()) { ProgressManager.getInstance().run(new Task.Modal(myProject, tabCaptionText, true) { private final ProgressIndicator progressIndicator = new ProgressIndicatorBase(); @Override public void run(@NotNull ProgressIndicator indicator) { progressIndicator.start(); TooManyUsagesStatus tooManyUsagesStatus = TooManyUsagesStatus.createFor(progressIndicator); Collection<Object> foundElements = new ArrayList<>(); int alreadyFoundCount = cached.size(); for (SearchEverywhereContributor<?> contributor : contributorsForAdditionalSearch) { if (progressIndicator.isCanceled()) break; try { fetch(contributor, foundElements, alreadyFoundCount, tooManyUsagesStatus); } catch (ProcessCanceledException ignore) { } } fillUsages(foundElements, usages, targets); } <Item> void fetch(SearchEverywhereContributor<Item> contributor, Collection<Object> foundElements, int alreadyFoundCount, TooManyUsagesStatus tooManyUsagesStatus) { contributor.fetchElements(searchText, progressIndicator, o -> { if (progressIndicator.isCanceled()) { return false; } if (cached.contains(o)) { return true; } foundElements.add(o); tooManyUsagesStatus.pauseProcessingIfTooManyUsages(); if (foundElements.size() + alreadyFoundCount >= UsageLimitUtil.USAGES_LIMIT && tooManyUsagesStatus.switchTooManyUsagesStatus()) { UsageViewManagerImpl.showTooManyUsagesWarningLater(getProject(), tooManyUsagesStatus, progressIndicator, null, () -> UsageViewBundle.message("find.excessive.usage.count.prompt"), null); return !progressIndicator.isCanceled(); } return true; }); } @Override public void onCancel() { progressIndicator.cancel(); } @Override public void onSuccess() { showInFindWindow(targets, usages, presentation); } @Override public void onThrowable(@NotNull Throwable error) { super.onThrowable(error); progressIndicator.cancel(); } }); } else { showInFindWindow(targets, usages, presentation); } sendStatisticsAndClose(); }