boolean (@NotNull GlobalSearchScope scope, @NotNull StringSearcher searcher, short searchContext, boolean caseSensitively, @Nullable String containerName, @NotNull SearchSession session, @NotNull ProgressIndicator progress, @NotNull BulkOccurrenceProcessor processor) { progress.setIndeterminate(false); progress.pushState(); try { progress.setText(IndexingBundle.message("psi.scanning.files.progress")); Processor<PsiElement> localProcessor = localProcessor(searcher, processor); // Lists of files to search in this order. // First, there are lists with higher probability of hits (e.g., files with `containerName` or files near the target) List<List<VirtualFile>> priorities = computePriorities(scope, searcher, searchContext, caseSensitively, containerName, session); if (priorities.isEmpty()) return true; int totalSize = priorities.stream().mapToInt(l -> l.size()).sum(); progress.setText(IndexingBundle.message("psi.search.for.word.progress", searcher.getPattern(), totalSize)); int alreadyProcessedFiles = 0; for (List<VirtualFile> files : priorities) { if (!processPsiFileRoots(files, totalSize, alreadyProcessedFiles, progress, localProcessor)) return false; alreadyProcessedFiles += files.size(); } } finally { progress.popState(); } return true; }