void (@NotNull AnActionEvent e) { Presentation presentation = e.getPresentation(); VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); Project project = e.getProject(); boolean haveSmthToDo; if (project == null || file == null || file.isDirectory()) { haveSmthToDo = false; } else { // the action should also be available for files which have been auto-detected as text or as a particular language (IDEA-79574) haveSmthToDo = FileTypeManager.getInstance().getFileTypeByFileName(file.getNameSequence()) == FileTypes.UNKNOWN && !(file.getFileSystem() instanceof NonPhysicalFileSystem) && !ScratchRootType.getInstance().containsFile(file); haveSmthToDo |= ActionPlaces.isMainMenuOrActionSearch(e.getPlace()); } presentation.setVisible(haveSmthToDo || ActionPlaces.isMainMenuOrActionSearch(e.getPlace())); presentation.setEnabled(haveSmthToDo); }