void (@NotNull ImplicitToStringSearch.SearchParameters parameters, @NotNull Processor<? super PsiExpression> consumer) { PsiMethod targetMethod = parameters.getTargetMethod(); Project project = PsiUtilCore.getProjectInReadAction(targetMethod); PsiClass aClass = ReadAction.compute(() -> targetMethod.getContainingClass()); if (aClass == null) return; DumbService dumbService = DumbService.getInstance(project); Map<VirtualFile, int[]> fileOffsets = new HashMap<>(); dumbService.runReadActionInSmartMode(() -> { CompilerReferenceService compilerReferenceService = CompilerReferenceService.getInstanceIfEnabled(project); GlobalSearchScope scopeWithToString = compilerReferenceService == null ? null : compilerReferenceService.getScopeWithImplicitToStringCodeReferences(aClass); GlobalSearchScope filter = GlobalSearchScopeUtil.toGlobalSearchScope(scopeWithToString == null ? parameters.getSearchScope() : scopeWithToString.intersectWith(parameters.getSearchScope()), project); FileBasedIndex.getInstance().processValues(JavaBinaryPlusExpressionIndex.INDEX_ID, Boolean.TRUE, null, (file, value) -> { ProgressManager.checkCanceled(); fileOffsets.put(file, value.getOffsets()); return true; }, filter); }); PsiManager psiManager = PsiManager.getInstance(project); psiManager.runInBatchFilesMode(() -> { for (Map.Entry<VirtualFile, int[]> entry : fileOffsets.entrySet()) { VirtualFile file = entry.getKey(); int[] offsets = entry.getValue(); ProgressManager.checkCanceled(); if (!processFile(file, offsets, psiManager, targetMethod, consumer, dumbService)) { return null; } } return null; }); }