private void processRequireCall ( NodeTraversal t , Node n , Node parent ) { Node left = n . getFirstChild ( ) ; Node arg = left . getNext ( ) ; String method = left . getFirstChild ( ) . getNext ( ) . getString ( ) ; if ( verifyLastArgumentIsString ( left , arg ) ) { String ns = arg . getString ( ) ; ProvidedName provided = providedNames . get ( ns ) ; if ( provided == null || ! provided . isExplicitlyProvided ( ) ) { unrecognizedRequires . add ( new UnrecognizedRequire ( n , ns , method . equals ( "requireType" ) ) ) ; } else { JSModule providedModule = provided . explicitModule ; if ( ! provided . isFromExterns ( ) ) { checkNotNull ( providedModule , n ) ; JSModule module = t . getModule ( ) ; // A cross-chunk goog.require must match a goog.provide in an earlier chunk. However, a // cross-chunk goog.requireType is allowed to match a goog.provide in a later chunk. if ( module != providedModule && ! moduleGraph . dependsOn ( module , providedModule ) && ! method . equals ( "requireType" ) ) { compiler . report ( JSError . make ( n , ProcessClosurePrimitives . XMODULE_REQUIRE_ERROR , ns , providedModule . getName ( ) , module . getName ( ) ) ) ; } } } maybeAddNameToSymbolTable ( left ) ; maybeAddStringToSymbolTable ( arg ) ; // Requires should be removed before further processing. // Some clients run closure pass multiple times, first with // the checks for broken requires turned off. In these cases, we // allow broken requires to be preserved by the first run to // let them be caught in the subsequent run. if ( ! preserveGoogProvidesAndRequires && ( provided != null || requiresLevel . isOn ( ) ) ) { requiresToBeRemoved . add ( parent ) ; } } }
Handles a goog . require or goog . requireType call .