@Override public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement reference) {
    PsiElement referencedElement = reference.resolve();
    if (referencedElement instanceof PsiClass referencedClass) {
      if (PsiTreeUtil.isAncestor(myClass, referencedClass, true)) {
        visitClassMemberReferenceElement(referencedClass, reference);
      }
      else if (isPartOf(myClass, referencedClass.getContainingClass())) {
        visitClassMemberReferenceElement(referencedClass, reference);
      }
    }
  }
@Override public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement reference)