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 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 providing
ReferenceCollector.Behavior
and
then calling process(Node, Node)
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Way for callers to add specific behavior during traversal that utilizes the built-up reference information. -
Constructor Summary
ConstructorsConstructorDescriptionReferenceCollector
(AbstractCompiler compiler, ReferenceCollector.Behavior behavior, com.google.javascript.jscomp.ScopeCreator creator) Constructor initializes block stack. -
Method Summary
Modifier and TypeMethodDescriptionGets the variables that were referenced in this callback.getReferences
(Var v) Gets the reference collection for the given variable.Returns the scope for a given symbol.void
void
Convenience method for running this pass over a tree with this class as a callback.
-
Constructor Details
-
ReferenceCollector
public ReferenceCollector(AbstractCompiler compiler, ReferenceCollector.Behavior behavior, com.google.javascript.jscomp.ScopeCreator creator) Constructor initializes block stack.
-
-
Method Details
-
process
Convenience method for running this pass over a tree with this class as a callback.- Specified by:
process
in interfaceCompilerPass
- Parameters:
externs
- Top of external JS treeroot
- Top of JS tree
-
process
-
getAllSymbols
Gets the variables that were referenced in this callback.- Specified by:
getAllSymbols
in interfaceStaticSymbolTable<Var,
Reference>
-
getScope
Description copied from interface:StaticSymbolTable
Returns the scope for a given symbol.- Specified by:
getScope
in interfaceStaticSymbolTable<Var,
Reference>
-
getReferences
Gets the reference collection for the given variable.- Specified by:
getReferences
in interfaceStaticSymbolTable<Var,
Reference>
-