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

    statements = SurroundWithUtil.moveDeclarationsOut(container, statements, false);
    if (statements.length == 0) {
      return;
    }

    String text = "{\n}";
    PsiBlockStatement blockStatement = (PsiBlockStatement)factory.createStatementFromText(text, null);
    blockStatement = (PsiBlockStatement)codeStyleManager.reformat(blockStatement);

    blockStatement = (PsiBlockStatement)addAfter(blockStatement, container, statements);

    PsiCodeBlock body = blockStatement.getCodeBlock();
    SurroundWithUtil.indentCommentIfNecessary(body, statements);
    addRangeWithinContainer(body, container, statements, true);
    container.deleteChildRange(statements[0], statements[statements.length - 1]);

    PsiElement firstChild = blockStatement.getFirstChild();
    if (firstChild != null) {
      TextRange range = firstChild.getTextRange();
      updater.select(TextRange.from(range.getEndOffset(), 0));
    }
  }
@Override
  protected void surroundStatements(@NotNull ActionContext context,
                                    @NotNull PsiElement container,
                                    @NotNull PsiElement @NotNull [] statements,
                                    @NotNull ModPsiUpdater updater)