private Node initTemplate ( Node templateFunctionNode ) { Node prepped = templateFunctionNode . cloneTree ( ) ; prepTemplatePlaceholders ( prepped ) ; Node body = prepped . getLastChild ( ) ; Node startNode ; if ( body . hasOneChild ( ) && body . getFirstChild ( ) . isExprResult ( ) ) { // When matching an expression, don't require it to be a complete // statement. startNode = body . getFirstFirstChild ( ) ; } else { startNode = body . getFirstChild ( ) ; } for ( int i = 0 ; i < templateLocals . size ( ) ; i ++ ) { // reserve space in the locals array. this . localVarMatches . add ( null ) ; } for ( int i = 0 ; i < templateParams . size ( ) ; i ++ ) { // reserve space in the params array. this . paramNodeMatches . add ( null ) ; } return startNode ; }
Prepare an template AST to use when performing matches .