PsiNamedElement () { PsiElement element = myFile.findElementAt(myEditor.getCaretModel().getOffset()); PsiNamedElement namedElement = PsiTreeUtil.getParentOfType(element, PsiNamedElement.class); assertTrue("Cannot find element in caret", LanguageFindUsages.canFindUsagesFor(namedElement)); return namedElement; }