SmartPsiFileRange (@NotNull PsiReference reference) { PsiElement element = reference.getElement(); int offset = element.getTextRange().getStartOffset() + reference.getRangeInElement().getStartOffset(); PsiFile file = element.getContainingFile(); if (areReferencesEquivalent(reference, file.findReferenceAt(offset))) { return SmartPointerManager.getInstance(element.getProject()).createSmartPsiFileRangePointer(file, TextRange.from(offset, 0)); } return null; }