void (Project project, VirtualFile srcRoot) { IndexableFileSet indexableFileSet = new IndexableFileSet() { @Override public boolean isInSet(@NotNull VirtualFile file) { return file.getFileSystem() == srcRoot.getFileSystem() && project.isOpen(); } }; FileBasedIndexImpl fileBasedIndex = (FileBasedIndexImpl)FileBasedIndex.getInstance(); fileBasedIndex.registerIndexableSet(indexableFileSet, project); Disposer.register(project, () -> fileBasedIndex.removeIndexableSet(indexableFileSet)); }