private static void collapseBlock(List<? super FoldingDescriptor> descriptors, @NotNull PsiElement psi) {
    ASTNode node = psi.getNode();
    boolean collapse = isCollapseBlock(node);
    if (psi instanceof GrCodeBlock) {
      final int lineFeedCount = StringUtil.countChars(psi.getText(), '\n');
      if (lineFeedCount <= 2) {
        final PsiElement lbrace = ((GrCodeBlock)psi).getLBrace();
        final PsiElement rbrace = ((GrCodeBlock)psi).getRBrace();
        if (lbrace != null && rbrace != null) {
          final PsiElement next = lbrace.getNextSibling();
          final PsiElement prev = rbrace.getPrevSibling();
          if (PsiImplUtil.isWhiteSpaceOrNls(next) && PsiImplUtil.isWhiteSpaceOrNls(prev)) {
            final FoldingGroup group = FoldingGroup.newGroup("block_group");
            descriptors.add(new FoldingDescriptor(node, new TextRange(lbrace.getTextRange().getStartOffset(),
                                                                      next.getTextRange().getEndOffset()),
                                                  group, "{", collapse, Collections.emptySet()));
            descriptors.add(new FoldingDescriptor(node, new TextRange(prev.getTextRange().getStartOffset(),
                                                                      rbrace.getTextRange().getEndOffset()),
                                                  group, "}", collapse, Collections.emptySet()));
            return;
          }
        }
      }
    }
    descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, "{...}", collapse, Collections.emptySet()));
  }
private static void collapseBlock(List<? super FoldingDescriptor> descriptors, @NotNull PsiElement psi)