public static <T extends PsiElement> void showChooser(@NotNull Editor editor,
                                                        @NotNull List<? extends T> expressions,
                                                        @NotNull Pass<? super T> callback,
                                                        @NotNull Function<? super T, String> renderer,
                                                        @NotNull @NlsContexts.PopupTitle String title,
                                                        int selection,
                                                        @NotNull NotNullFunction<? super PsiElement, ? extends TextRange> ranger) {

    if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
      List<MyIntroduceTarget<T>> targets = ContainerUtil.map(expressions, t -> new MyIntroduceTarget<>(t, ranger.fun(t), renderer.fun(t)));
      showIntroduceTargetChooser(editor, targets, target -> callback.accept(target.getPlace()), title, selection);
    }
    else {
      ReadAction.nonBlocking(() -> ContainerUtil.map(expressions, t -> new MyIntroduceTarget<>(t, ranger.fun(t), renderer.fun(t))))
        .finishOnUiThread(ModalityState.nonModal(), targets ->
          showIntroduceTargetChooser(editor, targets, target -> callback.accept(target.getPlace()), title, selection))
        .expireWhen(() -> editor.isDisposed())
        .submit(AppExecutorUtil.getAppExecutorService());
    }
  }
public static <T extends PsiElement> void showChooser(@NotNull Editor editor,
                                                        @NotNull List<? extends T> expressions,
                                                        @NotNull Pass<? super T> callback,
                                                        @NotNull Function<? super T, String> renderer,
                                                        @NotNull @NlsContexts.PopupTitle String title,
                                                        int selection,
                                                        @NotNull NotNullFunction<? super PsiElement, ? extends TextRange> ranger)