final class CheckSuspiciousCode extends NodeTraversal.AbstractPostOrderCallback
if (x); act_now();or comparison against NaN:
if (x === NaN) act();and generates warnings.
Modifier and Type | Field and Description |
---|---|
(package private) static DiagnosticType |
SUSPICIOUS_COMPARISON_WITH_NAN |
(package private) static DiagnosticType |
SUSPICIOUS_IN_OPERATOR |
(package private) static DiagnosticType |
SUSPICIOUS_INSTANCEOF_LEFT_OPERAND |
(package private) static DiagnosticType |
SUSPICIOUS_NEGATED_LEFT_OPERAND_OF_IN_OPERATOR |
(package private) static DiagnosticType |
SUSPICIOUS_SEMICOLON |
Constructor and Description |
---|
CheckSuspiciousCode() |
Modifier and Type | Method and Description |
---|---|
private void |
checkInvalidIn(NodeTraversal t,
Node n) |
private void |
checkMissingSemicolon(NodeTraversal t,
Node n) |
private void |
checkNaN(NodeTraversal t,
Node n) |
private void |
checkNegatedLeftOperandOfInOperator(NodeTraversal t,
Node n) |
private void |
checkNonObjectInstanceOf(NodeTraversal t,
Node n) |
private static void |
reportIfNaN(NodeTraversal t,
Node n) |
private static boolean |
reportIfNonObject(NodeTraversal t,
Node n,
DiagnosticType diagnosticType) |
private static void |
reportIfWasEmpty(NodeTraversal t,
Node block) |
void |
visit(NodeTraversal t,
Node n,
Node parent)
Visits a node in postorder (after its children have been visited).
|
shouldTraverse
static final DiagnosticType SUSPICIOUS_SEMICOLON
static final DiagnosticType SUSPICIOUS_COMPARISON_WITH_NAN
static final DiagnosticType SUSPICIOUS_IN_OPERATOR
static final DiagnosticType SUSPICIOUS_INSTANCEOF_LEFT_OPERAND
static final DiagnosticType SUSPICIOUS_NEGATED_LEFT_OPERAND_OF_IN_OPERATOR
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).
private void checkMissingSemicolon(NodeTraversal t, Node n)
private static void reportIfWasEmpty(NodeTraversal t, Node block)
private void checkNaN(NodeTraversal t, Node n)
private static void reportIfNaN(NodeTraversal t, Node n)
private void checkInvalidIn(NodeTraversal t, Node n)
private void checkNonObjectInstanceOf(NodeTraversal t, Node n)
private static boolean reportIfNonObject(NodeTraversal t, Node n, DiagnosticType diagnosticType)
private void checkNegatedLeftOperandOfInOperator(NodeTraversal t, Node n)