private class NameReferenceGraphConstruction.Traversal extends java.lang.Object implements NodeTraversal.ScopedCallback
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
isExtern |
Modifier | Constructor and Description |
---|---|
private |
Traversal(boolean isExtern) |
Modifier and Type | Method and Description |
---|---|
private boolean |
containsName(Node n) |
private void |
defineAndAlias(java.lang.String name) |
void |
enterScope(NodeTraversal t)
Called immediately after entering a new scope.
|
void |
exitScope(NodeTraversal t)
Called immediately before exiting a scope.
|
private boolean |
isLocalNameReference(NodeTraversal t,
Node n) |
private boolean |
isPrototypeNameReference(Node n) |
private boolean |
isStaticNameReference(Node n,
Scope scope) |
private void |
maybeAliasNamesOnAssign(Node lhs,
Node rhs) |
private void |
maybeRecordExport(Node call) |
private NameReferenceGraph.Name |
recordClassConstructorOrInterface(java.lang.String name,
FunctionType type,
Node n,
Node rhs)
Creates the name in the graph if it does not already exist.
|
private NameReferenceGraph.Name |
recordPrototypePropDefinition(Node qName,
JSType type,
Node assign) |
private void |
recordPrototypePropUse(Node n) |
private NameReferenceGraph.Name |
recordStaticNameDefinition(java.lang.String name,
JSType type,
Node n,
Node rValue) |
private NameReferenceGraph.Reference |
recordStaticNameUse(Node n) |
private void |
recordSubclassPrototypePropUse(FunctionType classType,
java.lang.String prop,
NameReferenceGraph.Reference ref)
Conservatively assumes that all subclass implementation of this property
might be called.
|
private void |
recordSuperClassPrototypePropUse(FunctionType classType,
java.lang.String prop,
NameReferenceGraph.Reference ref)
Look for the super class implementation up the tree.
|
private void |
recordUnknownUse(Node n) |
private void |
safeAlias(Node n)
Given a node, this alias all the names in the node that need aliasing.
|
boolean |
shouldTraverse(NodeTraversal t,
Node n,
Node parent)
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed.
|
void |
visit(NodeTraversal t,
Node n,
Node parent)
Visits a node in postorder (after its children have been visited).
|
public void enterScope(NodeTraversal t)
NodeTraversal.ScopedCallback
enterScope
in interface NodeTraversal.ScopedCallback
public void exitScope(NodeTraversal t)
NodeTraversal.ScopedCallback
exitScope
in interface NodeTraversal.ScopedCallback
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent)
NodeTraversal.Callback
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed. If children are
traversed, they will be visited by
NodeTraversal.Callback.visit(NodeTraversal, Node, Node)
in postorder.
Implementations can have side effects (e.g. modifying the parse tree).
shouldTraverse
in interface NodeTraversal.Callback
public void visit(NodeTraversal t, Node n, Node parent)
NodeTraversal.Callback
Visits a node in postorder (after its children have been visited).
A node is visited only if all its parents should be traversed
(NodeTraversal.Callback.shouldTraverse(NodeTraversal, Node, Node)
).
Implementations can have side effects (e.g. modifying the parse tree).
visit
in interface NodeTraversal.Callback
private boolean containsName(Node n)
private void safeAlias(Node n)
n
- node to aliasprivate void defineAndAlias(java.lang.String name)
private void maybeRecordExport(Node call)
private boolean isLocalNameReference(NodeTraversal t, Node n)
private boolean isStaticNameReference(Node n, Scope scope)
private boolean isPrototypeNameReference(Node n)
private NameReferenceGraph.Name recordStaticNameDefinition(java.lang.String name, JSType type, Node n, Node rValue)
private NameReferenceGraph.Name recordPrototypePropDefinition(Node qName, JSType type, @Nullable Node assign)
assign
- The assignment node, null if it is just a "forward"
declaration for recording the rValue's type.private NameReferenceGraph.Reference recordStaticNameUse(Node n)
private void recordPrototypePropUse(Node n)
private void recordSuperClassPrototypePropUse(FunctionType classType, java.lang.String prop, NameReferenceGraph.Reference ref)
private void recordSubclassPrototypePropUse(FunctionType classType, java.lang.String prop, NameReferenceGraph.Reference ref)
private void recordUnknownUse(Node n)
private NameReferenceGraph.Name recordClassConstructorOrInterface(java.lang.String name, FunctionType type, @Nullable Node n, @Nullable Node rhs)