PsiElement (Editor editor, PsiFile file) { int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); PsiElement parent = element != null ? element.getParent() : null; if (isText(parent)) return parent; element = file.findElementAt(offset - 1); parent = element != null ? element.getParent() : null; if (isText(parent)) return parent; return null; }