boolean (@NotNull PsiFile containingFile, @NotNull PsiClass classToImport) { GrImportStatement[] importList = ((GroovyFile)containingFile).getImportStatements(); if (importList == null) return false; String classQualifiedName = classToImport.getQualifiedName(); String packageName = classQualifiedName == null ? "" : StringUtil.getPackageName(classQualifiedName); boolean result = false; for (GrImportStatement statement : importList) { GrCodeReferenceElement importRef = statement.getImportReference(); if (importRef == null) continue; String canonicalText = importRef.getCanonicalText(); // rely on the optimization: no resolve while getting import statement canonical text if (statement.isOnDemand()) { if (canonicalText.equals(packageName)) { result = true; break; } } else { if (canonicalText.equals(classQualifiedName)) { result = true; break; } } } return result; }