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 * fromhas 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 aBindingrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringThe name of the variable this export is bound to, assuming it is not a binding of a module namespace.@Nullable StringReturns the value of theclosureNamespacerecord component.com.google.javascript.jscomp.modules.Binding.CreatedByReturns the value of thecreatedByrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final booleanReturns whether this Binding originated from an ES import, as opposed to an export or goog.require.final booleanReturns whether this Binding originated from an ES import, as opposed to an export or goog.require.booleanReturns the value of theisModuleNamespacerecord component.final booleanReturns whether or not this export is potentially mutated after module execution (i.e.final booleanReturns whether this Binding originated from an ES import or goog.requiremetadata()Returns the value of themetadatarecord component.@Nullable ExportReturns the value of theoriginatingExportrecord component.@Nullable NodeReturns the value of thesourceNoderecord component.final StringtoString()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 aBindingrecord class.- Parameters:
metadata- the value for themetadatarecord componentsourceNode- the value for thesourceNoderecord componentoriginatingExport- the value for theoriginatingExportrecord componentisModuleNamespace- the value for theisModuleNamespacerecord componentclosureNamespace- the value for theclosureNamespacerecord componentcreatedBy- the value for thecreatedByrecord 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 themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-
sourceNode
Returns the value of thesourceNoderecord component.- Returns:
- the value of the
sourceNoderecord component
-
originatingExport
Returns the value of theoriginatingExportrecord component.- Returns:
- the value of the
originatingExportrecord component
-
isModuleNamespace
public boolean isModuleNamespace()Returns the value of theisModuleNamespacerecord component.- Returns:
- the value of the
isModuleNamespacerecord component
-
closureNamespace
Returns the value of theclosureNamespacerecord component.- Returns:
- the value of the
closureNamespacerecord component
-
createdBy
public com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy()Returns the value of thecreatedByrecord component.- Returns:
- the value of the
createdByrecord component
-