void (@NotNull final AnActionEvent e) { cancelListUpdater(); final UsageViewPresentation presentation = new UsageViewPresentation(); final String text = getTrimmedText(); final String prefixPattern = myFindUsagesTitle + " '" + text + "'"; presentation.setCodeUsagesString(prefixPattern); presentation.setTabName(prefixPattern); presentation.setTabText(prefixPattern); presentation.setTargetsNodeText(LangBundle.message("list.item.unsorted", StringUtil.toLowerCase(patternToLowerCase(prefixPattern)))); PsiElement[] elements = getElements(); final List<PsiElement> targets = new ArrayList<>(); final Set<Usage> usages = new LinkedHashSet<>(); fillUsages(Arrays.asList(elements), usages, targets); if (myListModel.contains(EXTRA_ELEM)) { //start searching for the rest final boolean everywhere = myCheckBox.isSelected(); hideHint(); final Set<Object> collected = new LinkedHashSet<>(); ProgressManager.getInstance().run(new Task.Modal(myProject, prefixPattern, true) { private ChooseByNameBase.CalcElementsThread myCalcUsagesThread; @Override public void run(@NotNull final ProgressIndicator indicator) { ensureNamesLoaded(everywhere); indicator.setIndeterminate(true); final TooManyUsagesStatus tooManyUsagesStatus = TooManyUsagesStatus.createFor(indicator); myCalcUsagesThread = new CalcElementsThread(text, everywhere, ModalityState.nonModal(), PreserveSelection.INSTANCE, __->{}) { @Override protected boolean isOverflow(@NotNull Set<Object> elementsArray) { tooManyUsagesStatus.pauseProcessingIfTooManyUsages(); if (elementsArray.size() > UsageLimitUtil.USAGES_LIMIT - myMaximumListSizeLimit && tooManyUsagesStatus.switchTooManyUsagesStatus()) { UsageViewManagerImpl.showTooManyUsagesWarningLater(getProject(), tooManyUsagesStatus, indicator, null, () -> UsageViewBundle.message("find.excessive.usage.count.prompt"), null); } return false; } }; ApplicationManager.getApplication().runReadAction(() -> { myCalcUsagesThread.addElementsByPattern(text, collected, indicator, everywhere); indicator.setText(LangBundle.message("progress.text.prepare")); fillUsages(collected, usages, targets); }); } @Override public void onSuccess() { showUsageView(targets, usages, presentation); } @Override public void onCancel() { myCalcUsagesThread.cancel(); } @Override public void onThrowable(@NotNull Throwable error) { super.onThrowable(error); myCalcUsagesThread.cancel(); } }); } else { hideHint(); showUsageView(targets, usages, presentation); } }