boolean (@NotNull Processor<? super PsiFile> processor) { if (myProject.isDefault()) return true; GlobalSearchScope scope = new GlobalSearchScope(myProject) { @Override public boolean isSearchInModuleContent(@NotNull Module module) { return true; } @Override public boolean isSearchInLibraries() { return false; } @Override public boolean contains(@NotNull VirtualFile file) { return TodoIndexers.belongsToProject(myProject, file); } }; ConcurrentBitSet idSet = ConcurrentBitSet.create(); ManagingFS fs = ManagingFS.getInstance(); PsiManager psiManager = PsiManager.getInstance(myProject); IntPredicate consumer = fileId -> { VirtualFile file = fs.findFileById(fileId); if (file == null || !file.isValid() || !scope.contains(file)) return true; PsiFile psiFile = psiManager.findFile(file); return psiFile == null || processor.process(psiFile); }; DumbModeAccessType.RAW_INDEX_DATA_ACCEPTABLE.ignoreDumbMode(() -> { FileBasedIndex.getInstance().processAllKeys(TodoIndex.NAME, fileId -> { idSet.set(fileId); return true; }, scope, null); }); FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance(); fileDocumentManager.processUnsavedDocuments(document -> { VirtualFile file = fileDocumentManager.getFile(document); if (file instanceof VirtualFileWithId) { idSet.clear(((VirtualFileWithId)file).getId()); } return true; }); for (int fileId = idSet.nextSetBit(0); fileId > 0; fileId = idSet.nextSetBit(fileId + 1)) { if (IndexingStamp.isFileIndexedStateCurrent(fileId, TodoIndex.NAME) != FileIndexingState.UP_TO_DATE) { idSet.clear(fileId); } else if (!consumer.test(fileId)) return false; } IdFilter filter = ((FileBasedIndexEx)FileBasedIndex.getInstance()).extractIdFilter(scope, myProject); if (!FileBasedIndexScanUtil.doProcessAllKeys(TodoIndex.NAME, fileId -> idSet.set(fileId) || consumer.test(fileId), scope, filter)) { return false; } return true; }