private void addStubsForUndeclaredProperties ( Name n , String alias , Node parent , Node addAfter ) { checkState ( n . canCollapseUnannotatedChildNames ( ) , n ) ; checkArgument ( NodeUtil . isStatementBlock ( parent ) , parent ) ; checkNotNull ( addAfter ) ; if ( n . props == null ) { return ; } for ( Name p : n . props ) { if ( p . needsToBeStubbed ( ) ) { String propAlias = appendPropForAlias ( alias , p . getBaseName ( ) ) ; Node nameNode = IR . name ( propAlias ) ; Node newVar = IR . var ( nameNode ) . useSourceInfoIfMissingFromForTree ( addAfter ) ; parent . addChildAfter ( newVar , addAfter ) ; addAfter = newVar ; compiler . reportChangeToEnclosingScope ( newVar ) ; // Determine if this is a constant var by checking the first // reference to it. Don't check the declaration, as it might be null. if ( p . getFirstRef ( ) . getNode ( ) . getLastChild ( ) . getBooleanProp ( Node . IS_CONSTANT_NAME ) ) { nameNode . putBooleanProp ( Node . IS_CONSTANT_NAME , true ) ; compiler . reportChangeToEnclosingScope ( nameNode ) ; } } } }
Adds global variable stubs for any properties of a global name that are only set in a local scope or read but never set .