IdFilter (@NotNull Project project, boolean includeNonProjectItems) { long started = System.currentTimeMillis(); final BitSet idSet = new BitSet(); ContentIterator iterator = fileOrDir -> { idSet.set(((VirtualFileWithId)fileOrDir).getId()); ProgressManager.checkCanceled(); return true; }; if (includeNonProjectItems) { FileBasedIndex.getInstance().iterateIndexableFiles(iterator, project, ProgressIndicatorProvider.getGlobalProgressIndicator()); } else { ProjectRootManager.getInstance(project).getFileIndex().iterateContent(iterator); } if (LOG.isDebugEnabled()) { long elapsed = System.currentTimeMillis() - started; LOG.debug("Done filter (includeNonProjectItems=" + includeNonProjectItems+") "+ "in " + elapsed + "ms. Total files in set: " + idSet.cardinality()); } return new IdFilter() { @Override public boolean containsFileId(int id) { return id >= 0 && idSet.get(id); } @NotNull @Override public FilterScopeType getFilteringScopeType() { return includeNonProjectItems ? FilterScopeType.PROJECT_AND_LIBRARIES : FilterScopeType.PROJECT; } }; }