Record Class Module
java.lang.Object
java.lang.Record
com.google.javascript.jscomp.modules.Module
- Record Components:
path
- Path of this module. Null if this module is a nestedgoog.loadModule
.namespace
- Map of exported identifiers to originating binding.Note that the keys are different than
boundNames()
. Here the keys are the exported name, not the local name.Examples:
- Locally defined exports (e.g.
export let x;
,let x; export {x as v};
) creates an entry with the exported name for the local module's export definition. export default function foo() {};
creates an entry with the name "default" for the local module's default export definition.export {x as v} from 'mod';
creates an entry with the name "v" for the export definition x from 'mod'.import
statements make no entries on their own. If imported values are exported withexport {};
then an entry is created likeexport {} from
.exports.foo = bar;
creates an entry with the name "foo" for the expression on the right-hand side. This is not bound to a local name.
- Locally defined exports (e.g.
boundNames
- Map of local identifiers to originating binding.This includes all names bound by import and exported names which originate in this module. Used for rewriting in later stages of the compiler.
ES modules may have names bound by both imports and exports. Closure modules only have names bound by imports, as it is impossible to create a new local identifier in an export.
Examples:
import {x as v} from 'mod';
creates an entry with the name "v" for the export definition x from 'mod'.import * as ns from 'mod';
creates an entry with the name "ns" with a binding containing all of mod's bindings.export default function foo() {}
creates an entry with the name "foo" for the local module's export definition.export {x as v} from 'mod';
does not create any entry in this module.const C = goog.require('mod.C')
creates an entry with the name "C" for the binding containing the default export of 'mod.C'
localNameToLocalExport
- Map of local identifier name to local export definition.closureNamespace
- The specific Closure namespace this module represents, if any. This can be fromgoog.provide
,goog.module
, orgoog.module.declareNamespace
. Null otherwise.
public record Module(ModuleMetadataMap.ModuleMetadata metadata, @Nullable ModuleLoader.ModulePath path, com.google.common.collect.ImmutableMap<String,Binding> namespace, com.google.common.collect.ImmutableMap<String,Binding> boundNames, com.google.common.collect.ImmutableMap<String,Export> localNameToLocalExport, @Nullable String closureNamespace)
extends Record
Information for modules, particularly ES modules, that is useful for rewriting. The primary
pieces of information are what variables are exported (transitive or local), and what names are
imported.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionModule
(ModuleMetadataMap.ModuleMetadata metadata, @Nullable ModuleLoader.ModulePath path, com.google.common.collect.ImmutableMap<String, Binding> namespace, com.google.common.collect.ImmutableMap<String, Binding> boundNames, com.google.common.collect.ImmutableMap<String, Export> localNameToLocalExport, @Nullable String closureNamespace) Creates an instance of aModule
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theboundNames
record component.static Module.Builder
builder()
Creates a new builder.@Nullable String
Returns the value of theclosureNamespace
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of thelocalNameToLocalExport
record component.metadata()
Returns the value of themetadata
record component.Returns the value of thenamespace
record component.@Nullable ModuleLoader.ModulePath
path()
Returns the value of thepath
record component.Returns this module in builder form.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Module
public Module(ModuleMetadataMap.ModuleMetadata metadata, @Nullable ModuleLoader.ModulePath path, com.google.common.collect.ImmutableMap<String, Binding> namespace, com.google.common.collect.ImmutableMap<String, Binding> boundNames, com.google.common.collect.ImmutableMap<String, Export> localNameToLocalExport, @Nullable String closureNamespace) Creates an instance of aModule
record class.- Parameters:
metadata
- the value for themetadata
record componentpath
- the value for thepath
record componentnamespace
- the value for thenamespace
record componentboundNames
- the value for theboundNames
record componentlocalNameToLocalExport
- the value for thelocalNameToLocalExport
record componentclosureNamespace
- the value for theclosureNamespace
record component
-
-
Method Details
-
builder
Creates a new builder. -
toBuilder
Returns this module in builder form. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
metadata
Returns the value of themetadata
record component.- Returns:
- the value of the
metadata
record component
-
path
Returns the value of thepath
record component.- Returns:
- the value of the
path
record component
-
namespace
Returns the value of thenamespace
record component.- Returns:
- the value of the
namespace
record component
-
boundNames
Returns the value of theboundNames
record component.- Returns:
- the value of the
boundNames
record component
-
localNameToLocalExport
Returns the value of thelocalNameToLocalExport
record component.- Returns:
- the value of the
localNameToLocalExport
record component
-
closureNamespace
Returns the value of theclosureNamespace
record component.- Returns:
- the value of the
closureNamespace
record component
-