Collection<String> (@NotNull PsiQualifiedReferenceElement ref) { GrImportStatement importStatement = PsiTreeUtil.getParentOfType(ref.getElement(), GrImportStatement.class); //from static imports if (importStatement != null) { String fqn = importStatement.getImportFqn(); return fqn == null ? Collections.emptyList() : Collections.singleton(fqn); } if (ref.getQualifier() != null) return Collections.emptyList(); final String className = ref.getReferenceName(); if (className == null) return Collections.emptyList(); PsiFile file = ref.getContainingFile().getOriginalFile(); if (!(file instanceof GroovyFile)) return Collections.emptyList(); GrImportStatement[] importList = ((GroovyFile)file).getImportStatements(); for (GrImportStatement imp : importList) { if (className.equals(imp.getImportedName())) { String fqn = imp.getImportFqn(); return fqn == null ? Collections.emptyList() : Collections.singleton(fqn); } } return Collections.emptyList(); }