PsiQualifiedReferenceElement (PsiReferenceList refList, PsiClass aClass) { PsiQualifiedReferenceElement[] refs = refList instanceof GrReferenceList ? ((GrReferenceList)refList).getReferenceElementsGroovy() : refList.getReferenceElements(); for (PsiQualifiedReferenceElement ref : refs) { if (ref.isReferenceTo(aClass)) { return ref; } } return null; }