private static <T> void computeOnEDT(@NotNull Function<? super Obsolescent, ? extends T> function, @NotNull AsyncPromise<T> promise) {
    assert EventQueue.isDispatchThread();
    T result;
    try {
      result = function.apply((Obsolescent)promise::isDone);
    }
    catch (IndexNotReadyException | ProcessCanceledException exception) {
      getScheduledExecutorInstance().schedule(() -> computeOnEDT(function, promise), 10, MILLISECONDS);
      return; // recalculate later
    }
    catch (Throwable error) {
      promise.setError(error);
      return;
    }
    promise.setResult(result);
  }
private static <T> void computeOnEDT(@NotNull Function<? super Obsolescent, ? extends T> function, @NotNull AsyncPromise<T> promise)