@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 = "for(a;b;c){\n}";
    PsiForStatement forStatement = (PsiForStatement)factory.createStatementFromText(text, null);
    forStatement = (PsiForStatement)codeStyleManager.reformat(forStatement);

    forStatement = (PsiForStatement)addAfter(forStatement, container, statements);

    PsiStatement body = forStatement.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]);

    forStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(forStatement);
    PsiStatement initialization = forStatement.getInitialization();
    if (initialization == null) return;
    TextRange range1 = initialization.getTextRange();

    PsiStatement update = forStatement.getUpdate();
    if (update == null) return;
    TextRange range3 = update.getTextRange();
    update.getContainingFile().getFileDocument().deleteString(range1.getStartOffset(), range3.getEndOffset());
    updater.select(TextRange.from(range1.getStartOffset(), 0));
  }
@Override
  protected void surroundStatements(@NotNull ActionContext context,
                                    @NotNull PsiElement container,
                                    @NotNull PsiElement @NotNull [] statements,
                                    @NotNull ModPsiUpdater updater)