@Nullable
  public static TextRange surround(@NotNull Surrounder surrounder,
                                   @NotNull Editor editor,
                                   @NotNull PsiElement expr) {
    Project project = expr.getProject();
    PsiElement[] elements = {expr};
    if (surrounder instanceof ModCommandSurrounder modCommandSurrounder) {
      ActionContext context = ActionContext.from(editor, expr.getContainingFile());
      ReadAction.nonBlocking(
          () -> modCommandSurrounder.isApplicable(elements) ? modCommandSurrounder.surroundElements(context, elements) : null)
        .expireWhen(() -> project.isDisposed() || editor.isDisposed())
        .finishOnUiThread(ModalityState.nonModal(), command -> {
          if (command == null) {
            showErrorHint(project, editor);
          }
          else {
            CommandProcessor.getInstance().executeCommand(
              project, () -> ModCommandExecutor.getInstance().executeInteractively(context, command, editor),
              CodeInsightBundle.message("command.expand.postfix.template"),
              PostfixLiveTemplate.POSTFIX_TEMPLATE_ID);
          }
        })
        .submit(AppExecutorUtil.getAppExecutorService());
      return null;
    }
    if (surrounder.isApplicable(elements)) {
      return surrounder.surroundElements(project, editor, elements);
    }
    else {
      showErrorHint(project, editor);
    }
    return null;
  }
@Nullable
  public static TextRange surround(@NotNull Surrounder surrounder,
                                   @NotNull Editor editor,
                                   @NotNull PsiElement expr)