private class AnalyzePrototypeProperties.ProcessProperties extends java.lang.Object implements NodeTraversal.ScopedCallback
Modifier and Type | Field and Description |
---|---|
private java.util.Stack<AnalyzePrototypeProperties.NameContext> |
symbolStack |
Modifier | Constructor and Description |
---|---|
private |
ProcessProperties() |
Modifier and Type | Method and Description |
---|---|
private void |
addGlobalUseOfSymbol(java.lang.String name,
JSModule module,
AnalyzePrototypeProperties.SymbolType type) |
private void |
addSymbolUse(java.lang.String name,
JSModule module,
AnalyzePrototypeProperties.SymbolType type) |
void |
enterScope(NodeTraversal t)
Called immediately after entering a new scope.
|
void |
exitScope(NodeTraversal t)
Called immediately before exiting a scope.
|
private java.lang.String |
getPrototypePropertyNameFromRValue(Node rValue)
Returns the name of a prototype property being assigned to this r-value.
|
private boolean |
isAssignRValue(Node n,
Node parent)
Returns true if this is the r-value of an assignment.
|
private boolean |
isGlobalFunctionDeclaration(NodeTraversal t,
Node n)
Determines whether
n is the FUNCTION node in a global function
declaration. |
private Var |
maybeGetVar(NodeTraversal t,
Node maybeName) |
private boolean |
processGlobalFunctionDeclaration(NodeTraversal t,
Node nameNode,
Var v)
Processes a NAME node to see if it's a global function declaration.
|
private java.lang.String |
processNonFunctionPrototypeAssign(Node n,
Node parent)
If this is a non-function prototype assign, return the prop name.
|
private boolean |
processPrototypeRef(NodeTraversal t,
Node ref)
Processes the GETPROP of prototype, which can either be under
another GETPROP (in the case of Foo.prototype.bar), or can be
under an assignment (in the case of Foo.prototype = ...).
|
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).
|
private final java.util.Stack<AnalyzePrototypeProperties.NameContext> symbolStack
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 void addSymbolUse(java.lang.String name, JSModule module, AnalyzePrototypeProperties.SymbolType type)
private java.lang.String processNonFunctionPrototypeAssign(Node n, Node parent)
private boolean isGlobalFunctionDeclaration(NodeTraversal t, Node n)
n
is the FUNCTION node in a global function
declaration.private boolean isAssignRValue(Node n, Node parent)
private java.lang.String getPrototypePropertyNameFromRValue(Node rValue)
private boolean processGlobalFunctionDeclaration(NodeTraversal t, Node nameNode, Var v)
private boolean processPrototypeRef(NodeTraversal t, Node ref)
private Var maybeGetVar(NodeTraversal t, Node maybeName)
private void addGlobalUseOfSymbol(java.lang.String name, JSModule module, AnalyzePrototypeProperties.SymbolType type)