private static int findClosingBrace(GrCodeBlock block, int startOffset) {
    PsiElement rbrace = block.getRBrace();
    if (rbrace == null) return block.getTextRange().getEndOffset();

    while (PsiImplUtil.isWhiteSpaceOrNls(rbrace.getPrevSibling()) && rbrace.getPrevSibling().getTextRange().getStartOffset() > startOffset) {
      rbrace = rbrace.getPrevSibling();
    }

    return rbrace.getTextRange().getStartOffset();
  }
private static int findClosingBrace(GrCodeBlock block, int startOffset)