public final class ReferenceCollectingCallback extends java.lang.Object implements NodeTraversal.ScopedCallback, HotSwapCompilerPass, StaticSymbolTable<Var,Reference>
ReferenceCollectingCallback.Behavior and
then calling process(Node, Node).| Modifier and Type | Class and Description |
|---|---|
static interface |
ReferenceCollectingCallback.Behavior
Way for callers to add specific behavior during traversal that
utilizes the built-up reference information.
|
| Constructor and Description |
|---|
ReferenceCollectingCallback(AbstractCompiler compiler,
ReferenceCollectingCallback.Behavior behavior,
com.google.javascript.jscomp.ScopeCreator creator)
Constructor initializes block stack.
|
| Modifier and Type | Method and Description |
|---|---|
void |
enterScope(NodeTraversal t)
Updates block stack and invokes any additional behavior.
|
void |
exitScope(NodeTraversal t)
Updates block stack and invokes any additional behavior.
|
java.lang.Iterable<Var> |
getAllSymbols()
Gets the variables that were referenced in this callback.
|
ReferenceCollection |
getReferences(Var v)
Gets the reference collection for the given variable.
|
Scope |
getScope(Var var)
Returns the scope for a given symbol.
|
void |
hotSwapScript(Node scriptRoot,
Node originalRoot)
Same as process but only runs on a part of AST associated to one script.
|
void |
process(Node root) |
void |
process(Node externs,
Node root)
Convenience method for running this pass over a tree with this
class as a callback.
|
boolean |
shouldTraverse(NodeTraversal nodeTraversal,
Node n,
Node parent)
Updates block stack.
|
void |
visit(NodeTraversal t,
Node n,
Node parent)
For each node, update the block stack and reference collection
as appropriate.
|
public ReferenceCollectingCallback(AbstractCompiler compiler, ReferenceCollectingCallback.Behavior behavior, com.google.javascript.jscomp.ScopeCreator creator)
public void process(Node externs, Node root)
process in interface CompilerPassexterns - Top of external JS treeroot - Top of JS treepublic void process(Node root)
public void hotSwapScript(Node scriptRoot, Node originalRoot)
hotSwapScript in interface HotSwapCompilerPassscriptRoot - Root node corresponding to the file that is modified,
should be of type Token.SCRIPT.originalRoot - Root node corresponding to the original version of the
file that is modified. Should be of type token.SCRIPT.public java.lang.Iterable<Var> getAllSymbols()
getAllSymbols in interface StaticSymbolTable<Var,Reference>public Scope getScope(Var var)
StaticSymbolTablegetScope in interface StaticSymbolTable<Var,Reference>public ReferenceCollection getReferences(Var v)
getReferences in interface StaticSymbolTable<Var,Reference>public void visit(NodeTraversal t, Node n, Node parent)
visit in interface NodeTraversal.Callbackpublic void enterScope(NodeTraversal t)
enterScope in interface NodeTraversal.ScopedCallbackpublic void exitScope(NodeTraversal t)
exitScope in interface NodeTraversal.ScopedCallbackpublic boolean shouldTraverse(NodeTraversal nodeTraversal, Node n, Node parent)
shouldTraverse in interface NodeTraversal.CallbackCopyright © 2009-2019 Google. All Rights Reserved.