class StrictModeCheck extends NodeTraversal.AbstractPostOrderCallback implements CompilerPass
Modifier and Type | Class and Description |
---|---|
private static class |
StrictModeCheck.NonExternChecks
Checks that are performed on non-extern code only.
|
Modifier and Type | Field and Description |
---|---|
(package private) static DiagnosticType |
ARGUMENTS_ASSIGNMENT |
(package private) static DiagnosticType |
ARGUMENTS_CALLEE_FORBIDDEN |
(package private) static DiagnosticType |
ARGUMENTS_CALLER_FORBIDDEN |
(package private) static DiagnosticType |
ARGUMENTS_DECLARATION |
(package private) static DiagnosticType |
BAD_FUNCTION_DECLARATION |
private AbstractCompiler |
compiler |
(package private) static DiagnosticType |
DELETE_VARIABLE |
(package private) static DiagnosticType |
DUPLICATE_CLASS_METHODS |
(package private) static DiagnosticType |
DUPLICATE_OBJECT_KEY |
(package private) static DiagnosticType |
EVAL_ASSIGNMENT |
(package private) static DiagnosticType |
EVAL_DECLARATION |
(package private) static DiagnosticType |
FUNCTION_ARGUMENTS_PROP_FORBIDDEN |
(package private) static DiagnosticType |
FUNCTION_CALLER_FORBIDDEN |
(package private) static DiagnosticType |
USE_OF_WITH |
Constructor and Description |
---|
StrictModeCheck(AbstractCompiler compiler) |
Modifier and Type | Method and Description |
---|---|
private static void |
checkAssignment(NodeTraversal t,
Node n)
Checks that an assignment is not to the "arguments" object.
|
private static void |
checkDelete(NodeTraversal t,
Node n)
Checks that variables, functions, and arguments are not deleted.
|
private static void |
checkFunctionUse(NodeTraversal t,
Node n)
Checks that the function is used legally.
|
private static void |
checkObjectLiteralOrClass(NodeTraversal t,
Node n)
Checks that object literal keys or class method names are valid.
|
private static void |
checkWith(NodeTraversal t,
Node n)
Reports a warning for with statements.
|
private static boolean |
isDeclaration(Node n)
Determines if the given name is a declaration, which can be a declaration
of a variable, function, or argument.
|
private static boolean |
isFunctionType(Node n) |
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
void |
visit(NodeTraversal t,
Node n,
Node parent)
Visits a node in postorder (after its children have been visited).
|
shouldTraverse
static final DiagnosticType USE_OF_WITH
static final DiagnosticType EVAL_DECLARATION
static final DiagnosticType EVAL_ASSIGNMENT
static final DiagnosticType ARGUMENTS_DECLARATION
static final DiagnosticType ARGUMENTS_ASSIGNMENT
static final DiagnosticType ARGUMENTS_CALLEE_FORBIDDEN
static final DiagnosticType ARGUMENTS_CALLER_FORBIDDEN
static final DiagnosticType FUNCTION_CALLER_FORBIDDEN
static final DiagnosticType FUNCTION_ARGUMENTS_PROP_FORBIDDEN
static final DiagnosticType DELETE_VARIABLE
static final DiagnosticType DUPLICATE_OBJECT_KEY
static final DiagnosticType DUPLICATE_CLASS_METHODS
static final DiagnosticType BAD_FUNCTION_DECLARATION
private final AbstractCompiler compiler
StrictModeCheck(AbstractCompiler compiler)
public void process(Node externs, Node root)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treepublic 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 static void checkWith(NodeTraversal t, Node n)
private static void checkFunctionUse(NodeTraversal t, Node n)
private static boolean isDeclaration(Node n)
private static void checkAssignment(NodeTraversal t, Node n)
private static void checkDelete(NodeTraversal t, Node n)
private static void checkObjectLiteralOrClass(NodeTraversal t, Node n)
private static boolean isFunctionType(Node n)