PsiMember (PsiJavaCodeReferenceElement reference) { PsiElement parent = reference.getParent(); if (!(parent instanceof PsiTypeElement) && !(parent instanceof PsiReferenceList)) { return null; } PsiElement grandParent = PsiTreeUtil.skipParentsOfType(reference, PsiTypeElement.class, PsiReferenceList.class, PsiParameter.class, PsiParameterList.class, PsiReferenceParameterList.class, PsiJavaCodeReferenceElement.class, PsiTypeParameter.class, PsiTypeParameterList.class); if (grandParent instanceof PsiField || grandParent instanceof PsiMethod) { return (PsiMember)grandParent; } return null; }