void (PsiJavaCodeReferenceElement reference) { if (reference.isQualified()) { return; } final PsiElement target = reference.resolve(); if (!(target instanceof PsiMethod) && !(target instanceof PsiClass) && !(target instanceof PsiField)) { return; } final PsiMember member = (PsiMember)target; for (PsiElement importTarget : myImportTargets) { if (importTarget instanceof PsiMethod) { if (member.equals(importTarget)) { addReference(member, reference); } } else if (importTarget instanceof PsiClass importClass) { if (myOnDemand) { final PsiClass containingClass = member.getContainingClass(); if (InheritanceUtil.isInheritorOrSelf(importClass, containingClass, true)) { addReference(member, reference); } } else { if (importTarget.equals(member)) { addReference(member, reference); } } } } }