PsiReference () { final PsiClass scope = getScope(); final PsiElement element = getNameElement(); if (scope == null || element == null) return new MyReference(PsiElement.EMPTY_ARRAY); PsiReference psiReference = getReferenceInScope(scope, element); if (psiReference != null) return psiReference; PsiClass classScope; PsiClass containingClass = scope.getContainingClass(); while (containingClass != null) { classScope = containingClass; psiReference = getReferenceInScope(classScope, element); if (psiReference != null) return psiReference; containingClass = classScope.getContainingClass(); } return new MyReference(PsiElement.EMPTY_ARRAY); }