void () { ProgressIndicator current = ProgressManager.getInstance().getProgressIndicator(); if (current == null) throw new IllegalStateException("must run find usages under progress"); ProgressIndicator indicator = ProgressWrapper.unwrapAll(current); if (!ApplicationManager.getApplication().isDispatchThread()) { CoreProgressManager.assertUnderProgress(indicator); } TooManyUsagesStatus.createFor(indicator); UsageSearcher usageSearcher = mySearcherFactory.create(); long startSearchStamp = System.currentTimeMillis(); usageSearcher.generate(usage -> { ProgressIndicator currentIndicator = ProgressManager.getInstance().getProgressIndicator(); if (currentIndicator == null) throw new IllegalStateException("must run find usages under progress"); ProgressIndicator originalIndicator = ProgressWrapper.unwrapAll(current); ProgressManager.checkCanceled(); if (!UsageViewManagerImpl.isInScope(usage, mySearchScopeToWarnOfFallingOutOf)) { myOutOfScopeUsages.incrementAndGet(); return true; } boolean incrementCounter = !UsageViewManager.isSelfUsage(usage, mySearchFor); if (incrementCounter) { int usageCount = myUsageCountWithoutDefinition.incrementAndGet(); if (usageCount == 1 && !myProcessPresentation.isShowPanelIfOnlyOneUsage()) { myFirstUsage.compareAndSet(null, usage); } myFirstItemFoundTS.compareAndSet(0, System.nanoTime()); // Successes only once - at first assignment UsageViewEx usageView = getUsageView(originalIndicator, startSearchStamp); TooManyUsagesStatus tooManyUsagesStatus= TooManyUsagesStatus.getFrom(originalIndicator); if (usageCount > UsageLimitUtil.USAGES_LIMIT && tooManyUsagesStatus.switchTooManyUsagesStatus()) { myTooManyUsages.set(true); PsiElement element = getPsiElement(mySearchFor); Class<? extends PsiElement> elementClass = element == null ? null : element.getClass(); String scopeText = myPresentation.getScopeText(); Language language = element == null ? null : element.getLanguage(); Consumer<UsageLimitUtil.Result> onUserClicked = result -> UsageViewStatisticsCollector.logTooManyDialog(myProject, myUsageViewRef.get(), result == UsageLimitUtil.Result.ABORT ? TooManyUsagesUserAction.Aborted : TooManyUsagesUserAction.Continued, elementClass, scopeText, language); UsageViewManagerImpl.showTooManyUsagesWarningLater(myProject, tooManyUsagesStatus, originalIndicator, usageView, () -> UsageViewBundle.message("find.excessive.usage.count.prompt"), onUserClicked); UsageViewStatisticsCollector.logTooManyDialog(myProject, myUsageViewRef.get(), TooManyUsagesUserAction.Shown, elementClass, scopeText, language); } tooManyUsagesStatus.pauseProcessingIfTooManyUsages(); if (usageView != null) { ApplicationManager.getApplication().runReadAction(() -> usageView.appendUsage(usage)); } } return true; }); if (myProcessPresentation.isShowFindOptionsPrompt() && getUsageView(indicator, startSearchStamp) != null) { ApplicationManager.getApplication().invokeLater(() -> myUsageViewManager.showToolWindow(true), myProject.getDisposed()); } }