boolean (@NotNull PsiFile psiFile, @NotNull String name) { if (!(psiFile instanceof PsiJavaFile)) return false; PsiImportList importList = ((PsiJavaFile)psiFile).getImportList(); if (importList == null) return false; PsiImportStatement[] importStatements = importList.getImportStatements(); for (PsiImportStatement importStatement : importStatements) { if (importStatement.resolve() != null) continue; if (importStatement.isOnDemand()) return true; String qualifiedName = importStatement.getQualifiedName(); String className = qualifiedName == null ? null : ClassUtil.extractClassName(qualifiedName); if (Comparing.strEqual(className, name)) return true; } PsiImportStaticStatement[] importStaticStatements = importList.getImportStaticStatements(); for (PsiImportStaticStatement importStaticStatement : importStaticStatements) { if (importStaticStatement.resolve() != null) continue; if (importStaticStatement.isOnDemand()) return true; String qualifiedName = importStaticStatement.getReferenceName(); // rough heuristic, since there is no API to get class name reference from static import if (qualifiedName != null && StringUtil.split(qualifiedName, ".").contains(name)) return true; } return false; }