private static Node fuseIntoOneStatement ( Node parent , Node first , Node last ) { // Nothing to fuse if there is only one statement. if ( first . getNext ( ) == last ) { return first ; } // Step one: Create a comma tree that contains all the statements. Node commaTree = first . removeFirstChild ( ) ; Node next = null ; for ( Node cur = first . getNext ( ) ; cur != last ; cur = next ) { commaTree = fuseExpressionIntoExpression ( commaTree , cur . removeFirstChild ( ) ) ; next = cur . getNext ( ) ; parent . removeChild ( cur ) ; } // Step two: The last EXPR_RESULT will now hold the comma tree with all // the fused statements. first . addChildToBack ( commaTree ) ; return first ; }
Given a block fuse a list of statements with comma s .