Package com.google.javascript.jscomp
Class ReferenceCollector
- java.lang.Object
-
- com.google.javascript.jscomp.ReferenceCollector
-
- All Implemented Interfaces:
CompilerPass,StaticSymbolTable<Var,Reference>
public final class ReferenceCollector extends java.lang.Object implements CompilerPass, StaticSymbolTable<Var,Reference>
A helper class for passes that want to access all information about where a variable is referenced and declared at once and then make a decision as to how it should be handled, possibly inlining, reordering, or generating warnings. Callers do this by providingReferenceCollector.Behaviorand then callingprocess(Node, Node).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceReferenceCollector.BehaviorWay for callers to add specific behavior during traversal that utilizes the built-up reference information.
-
Constructor Summary
Constructors Constructor Description ReferenceCollector(AbstractCompiler compiler, ReferenceCollector.Behavior behavior, com.google.javascript.jscomp.ScopeCreator creator)Constructor initializes block stack.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<Var>getAllSymbols()Gets the variables that were referenced in this callback.ReferenceCollectiongetReferences(Var v)Gets the reference collection for the given variable.ScopegetScope(Var var)Returns the scope for a given symbol.voidprocess(Node root)voidprocess(Node externs, Node root)Convenience method for running this pass over a tree with this class as a callback.
-
-
-
Constructor Detail
-
ReferenceCollector
public ReferenceCollector(AbstractCompiler compiler, ReferenceCollector.Behavior behavior, com.google.javascript.jscomp.ScopeCreator creator)
Constructor initializes block stack.
-
-
Method Detail
-
process
public void process(Node externs, Node root)
Convenience method for running this pass over a tree with this class as a callback.- Specified by:
processin interfaceCompilerPass- Parameters:
externs- Top of external JS treeroot- Top of JS tree
-
process
public void process(Node root)
-
getAllSymbols
public java.lang.Iterable<Var> getAllSymbols()
Gets the variables that were referenced in this callback.- Specified by:
getAllSymbolsin interfaceStaticSymbolTable<Var,Reference>
-
getScope
public Scope getScope(Var var)
Description copied from interface:StaticSymbolTableReturns the scope for a given symbol.- Specified by:
getScopein interfaceStaticSymbolTable<Var,Reference>
-
getReferences
public ReferenceCollection getReferences(Var v)
Gets the reference collection for the given variable.- Specified by:
getReferencesin interfaceStaticSymbolTable<Var,Reference>
-
-