Class ModuleMetadataMap
- java.lang.Object
-
- com.google.javascript.jscomp.modules.ModuleMetadataMap
-
public final class ModuleMetadataMap extends java.lang.Object
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 Classes Modifier and Type Class Description static class
ModuleMetadataMap.ModuleMetadata
Struct containing basic information about a module/script including its type and goog namespaces.static class
ModuleMetadataMap.ModuleType
Various types of Javascript modules and scripts that can be found in the JS Compiler.
-
Constructor Summary
Constructors Constructor Description ModuleMetadataMap(java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByPath, java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByGoogNamespace)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ModuleMetadataMap
emptyForTesting()
com.google.common.collect.ImmutableSet<ModuleMetadataMap.ModuleMetadata>
getAllModuleMetadata()
The set of all modules across both maps.com.google.common.collect.ImmutableMap<java.lang.String,ModuleMetadataMap.ModuleMetadata>
getModulesByGoogNamespace()
com.google.common.collect.ImmutableMap<java.lang.String,ModuleMetadataMap.ModuleMetadata>
getModulesByPath()
-
-
-
Constructor Detail
-
ModuleMetadataMap
public ModuleMetadataMap(java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByPath, java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByGoogNamespace)
-
-
Method Detail
-
getModulesByPath
public com.google.common.collect.ImmutableMap<java.lang.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<java.lang.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
public static ModuleMetadataMap emptyForTesting()
-
-