Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 4640d54

Browse files
committed
Play it safe with null tokens/nodes (#24910).
Background here: dart-lang/sdk#24910 The rub is we need to be careful in case nodes or tokens are null (for example when analyzing invalid source). BUG=24910 [email protected] Review URL: https://codereview.chromium.org//1464173002 .
1 parent 4930ad5 commit 4640d54

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/src/linter.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,15 @@ abstract class LintRule extends Linter implements Comparable<LintRule> {
262262
AstVisitor getVisitor() => null;
263263

264264
void reportLint(AstNode node) {
265-
reporter.reportErrorForNode(new _LintCode(name, description), node, []);
265+
if (node != null) {
266+
reporter.reportErrorForNode(new _LintCode(name, description), node, []);
267+
}
266268
}
267269

268270
void reportLintForToken(Token token) {
269-
reporter.reportErrorForToken(new _LintCode(name, description), token, []);
271+
if (token != null) {
272+
reporter.reportErrorForToken(new _LintCode(name, description), token, []);
273+
}
270274
}
271275

272276
void reportPubLint(PSNode node) {

0 commit comments

Comments
 (0)