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 by import *

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

    Constructors
    Constructor
    Description
    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 a Binding record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final 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 the closureNamespace record component.
    com.google.javascript.jscomp.modules.Binding.CreatedBy
    Returns the value of the createdBy record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    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 the isModuleNamespace 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.require
    Returns the value of the metadata record component.
    @Nullable Export
    Returns the value of the originatingExport record component.
    @Nullable Node
    Returns the value of the sourceNode record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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 a Binding record class.
      Parameters:
      metadata - the value for the metadata record component
      sourceNode - the value for the sourceNode record component
      originatingExport - the value for the originatingExport record component
      isModuleNamespace - the value for the isModuleNamespace record component
      closureNamespace - the value for the closureNamespace record component
      createdBy - the value for the createdBy record component
  • Method Details

    • boundName

      public final String 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • metadata

      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component
    • sourceNode

      public @Nullable Node sourceNode()
      Returns the value of the sourceNode record component.
      Returns:
      the value of the sourceNode record component
    • originatingExport

      public @Nullable Export originatingExport()
      Returns the value of the originatingExport record component.
      Returns:
      the value of the originatingExport record component
    • isModuleNamespace

      public boolean isModuleNamespace()
      Returns the value of the isModuleNamespace record component.
      Returns:
      the value of the isModuleNamespace record component
    • closureNamespace

      public @Nullable String closureNamespace()
      Returns the value of the closureNamespace record component.
      Returns:
      the value of the closureNamespace record component
    • createdBy

      public com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy()
      Returns the value of the createdBy record component.
      Returns:
      the value of the createdBy record component