public static <T> void runTask(Project project,
                                 NonBlockingReadAction<T> nonBlockingReadAction,
                                 Consumer<? super T> continuationConsumer,
                                 @Nullable @NlsContexts.ProgressTitle String progressTitle,
                                 Editor editor,
                                 boolean stopOnScrolling) {
    AtomicReference<CancellablePromise<?>> cancellablePromiseRef = new AtomicReference<>();
    Consumer<Boolean> stopAction =
      startProgressAndCreateStopAction(editor.getProject(), progressTitle, cancellablePromiseRef, editor);

    final VisibleAreaListener visibleAreaListener = new CancelProgressOnScrolling(cancellablePromiseRef);

    if (stopOnScrolling) {
      editor.getScrollingModel().addVisibleAreaListener(visibleAreaListener);
    }

    final Component focusOwner = getFocusOwner(project);

    cancellablePromiseRef.set(
      nonBlockingReadAction.finishOnUiThread(
        ModalityState.defaultModalityState(),
        continuation -> {
          CancellablePromise<?> promise = cancellablePromiseRef.get();
          if (promise != null && promise.isSucceeded()) {
            Component owner = getFocusOwner(project);
            if (Objects.equals(focusOwner, owner) || owner instanceof ParameterInfoController.WrapperPanel) {
              continuationConsumer.accept(continuation);
            }
          }
        })
        .expireWith(editor instanceof EditorImpl ? ((EditorImpl) editor).getDisposable() : project)
        .submit(AppExecutorUtil.getAppExecutorService())
        .onProcessed(ignore -> {
          stopAction.accept(false);
          if (stopOnScrolling) {
            editor.getScrollingModel().removeVisibleAreaListener(visibleAreaListener);
          }
        }));
  }
public static <T> void runTask(Project project,
                                 NonBlockingReadAction<T> nonBlockingReadAction,
                                 Consumer<? super T> continuationConsumer,
                                 @Nullable @NlsContexts.ProgressTitle String progressTitle,
                                 Editor editor,
                                 boolean stopOnScrolling)