void (@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); }); }