public final class ModuleMetadataMap
extends java.lang.Object
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.
Modifier and Type | Class and 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 and Description |
---|
ModuleMetadataMap(java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByPath,
java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByGoogNamespace) |
Modifier and Type | Method and 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() |
public ModuleMetadataMap(java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByPath, java.util.Map<java.lang.String,ModuleMetadataMap.ModuleMetadata> modulesByGoogNamespace)
public com.google.common.collect.ImmutableMap<java.lang.String,ModuleMetadataMap.ModuleMetadata> getModulesByPath()
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) on ModuleMetadataMap.ModuleType.GOOG_PROVIDE
modules from this map that have more than one Closure namespace as
it is ambiguous.public com.google.common.collect.ImmutableMap<java.lang.String,ModuleMetadataMap.ModuleMetadata> getModulesByGoogNamespace()
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 from getModulesByPath()
.public com.google.common.collect.ImmutableSet<ModuleMetadataMap.ModuleMetadata> getAllModuleMetadata()
goog.loadModule
calls have no associated path, and non-Closure modules have no
namespaces.
public static ModuleMetadataMap emptyForTesting()
Copyright © 2009-2020 Google. All Rights Reserved.