private @NotNull ConsoleView createAndAttachConsoleInEDT(@NotNull Project project, ProcessHandler processHandler, Executor executor)
    throws ExecutionException {
    final Ref<Object> consoleRef = Ref.create();
    ApplicationManager.getApplication().invokeAndWait(
      () -> {
        try {
          consoleRef.set(createAndAttachConsole(project, processHandler, executor));
        }
        catch (ExecutionException | RuntimeException e) {
          consoleRef.set(e);
        }
      });

    if (consoleRef.get() instanceof ExecutionException) {
      throw (ExecutionException)consoleRef.get();
    }
    else if (consoleRef.get() instanceof RuntimeException) throw (RuntimeException)consoleRef.get();

    return (ConsoleView)consoleRef.get();
  }
private @NotNull ConsoleView createAndAttachConsoleInEDT(@NotNull Project project, ProcessHandler processHandler, Executor executor)