protected void actionPerformedImpl(@NotNull AnActionEvent e,
                                       @NotNull Project project,
                                       @NotNull @NlsContexts.PopupTitle String title,
                                       @NotNull JBIterable<? extends VirtualFile> files) {
      ScratchFileService fileService = ScratchFileService.getInstance();
      PerFileMappings<Language> mapping = fileService.getScratchesMapping();
      VirtualFile[] filesCopy = VfsUtilCore.toVirtualFileArray(JBIterable.from((Iterable<? extends VirtualFile>)files).toList());
      Arrays.sort(filesCopy, (o1, o2) -> StringUtil.compare(o1.getName(), o2.getName(), !o1.isCaseSensitive()));
      ScratchImplUtil.buildLanguagesPopup(project, title)
        .onChosen(item -> {
          try {
            WriteCommandAction.writeCommandAction(project).withName(LangBundle.message("command.name.change.language")).run(
              () -> ScratchImplUtil.changeLanguageWithUndo(project, item, filesCopy, mapping));
          }
          catch (UnexpectedUndoException e1) {
            ExceptionUtil.rethrowUnchecked(e1);
          }
        })
        .buildPopup()
        .showCenteredInCurrentWindow(project);
    }
protected void actionPerformedImpl(@NotNull AnActionEvent e,
                                       @NotNull Project project,
                                       @NotNull @NlsContexts.PopupTitle String title,
                                       @NotNull JBIterable<? extends VirtualFile> files)