private void reportUnrecognizedRequires ( ) { for ( UnrecognizedRequire unrecognizedRequire : unrecognizedRequires ) { String legacyNamespace = unrecognizedRequire . legacyNamespace ; Node requireNode = unrecognizedRequire . requireNode ; boolean targetGoogModuleExists = rewriteState . containsModule ( legacyNamespace ) ; boolean targetLegacyScriptExists = rewriteState . legacyScriptNamespaces . contains ( legacyNamespace ) ; if ( ! targetGoogModuleExists && ! targetLegacyScriptExists ) { // The required thing was free to be either a goog.module() or a legacy script but neither // flavor of file provided the required namespace, so report a vague error. compiler . report ( JSError . make ( requireNode , MISSING_MODULE_OR_PROVIDE , legacyNamespace ) ) ; // Remove the require node so this problem isn't reported again in ProcessClosurePrimitives. if ( ! preserveSugar ) { Node changeScope = NodeUtil . getEnclosingChangeScopeRoot ( requireNode ) ; if ( changeScope == null ) { // It's already been removed; nothing to do. } else { compiler . reportChangeToChangeScope ( changeScope ) ; NodeUtil . getEnclosingStatement ( requireNode ) . detach ( ) ; } } continue ; } // The required thing actually was available somewhere in the program but just wasn't // available as early as the require statement would have liked. if ( unrecognizedRequire . mustBeOrdered ) { compiler . report ( JSError . make ( requireNode , LATE_PROVIDE_ERROR , legacyNamespace ) ) ; } } // Clear the queue so that repeated reportUnrecognizedRequires() invocations in hotswap compiles // only report new problems. unrecognizedRequires . clear ( ) ; }
Examines queue ed unrecognizedRequires to categorize and report them as either missing module missing namespace or late provide .