void (@NotNull String pattern, @NotNull ProgressIndicator progressIndicator, @NotNull Processor<? super FoundItemDescriptor<Object>> consumer) { if (myProject == null) return; //nowhere to search if (!isEmptyPatternSupported() && pattern.isEmpty()) return; Runnable fetchRunnable = () -> { if (!isDumbAware() && DumbService.isDumb(myProject)) return; FilteringGotoByModel<?> model = createModel(myProject); if (progressIndicator.isCanceled()) return; PsiElement context = myPsiContext != null ? myPsiContext.getElement() : null; ChooseByNameItemProvider provider = ChooseByNameModelEx.getItemProvider(model, context); GlobalSearchScope scope = (GlobalSearchScope)Objects.requireNonNull(myScopeDescriptor.getScope()); boolean everywhere = scope.isSearchInLibraries(); ChooseByNameViewModel viewModel = new MyViewModel(myProject, model); if (provider instanceof ChooseByNameInScopeItemProvider) { FindSymbolParameters parameters = FindSymbolParameters.wrap(pattern, scope); ((ChooseByNameInScopeItemProvider)provider).filterElementsWithWeights(viewModel, parameters, progressIndicator, item -> processElement(progressIndicator, consumer, model, item.getItem(), item.getWeight()) ); } else if (provider instanceof ChooseByNameWeightedItemProvider) { ((ChooseByNameWeightedItemProvider)provider).filterElementsWithWeights(viewModel, pattern, everywhere, progressIndicator, item -> processElement(progressIndicator, consumer, model, item.getItem(), item.getWeight()) ); } else { provider.filterElements(viewModel, pattern, everywhere, progressIndicator, element -> processElement(progressIndicator, consumer, model, element, getElementPriority(element, pattern)) ); } }; Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode() && application.isDispatchThread()) { fetchRunnable.run(); } else { ProgressIndicatorUtils.yieldToPendingWriteActions(); ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(fetchRunnable, progressIndicator); } }