void (@NotNull AnActionEvent e) { DataContext dataContext = e.getDataContext(); e.getPresentation().setEnabled(false); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (editor == null) return; Project project = editor.getProject(); PsiFile psiFile = project == null ? null : PsiUtilBase.getPsiFileInEditor(editor, project); if (psiFile == null) return; e.getPresentation().setEnabled(true); }