void (@NotNull AnActionEvent e) { Project project = e.getProject(); VirtualFile virtualFile = project == null ? null : e.getData(CommonDataKeys.VIRTUAL_FILE); Document document = virtualFile == null ? null : FileDocumentManager.getInstance().getDocument(virtualFile); e.getPresentation().setEnabled(document != null); }