PsiElement (PsiFile psiFile, TextRange declarationRange) { PsiElement element = psiFile.findElementAt(declarationRange.getStartOffset()); while (element != null && !element.getTextRange().contains(declarationRange)) { element = element.getParent(); } if (element == null || !element.getTextRange().equals(declarationRange)) return null; return element; }