PsiElement (@NotNull AnActionEvent e) { Editor editor = e.getData(EDITOR); PsiFile file = e.getData(PSI_FILE); if (editor == null || file == null) return null; int offset = editor.getCaretModel().getOffset(); PsiElement at = file.findElementAt(offset); if (at instanceof PsiWhiteSpace && offset > 0) { PsiElement prev = file.findElementAt(offset - 1); if (!(prev instanceof PsiWhiteSpace)) return prev; } return at; }