Record Class Binding
java.lang.Object
java.lang.Record
com.google.javascript.jscomp.modules.Binding
- Record Components:
metadata
- Metadata of the module this is bound to.If this was made from an
import *
then it is the module that this imported. Otherwise it is the module this binding was created in (e.g. the module of the originating export).sourceNode
- The AST node to use for source location when rewriting.This is generally a NAME or IMPORT_STAR node inside an import or export statement that represents where the name was bound. However as
export * from
has no NAME nodes the source node in that instance should be the entire export node.Null for missing ES modules and non-ES modules as they are currently not scanned.
originatingExport
- Returns the original export if this binding was created by an export.For transitive exports this will still be the *original* export, not the transitive link.
isModuleNamespace
- True if this represents a module namespace, e.g. created byimport *
public record Binding(ModuleMetadataMap.ModuleMetadata metadata, @Nullable Node sourceNode, @Nullable Export originatingExport, boolean isModuleNamespace, @Nullable String closureNamespace, com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy)
extends Record
Represents a variable bound by an import or export statement, or goog.require. This can either be
a single variable or a entire module namespace created by an import * statement.
See Module.namespace()
and Module.boundNames()
for how Bindings are used.
-
Constructor Summary
ConstructorsConstructorDescriptionBinding
(ModuleMetadataMap.ModuleMetadata metadata, @Nullable Node sourceNode, @Nullable Export originatingExport, boolean isModuleNamespace, @Nullable String closureNamespace, com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy) Creates an instance of aBinding
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal String
The name of the variable this export is bound to, assuming it is not a binding of a module namespace.@Nullable String
Returns the value of theclosureNamespace
record component.com.google.javascript.jscomp.modules.Binding.CreatedBy
Returns the value of thecreatedBy
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.final boolean
Returns whether this Binding originated from an ES import, as opposed to an export or goog.require.final boolean
Returns whether this Binding originated from an ES import, as opposed to an export or goog.require.boolean
Returns the value of theisModuleNamespace
record component.final boolean
Returns whether or not this export is potentially mutated after module execution (i.e.final boolean
Returns whether this Binding originated from an ES import or goog.requiremetadata()
Returns the value of themetadata
record component.@Nullable Export
Returns the value of theoriginatingExport
record component.@Nullable Node
Returns the value of thesourceNode
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Binding
public Binding(ModuleMetadataMap.ModuleMetadata metadata, @Nullable Node sourceNode, @Nullable Export originatingExport, boolean isModuleNamespace, @Nullable String closureNamespace, com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy) Creates an instance of aBinding
record class.- Parameters:
metadata
- the value for themetadata
record componentsourceNode
- the value for thesourceNode
record componentoriginatingExport
- the value for theoriginatingExport
record componentisModuleNamespace
- the value for theisModuleNamespace
record componentclosureNamespace
- the value for theclosureNamespace
record componentcreatedBy
- the value for thecreatedBy
record component
-
-
Method Details
-
boundName
The name of the variable this export is bound to, assuming it is not a binding of a module namespace. -
isMutated
public final boolean isMutated()Returns whether or not this export is potentially mutated after module execution (i.e. in a function scope). -
isCreatedByEsImport
public final boolean isCreatedByEsImport()Returns whether this Binding originated from an ES import, as opposed to an export or goog.require. -
isCreatedByEsExport
public final boolean isCreatedByEsExport()Returns whether this Binding originated from an ES import, as opposed to an export or goog.require. -
isSomeImport
public final boolean isSomeImport()Returns whether this Binding originated from an ES import or goog.require -
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
metadata
Returns the value of themetadata
record component.- Returns:
- the value of the
metadata
record component
-
sourceNode
Returns the value of thesourceNode
record component.- Returns:
- the value of the
sourceNode
record component
-
originatingExport
Returns the value of theoriginatingExport
record component.- Returns:
- the value of the
originatingExport
record component
-
isModuleNamespace
public boolean isModuleNamespace()Returns the value of theisModuleNamespace
record component.- Returns:
- the value of the
isModuleNamespace
record component
-
closureNamespace
Returns the value of theclosureNamespace
record component.- Returns:
- the value of the
closureNamespace
record component
-
createdBy
public com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy()Returns the value of thecreatedBy
record component.- Returns:
- the value of the
createdBy
record component
-