@Override
  protected void surroundStatements(@NotNull ActionContext context,
                                    @NotNull PsiElement container,
                                    @NotNull PsiElement @NotNull [] statements,
                                    @NotNull ModPsiUpdater updater) throws IncorrectOperationException {
    Project project = context.project();
    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);

    statements = SurroundWithUtil.moveDeclarationsOut(container, statements, true);
    if (statements.length == 0) return;

    @NonNls String text = "while(true){\n}";
    PsiWhileStatement whileStatement = (PsiWhileStatement)factory.createStatementFromText(text, null);
    whileStatement = (PsiWhileStatement)codeStyleManager.reformat(whileStatement);

    whileStatement = (PsiWhileStatement)addAfter(whileStatement, container, statements);

    PsiStatement body = whileStatement.getBody();
    if (!(body instanceof PsiBlockStatement block)) return;
    PsiCodeBlock bodyBlock = block.getCodeBlock();
    SurroundWithUtil.indentCommentIfNecessary(bodyBlock, statements);
    addRangeWithinContainer(bodyBlock, container, statements, false);
    container.deleteChildRange(statements[0], statements[statements.length - 1]);

    PsiExpression condition = whileStatement.getCondition();
    if (condition != null) {
      updater.select(condition);
    }
  }
@Override
  protected void surroundStatements(@NotNull ActionContext context,
                                    @NotNull PsiElement container,
                                    @NotNull PsiElement @NotNull [] statements,
                                    @NotNull ModPsiUpdater updater)