void (@NotNull AnActionEvent e) { DataContext dataContext = e.getDataContext(); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); e.getPresentation().setEnabled(e.getProject() != null && editor != null && editor.getSelectionModel().hasSelection() && !EditorUtil.contextMenuInvokedOutsideOfSelection(e)); }