Class Binding
- java.lang.Object
-
- com.google.javascript.jscomp.modules.Binding
-
public abstract class Binding extends java.lang.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()
andModule.boundNames()
for how Bindings are used.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
boundName()
The name of the variable this export is bound to, assuming it is not a binding of a module namespace.abstract @Nullable java.lang.String
closureNamespace()
abstract com.google.javascript.jscomp.modules.Binding.CreatedBy
createdBy()
boolean
isCreatedByEsExport()
Returns whether this Binding originated from an ES import, as opposed to an export or goog.require.boolean
isCreatedByEsImport()
Returns whether this Binding originated from an ES import, as opposed to an export or goog.require.abstract boolean
isModuleNamespace()
True if this represents a module namespace, e.g.boolean
isMutated()
Returns whether or not this export is potentially mutated after module execution (i.e.boolean
isSomeImport()
Returns whether this Binding originated from an ES import or goog.requireabstract ModuleMetadataMap.ModuleMetadata
metadata()
Metadata of the module this is bound to.abstract @Nullable Export
originatingExport()
Returns the original export if this binding was created by an export.abstract @Nullable Node
sourceNode()
The AST node to use for source location when rewriting.
-
-
-
Method Detail
-
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 byimport *
-
closureNamespace
public abstract @Nullable java.lang.String closureNamespace()
-
createdBy
public abstract com.google.javascript.jscomp.modules.Binding.CreatedBy createdBy()
-
boundName
public final java.lang.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
-
-