GlobalSearchScope (@NotNull VirtualFile file, @NotNull Project project) { // For java only! For other languages resolve may be implemented with different rules, requiring larger scope. FileType type = file.getFileType(); if (type instanceof LanguageFileType && ((LanguageFileType)type).getLanguage() == JavaLanguage.INSTANCE) { ProjectFileIndex index = project.isDefault() ? null : ProjectRootManager.getInstance(project).getFileIndex(); if (index == null) { return GlobalSearchScope.fileScope(project, file); } if (index.isInContent(file) && !index.isInSource(file)) { PsiFile psi = PsiManager.getInstance(project).findFile(file); if (psi == null || !JavaHighlightUtil.isJavaHashBangScript(psi)) { return GlobalSearchScope.fileScope(project, file); } } } return null; }