void (@NotNull AnActionEvent e) { Project project = e.getProject(); JBIterable<VirtualFile> files = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)); if (project == null || files.isEmpty()) { e.getPresentation().setEnabledAndVisible(false); return; } Condition<VirtualFile> isScratch = fileFilter(project); if (!files.filter(not(isScratch)).isEmpty()) { e.getPresentation().setEnabledAndVisible(false); return; } FileTypeManager fileTypeManager = FileTypeManager.getInstance(); Set<String> languages = files .filter(isScratch) .map(file -> { // language substitution is not invoked for AbstractFileType (non-LanguageFileType) Language language = LanguageUtil.getFileLanguage(file) == null ? null : fileLanguage(project, file); if (language != null) return language.getDisplayName(); return fileTypeManager.getFileTypeByFileName(file.getName()).getDisplayName(); }) .toSet(); String langName = languages.size() == 1 ? languages.iterator().next() : LangBundle.message("scratch.file.actions.0.different.languages.number", languages.size()); e.getPresentation().setText(getChangeLanguageActionName(langName)); e.getPresentation().setEnabledAndVisible(true); }