static void chooseScriptEngineAndRun(@NotNull AnActionEvent e,
                                       @NotNull List<? extends IdeScriptEngineManager.EngineInfo> infos,
                                       @NotNull Consumer<? super IdeScriptEngineManager.EngineInfo> onChosen) {
    if (infos.size() == 1) {
      onChosen.consume(infos.iterator().next());
      return;
    }

    List<? extends AnAction> actions = JBIterable.from(infos).map(engineInfo -> {
      String lang = engineInfo.languageName;
      String eng = engineInfo.engineName;
      if (StringUtil.toLowerCase(lang).equals(lang)) lang = StringUtil.capitalize(lang);
      if (StringUtil.toLowerCase(eng).equals(eng)) eng = StringUtil.capitalize(eng);
      String name = lang + " (" + eng + ")";
      PluginDescriptor plugin = engineInfo.plugin;
      String description = LangBundle.message("action.engine.description", lang, eng,
                                              plugin == null ? "" : LangBundle.message("action.plugin.description") + plugin.getName());
      return new DumbAwareAction(name, description, null) {
        @Override
        public void actionPerformed(@NotNull AnActionEvent e1) {
          onChosen.consume(engineInfo);
        }
      };
    })
      .sort(Comparator.comparing(o -> o.getTemplatePresentation().getText()))
      .toList();
    DefaultActionGroup actionGroup = new DefaultActionGroup(actions);
    JBPopupFactory.getInstance().createActionGroupPopup(
      ExecutionBundle.message("popup.title.script.engine"), actionGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, false)
      .showInBestPositionFor(e.getDataContext());
  }
static void chooseScriptEngineAndRun(@NotNull AnActionEvent e,
                                       @NotNull List<? extends IdeScriptEngineManager.EngineInfo> infos,
                                       @NotNull Consumer<? super IdeScriptEngineManager.EngineInfo> onChosen)