question: void updateBlocks ( int startLine , int endLine , int newLineCount ) { if ( mBlockEndLines == null ) { createBlocks ( ) ; return ; } int firstBlock = - 1 ; int lastBlock = - 1 ; for ( int i = 0 ; i < mNumberOfBlocks ; i ++ ) { if ( mBlockEndLines [ i ] >= startLine ) { firstBlock = i ; break ; } } for ( int i = firstBlock ; i < mNumberOfBlocks ; i ++ ) { if ( mBlockEndLines [ i ] >= endLine ) { lastBlock = i ; break ; } } final int lastBlockEndLine = mBlockEndLines [ lastBlock ] ; boolean createBlockBefore = startLine > ( firstBlock == 0 ? 0 : mBlockEndLines [ firstBlock - 1 ] + 1 ) ; boolean createBlock = newLineCount > 0 ; boolean createBlockAfter = endLine < mBlockEndLines [ lastBlock ] ; int numAddedBlocks = 0 ; if ( createBlockBefore ) numAddedBlocks ++ ; if ( createBlock ) numAddedBlocks ++ ; if ( createBlockAfter ) numAddedBlocks ++ ; final int numRemovedBlocks = lastBlock - firstBlock + 1 ; final int newNumberOfBlocks = mNumberOfBlocks + numAddedBlocks - numRemovedBlocks ; if ( newNumberOfBlocks == 0 ) { mBlockEndLines [ 0 ] = 0 ; mBlockIndices [ 0 ] = INVALID_BLOCK_INDEX ; mNumberOfBlocks = 1 ; return ; } if ( newNumberOfBlocks > mBlockEndLines . length ) { int [ ] blockEndLines = ArrayUtils . newUnpaddedIntArray ( Math . max ( mBlockEndLines . length * 2 , newNumberOfBlocks ) ) ; int [ ] blockIndices = new int [ blockEndLines . length ] ; System . arraycopy ( mBlockEndLines , 0 , blockEndLines , 0 , firstBlock ) ; System . arraycopy ( mBlockIndices , 0 , blockIndices , 0 , firstBlock ) ; System . arraycopy ( mBlockEndLines , lastBlock + 1 , blockEndLines , firstBlock + numAddedBlocks , mNumberOfBlocks - lastBlock - 1 ) ; System . arraycopy ( mBlockIndices , lastBlock + 1 , blockIndices , firstBlock + numAddedBlocks , mNumberOfBlocks - lastBlock - 1 ) ; mBlockEndLines = blockEndLines ; mBlockIndices = blockIndices ; } else { System . arraycopy ( mBlockEndLines , lastBlock + 1 , mBlockEndLines , firstBlock + numAddedBlocks , mNumberOfBlocks - lastBlock - 1 ) ; System . arraycopy ( mBlockIndices , lastBlock + 1 , mBlockIndices , firstBlock + numAddedBlocks , mNumberOfBlocks - lastBlock - 1 ) ; } mNumberOfBlocks = newNumberOfBlocks ; int newFirstChangedBlock ; final int deltaLines = newLineCount - ( endLine - startLine + 1 ) ; if ( deltaLines != 0 ) { newFirstChangedBlock = firstBlock + numAddedBlocks ; for ( int i = newFirstChangedBlock ; i < mNumberOfBlocks ; i ++ ) { mBlockEndLines [ i ] += deltaLines ; } } else { newFirstChangedBlock = mNumberOfBlocks ; } mIndexFirstChangedBlock = Math . min ( mIndexFirstChangedBlock , newFirstChangedBlock ) ; int blockIndex = firstBlock ; if ( createBlockBefore ) { mBlockEndLines [ blockIndex ] = startLine - 1 ; mBlockIndices [ blockIndex ] = INVALID_BLOCK_INDEX ; blockIndex ++ ; } if ( createBlock ) { mBlockEndLines [ blockIndex ] = startLine + newLineCount - 1 ; mBlockIndices [ blockIndex ] = INVALID_BLOCK_INDEX ; blockIndex ++ ; } if ( createBlockAfter ) { mBlockEndLines [ blockIndex ] = lastBlockEndLine + deltaLines ; mBlockIndices [ blockIndex ] = INVALID_BLOCK_INDEX ; } }
target:  This method is called every time the layout is reflowed after an edition. It updates the internal block data structure. The text is split in blocks of contiguous lines, with at least one block for the entire text. When a range of lines is edited, new blocks (from 0 to 3 depending on the overlap structure) will replace the set of overlapping blocks. Blocks are listed in order and are represented by their ending line number. An index is associated to each block (which will be used by display lists), this class simply invalidates the index of blocks overlapping a modification. This method is package private and not private so that it can be tested.