PsiReference () { PsiElement element = getElement(); if (element == null) return null; final ProperTextRange rangeInElement = getRangeInElement(); PsiReference reference = rangeInElement != null ? element.findReferenceAt(rangeInElement.getStartOffset()) : element.getReference(); return reference != null && reference.getRangeInElement().equals(rangeInElement) ? reference : null; }