class ConstCheck extends NodeTraversal.AbstractPostOrderCallback implements CompilerPass
| Modifier and Type | Field and Description |
|---|---|
private AbstractCompiler |
compiler |
(package private) static DiagnosticType |
CONST_REASSIGNED_VALUE_ERROR |
private java.util.Set<Var> |
initializedConstants |
| Constructor and Description |
|---|
ConstCheck(AbstractCompiler compiler)
Creates an instance.
|
| Modifier and Type | Method and Description |
|---|---|
private static boolean |
isConstant(Var var)
Gets whether a variable is a constant initialized to a literal value at
the point where it is declared.
|
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
(package private) void |
reportError(NodeTraversal t,
Node n,
Var var,
java.lang.String name)
Reports a reassigned constant error.
|
void |
visit(NodeTraversal t,
Node n,
Node parent)
Visits a node in postorder (after its children have been visited).
|
shouldTraversestatic final DiagnosticType CONST_REASSIGNED_VALUE_ERROR
private final AbstractCompiler compiler
private final java.util.Set<Var> initializedConstants
public ConstCheck(AbstractCompiler compiler)
public void process(Node externs, Node root)
CompilerPassprocess in interface CompilerPassexterns - Top of external JS treeroot - Top of JS treepublic void visit(NodeTraversal t, Node n, Node parent)
NodeTraversal.CallbackVisits 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.Callbackprivate static boolean isConstant(Var var)
void reportError(NodeTraversal t, Node n, Var var, java.lang.String name)