private static @Nullable PsiVariable appendStatements(PsiStatement anchor,
                                                        CommentTracker tracker,
                                                        boolean introduceVariable,
                                                        String replacementBlock, @NotNull ModPsiUpdater updater) {
    PsiElement parent = anchor.getParent();
    Project project = anchor.getProject();
    final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
    final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
    PsiBlockStatement codeBlock = (PsiBlockStatement)factory.createStatementFromText(replacementBlock, anchor);
    PsiStatement[] statements = codeBlock.getCodeBlock().getStatements();
    PsiVariable variable = null;
    for (int i = 0, length = statements.length; i < length; i++) {
      final PsiElement insertedStatement = parent.addBefore(tracker.markUnchanged(statements[i]), anchor);
      if (i == 0) {
        updater.moveCaretTo(insertedStatement);
        if (introduceVariable) {
          variable = (PsiVariable)((PsiDeclarationStatement)insertedStatement).getDeclaredElements()[0];
        }
      }
      codeStyleManager.reformat(insertedStatement);
    }
    return variable;
  }
private static @Nullable PsiVariable appendStatements(PsiStatement anchor,
                                                        CommentTracker tracker,
                                                        boolean introduceVariable,
                                                        String replacementBlock, @NotNull ModPsiUpdater updater)