public Selector resolve ( Selector tree , Resolver resolver , PositionAssigner positionAssigner ) { if ( tree instanceof Identifier ) { Identifier id = ( Identifier ) tree ; // The subtree to resolve is an Identifier. Resolve the Identifier. return resolver . resolve ( id , positionAssigner ) ; } else if ( tree . getNumIds ( ) > 0 ) { Operator oper = ( Operator ) tree ; // The subtree to resolve is an Operator, under which there are some Identifiers. for ( int i = 0 ; i < oper . getOperands ( ) . length ; i ++ ) oper . setOperand ( i , resolve ( oper . getOperands ( ) [ i ] , resolver , positionAssigner ) ) ; oper . assignType ( ) ; } // else tree is a literal and not modified return tree ; }
Walks a Selector tree and resolves all the Identifiers