public static boolean tryMergeBlock ( Node block , boolean alwaysMerge ) { checkState ( block . isBlock ( ) ) ; Node parent = block . getParent ( ) ; boolean canMerge = alwaysMerge || canMergeBlock ( block ) ; // Try to remove the block if its parent is a block/script or if its // parent is label and it has exactly one child. if ( isStatementBlock ( parent ) && canMerge ) { Node previous = block ; while ( block . hasChildren ( ) ) { Node child = block . removeFirstChild ( ) ; parent . addChildAfter ( child , previous ) ; previous = child ; } parent . removeChild ( block ) ; return true ; } else { return false ; } }
Merge a block with its parent block .