private static <T> @NotNull Future<T> submit(@NotNull ThrowableComputable<? extends T, ?> computable, ModalityState modalityState) {
    CompletableFuture<T> future = new CompletableFuture<>();
    ApplicationManager.getApplication().invokeLaterOnWriteThread(() -> {
      try {
        future.complete(computable.compute());
      }
      catch (Throwable t) {
        future.completeExceptionally(t);
      }
    }, modalityState);
    return future;
  }
private static <T> @NotNull Future<T> submit(@NotNull ThrowableComputable<? extends T, ?> computable, ModalityState modalityState)