PsiClass (@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { PsiClass aClass = super.findClass(qualifiedName, scope); if (aClass == null || scope instanceof ExternalModuleBuildGlobalSearchScope || scope instanceof EverythingGlobalScope) { return aClass; } PsiFile containingFile = aClass.getContainingFile(); VirtualFile file = containingFile != null ? containingFile.getVirtualFile() : null; return file != null && !ProjectFileIndex.getInstance(myProject).isInContent(file) && !ProjectFileIndex.getInstance(myProject).isInLibrary(file) ? aClass : null; }