SearchScope (@NotNull VirtualFile file, @NotNull Project project) { if (project.isDefault()) { return null; } ProjectFileIndex index = ProjectFileIndex.getInstance(project); if (index.isInLibraryClasses(file) || index.isInContent(file)) { return null; } String fileExtension = file.getExtension(); if ("class".equals(fileExtension) || JavaFileType.DEFAULT_EXTENSION.equals(fileExtension)) { for (PsiElementFinder finder : PsiElementFinder.EP.getExtensions(project)) { if (finder instanceof NonClasspathClassFinder) { final List<VirtualFile> roots = ((NonClasspathClassFinder)finder).getClassRoots(); for (VirtualFile root : roots) { if (VfsUtilCore.isAncestor(root, file, true)) { return NonClasspathDirectoriesScope.compose(roots); } } } } } return null; }