private AbstractBlockWrapper buildFrom(final Block rootBlock,
                                         final int index,
                                         final @Nullable CompositeBlockWrapper parent,
                                         @Nullable WrapImpl currentWrapParent,
                                         final @Nullable Block parentBlock)
  {
    final WrapImpl wrap = (WrapImpl)rootBlock.getWrap();
    if (wrap != null) {
      wrap.registerParent(currentWrapParent);
      currentWrapParent = wrap;
    }

    TextRange textRange = rootBlock.getTextRange();
    final int blockStartOffset = textRange.getStartOffset();

    if (parent != null) {
      ASSERT.checkChildRange(new TextRange(parent.getStartOffset(), parent.getEndOffset()), textRange, myModel);
    }

    myCurrentWhiteSpace.changeEndOffset(blockStartOffset, myModel, myOptions);

    collectAlignments(rootBlock);

    if (isInsideFormattingRanges(textRange) || shouldCollectAlignmentsAround(textRange)) {
      final List<Block> subBlocks = rootBlock.getSubBlocks();
      if (subBlocks.isEmpty()) {
        final AbstractBlockWrapper wrapper = buildLeafBlock(rootBlock, parent, false, index, parentBlock);
        if (!subBlocks.isEmpty()) {
          wrapper.setIndent((IndentImpl)subBlocks.get(0).getIndent());
        }
        return wrapper;
      }
      return buildCompositeBlock(rootBlock, parent, index, currentWrapParent);
    }
    else {
      return buildLeafBlock(rootBlock, parent, true, index, parentBlock);
    }
  }
private AbstractBlockWrapper buildFrom(final Block rootBlock,
                                         final int index,
                                         final @Nullable CompositeBlockWrapper parent,
                                         @Nullable WrapImpl currentWrapParent,
                                         final @Nullable Block parentBlock)