Class ModuleMetadataMap
java.lang.Object
com.google.javascript.jscomp.modules.ModuleMetadataMap
Contains metadata around modules (or scripts) that is useful for checking imports / requires.
TODO(johnplaisted): There's an opportunity for reuse here in ClosureRewriteModules, which would involve putting this in some common location. Currently this is only used as a helper class for Es6RewriteModules. CompilerInput already has some (not all) of this information but it is not always populated. It may also be ideal to include CommonJS here too as ES6 modules can import them. That would allow decoupling of how these modules are written; right now Es6RewriteModule only checks this for goog.requires and goog: imports, not for ES6 path imports.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Struct containing basic information about a module/script including its type and goog namespaces.static enum
Various types of Javascript modules and scripts that can be found in the JS Compiler. -
Constructor Summary
ConstructorsConstructorDescriptionModuleMetadataMap
(Map<String, ModuleMetadataMap.ModuleMetadata> modulesByPath, Map<String, ModuleMetadataMap.ModuleMetadata> modulesByGoogNamespace) -
Method Summary
Modifier and TypeMethodDescriptionstatic ModuleMetadataMap
com.google.common.collect.ImmutableSet
<ModuleMetadataMap.ModuleMetadata> The set of all modules across both maps.com.google.common.collect.ImmutableMap
<String, ModuleMetadataMap.ModuleMetadata> com.google.common.collect.ImmutableMap
<String, ModuleMetadataMap.ModuleMetadata>
-
Constructor Details
-
ModuleMetadataMap
public ModuleMetadataMap(Map<String, ModuleMetadataMap.ModuleMetadata> modulesByPath, Map<String, ModuleMetadataMap.ModuleMetadata> modulesByGoogNamespace)
-
-
Method Details
-
getModulesByPath
public com.google.common.collect.ImmutableMap<String,ModuleMetadataMap.ModuleMetadata> getModulesByPath()- Returns:
- map from module path to module. These modules represent files and thus
ModuleMetadataMap.ModuleMetadata.googNamespaces()
contains all Closure namespaces in the file. These are not the same modules from ModuleMetadataMap#getModulesByGoogNamespace(). It is not valid to call ModuleRenaming#getGlobalName(ModuleMetadata, String) onModuleMetadataMap.ModuleType.GOOG_PROVIDE
modules from this map that have more than one Closure namespace as it is ambiguous.
-
getModulesByGoogNamespace
public com.google.common.collect.ImmutableMap<String,ModuleMetadataMap.ModuleMetadata> getModulesByGoogNamespace()- Returns:
- map from Closure namespace to module. These modules represent the Closure namespace and
thus
ModuleMetadataMap.ModuleMetadata.googNamespaces()
will have size 1. As a result, it is valid to call ModuleRenaming#getGlobalName(ModuleMetadata, String) on these modules. These are not the same modules fromgetModulesByPath()
.
-
getAllModuleMetadata
public com.google.common.collect.ImmutableSet<ModuleMetadataMap.ModuleMetadata> getAllModuleMetadata()The set of all modules across both maps.goog.loadModule
calls have no associated path, and non-Closure modules have no namespaces. -
emptyForTesting
-