private static @NotNull Runnable create(@NotNull Runnable delegate, @Nullable Object disposable) {
    if (disposable == null) {
      return delegate;
    }

    //noinspection SSBasedInspection
    if (delegate instanceof DumbAware) {
      return DumbAwareRunnable.create((Runnable & DumbAware)delegate, disposable);
    }

    if (delegate instanceof PossiblyDumbAware) {
      return PossiblyDumbAwareRunnable.create((Runnable & PossiblyDumbAware)delegate, disposable);
    }

    return new DisposeAwareRunnable<>(delegate, disposable);
  }
private static @NotNull Runnable create(@NotNull Runnable delegate, @Nullable Object disposable)