Class Binding

java.lang.Object
com.google.javascript.jscomp.modules.Binding

public abstract class Binding extends Object
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.

  • 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.
    abstract @Nullable String
     
    abstract com.google.javascript.jscomp.modules.Binding.CreatedBy
     
    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.
    abstract boolean
    True if this represents a module namespace, e.g.
    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
    Metadata of the module this is bound to.
    abstract @Nullable Export
    Returns the original export if this binding was created by an export.
    abstract @Nullable Node
    The AST node to use for source location when rewriting.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • metadata

      public abstract ModuleMetadataMap.ModuleMetadata 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

      public abstract @Nullable Node 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

      public abstract @Nullable Export 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

      public abstract boolean isModuleNamespace()
      True if this represents a module namespace, e.g. created by import *
    • closureNamespace

      public abstract @Nullable String closureNamespace()
    • createdBy

      public abstract com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy()
    • 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