ClassReferencePointer (@NotNull PsiJavaCodeReferenceElement ref) { PsiTypeElement rootType = getRootTypeElement(ref); if (rootType != null) { PsiElement parent = rootType.getParent(); if (parent instanceof PsiMethod || parent instanceof PsiVariable) { int index = allReferencesInside(rootType).indexOf(ref::equals); if (index < 0) throw new AssertionError(rootType.getClass()); return computeFromTypeOwner(parent, index, new WeakReference<>(ref)); } } return ClassReferencePointer.constant(ref); }