private static void fixLoopBody(@NotNull Editor editor,
                                  @NotNull AbstractBasicJavaSmartEnterProcessor processor,
                                  @NotNull ASTNode loop,
                                  @NotNull Document doc,
                                  @Nullable ASTNode body) {
    ASTNode eltToInsertAfter = BasicJavaAstTreeUtil.getRParenth(loop);
    PsiElement loopElement = BasicJavaAstTreeUtil.toPsi(loop);
    if (body != null && eltToInsertAfter != null) {
      PsiElement bodyElement = BasicJavaAstTreeUtil.toPsi(body);
      if (loopElement != null && bodyElement != null && bodyIsIndented(loopElement, bodyElement)) {
        int endOffset = body.getTextRange().getEndOffset();
        doc.insertString(endOffset, "\n");
        processor.insertCloseBrace(editor, endOffset + 1);
        int offset = eltToInsertAfter.getTextRange().getEndOffset();
        doc.insertString(offset, "{");
        editor.getCaretModel().moveToOffset(endOffset + "{".length());
        processor.setSkipEnter(true);
        processor.reformat(loopElement);
        return;
      }
    }
    boolean needToClose = false;
    if (eltToInsertAfter == null) {
      eltToInsertAfter = loop;
      needToClose = true;
    }
    int offset = eltToInsertAfter.getTextRange().getEndOffset();
    if (needToClose) {
      if (BasicJavaAstTreeUtil.getLParenth(loop) == null) {
        doc.insertString(offset, "()");
        offset += 2;
      } else {
        doc.insertString(offset, ")");
        offset++;
      }
    }
    processor.insertBraces(editor, offset);
    editor.getCaretModel().moveToOffset(offset);
  }
private static void fixLoopBody(@NotNull Editor editor,
                                  @NotNull AbstractBasicJavaSmartEnterProcessor processor,
                                  @NotNull ASTNode loop,
                                  @NotNull Document doc,
                                  @Nullable ASTNode body)