void (@NotNull ProgressIndicator indicator) { try { Project project = scope.getProject(); FileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); scope.accept(file -> { ProgressManager.checkCanceled(); if (ProjectUtil.isProjectOrWorkspaceFile(file) || !ReadAction.compute(() -> fileIndex.isInContent(file) || ScratchUtil.isScratch(file))) { return true; } PsiFile psiFile = ReadAction.compute(() -> { if (project.isDisposed()) throw new ProcessCanceledException(); PsiFile psi = PsiManager.getInstance(project).findFile(file); Document document = psi == null ? null : shouldProcess(psi, headlessEnvironment, localScopeFiles); if (document != null) { return psi; } return null; }); // do not inspect binary files if (psiFile != null) { try { if (ApplicationManager.getApplication().isReadAccessAllowed()) { throw new IllegalStateException("Must not have read action"); } outFilesToInspect.put(file); } catch (InterruptedException e) { LOG.error(e); } } ProgressManager.checkCanceled(); return true; }); } catch (ProcessCanceledException e) { // ignore, but put tombstone } finally { try { outFilesToInspect.put(TOMBSTONE); } catch (InterruptedException e) { LOG.error(e); } } }