private Tree < Row > findNext ( Tree < Row > pointer ) { if ( pointer . hasNext ( ) ) { // The given tree-node is not the last in its block. if ( Type . END . equals ( pointer . getNext ( ) . getContent ( ) . getType ( ) ) ) { return null ; } else { return pointer . getNext ( ) ; } } // The given tree-node was last in its block. Then we return the // the block closing tree-node. Tree < Row > parent = pointer . getParent ( ) ; Type parentType = parent . getContent ( ) . getType ( ) ; if ( Type . WHILE_DO_BEGIN . equals ( parentType ) ) { return parent . getNext ( ) ; } else if ( Type . DO_WHILE_BEGIN . equals ( parentType ) ) { return parent . getNext ( ) ; } if ( Type . BRANCH . equals ( parentType ) ) { Tree < Row > join = parent . getParent ( ) . getNext ( ) ; return join ; } else if ( Type . IF . equals ( parentType ) || Type . ELSE_IF . equals ( parentType ) || Type . ELSE . equals ( parentType ) ) { Tree < Row > endIf = findEndIf ( parent ) ; return endIf ; } else { throw new IllegalStateException ( "Unknown containting block type for row " + parent . getContent ( ) ) ; } }
Finds the following node which to create a transition to . Supports tree - nodes that are not the last in their block and those which are last .