boolean (@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { Project project = editor.getProject(); if (project == null) return false; Document document = editor.getDocument(); if (!(document instanceof DocumentEx)) return false; PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document); if (file == null) return false; PsiElement[] elementList = getElementList(file, caret.getSelectionStart(), caret.getSelectionEnd()); return elementList != null; }