private static @NotNull PositionInfo getPositionInfo(PsiCodeBlock body) {
    PsiElement firstBodyElement = body.getFirstBodyElement();
    PsiElement l = firstBodyElement;
    while (l instanceof PsiWhiteSpace) l = l.getNextSibling();
    if (l == null) l = body;
    PsiElement lastBodyElement = body.getLastBodyElement();
    PsiElement r = lastBodyElement;
    while (r instanceof PsiWhiteSpace) r = r.getPrevSibling();
    if (r == null) r = body;

    int start = l.getTextRange().getStartOffset();
    int end = r.getTextRange().getEndOffset();

    boolean adjustLineIndent = false;

    // body is whitespace
    if (start > end &&
        firstBodyElement == lastBodyElement &&
        firstBodyElement instanceof PsiWhiteSpaceImpl
    ) {
      CharSequence chars = ((PsiWhiteSpaceImpl)firstBodyElement).getChars();
      if (chars.length() > 1 && chars.charAt(0) == '\n' && chars.charAt(1) == '\n') {
        start = end = firstBodyElement.getTextRange().getStartOffset() + 1;
        adjustLineIndent = true;
      }
    }
    return new PositionInfo(start, end, adjustLineIndent);
  }
private static @NotNull PositionInfo getPositionInfo(PsiCodeBlock body)