@RequiresEdt
  public static @NotNull JShellHandler create(@NotNull Project project,
                                              @NotNull VirtualFile contentFile,
                                              @Nullable Module module,
                                              @Nullable Sdk alternateSdk) throws Exception {
    final OSProcessHandler processHandler = launchProcess(project, module, alternateSdk);

    final String title = JShellDiagnostic.TITLE + " " + contentFile.getNameWithoutExtension();

    final ConsoleViewImpl consoleView = new MyConsoleView(project);
    final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, processHandler, new JPanel(new BorderLayout()), title);
    final JShellHandler jshellHandler = new JShellHandler(project, descriptor, consoleView, contentFile, processHandler);

    // init classpath for evaluation
    final Set<String> cp = new LinkedHashSet<>();
    final Computable<OrderEnumerator> orderEnumerator = module != null ?
                                                        () -> ModuleRootManager.getInstance(module).orderEntries() :
                                                        () -> ProjectRootManager.getInstance(project).orderEntries();
    ApplicationManager.getApplication().runReadAction(() -> {
      cp.addAll(orderEnumerator.compute().librariesOnly().recursively().withoutSdk().getPathsList().getPathList());
    });
    if (!cp.isEmpty()) {
      jshellHandler.myEvalClasspathRef.set(cp);
    }

    // must call getComponent before createConsoleActions()
    final JComponent consoleViewComponent = consoleView.getComponent();

    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    //actionGroup.add(new BuildAndRestartConsoleAction(module, project, defaultExecutor, descriptor, restarter(project, contentFile)));
    //actionGroup.addSeparator();
    actionGroup.addAll(consoleView.createConsoleActions());
    actionGroup.add(new CloseAction(EXECUTOR, descriptor, project) {
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        jshellHandler.stop();
        if (!processHandler.waitFor(10000)) {
          processHandler.destroyProcess();
        }
        super.actionPerformed(e);
      }
    });

    final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("JShellHandler", actionGroup, false);
    toolbar.setTargetComponent(consoleViewComponent);

    final JComponent ui = descriptor.getComponent();
    ui.add(consoleViewComponent, BorderLayout.CENTER);
    ui.add(toolbar.getComponent(), BorderLayout.WEST);

    processHandler.startNotify();

    RunContentManager.getInstance(project).showRunContent(EXECUTOR, descriptor);
    return jshellHandler;
  }
@RequiresEdt
  public static @NotNull JShellHandler create(@NotNull Project project,
                                              @NotNull VirtualFile contentFile,
                                              @Nullable Module module,
                                              @Nullable Sdk alternateSdk)