| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package com.google.javascript.jscomp; |
| 17 |
|
| 18 |
import com.google.javascript.jscomp.DiagnosticType; |
| 19 |
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; |
| 20 |
import com.google.javascript.rhino.Node; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
class CheckDebuggerStatement extends AbstractPostOrderCallback |
| 31 |
implements CompilerPass { |
| 32 |
|
| 33 |
static final DiagnosticType DEBUGGER_STATEMENT_PRESENT = |
| 34 |
DiagnosticType.disabled("JSC_DEBUGGER_STATEMENT_PRESENT", |
| 35 |
"Using the debugger statement can halt your application if the user " + |
| 36 |
"has a JavaScript debugger running."); |
| 37 |
|
| 38 |
private final AbstractCompiler compiler; |
| 39 |
|
| 40 |
public CheckDebuggerStatement(AbstractCompiler compiler) { |
| 41 |
this.compiler = compiler; |
| 42 |
} |
| 43 |
|
| 44 |
@Override |
| 45 |
public void process(Node externs, Node root) { |
| 46 |
NodeTraversal.traverse(compiler, root, this); |
| 47 |
} |
| 48 |
|
| 49 |
@Override |
| 50 |
public void visit(NodeTraversal t, Node n, Node parent) { |
| 51 |
if (n.isDebugger()) { |
| 52 |
t.report(n, DEBUGGER_STATEMENT_PRESENT); |
| 53 |
} |
| 54 |
} |
| 55 |
} |