boolean (@NotNull PsiFile psiFile, @NotNull String name) { if (!(psiFile instanceof GroovyFile)) return false; final GrImportStatement[] importStatements = ((GroovyFile)psiFile).getImportStatements(); for (GrImportStatement importStatement : importStatements) { final GrCodeReferenceElement importReference = importStatement.getImportReference(); if (importReference == null || importReference.resolve() != null) { continue; } if (importStatement.isOnDemand() || Comparing.strEqual(importStatement.getImportedName(), name)) { return true; } } return false; }