Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Side by Side Diff: lib/src/linter.dart

Issue 1464173002: Play it safe with null tokens/nodes (#24910). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library linter.src.linter; 5 library linter.src.linter;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 /// Return a visitor to be passed to pubspecs to perform lint 256 /// Return a visitor to be passed to pubspecs to perform lint
257 /// analysis. 257 /// analysis.
258 /// Lint errors are reported via this [Linter]'s error [reporter]. 258 /// Lint errors are reported via this [Linter]'s error [reporter].
259 PubspecVisitor getPubspecVisitor() => null; 259 PubspecVisitor getPubspecVisitor() => null;
260 260
261 @override 261 @override
262 AstVisitor getVisitor() => null; 262 AstVisitor getVisitor() => null;
263 263
264 void reportLint(AstNode node) { 264 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 }
266 } 268 }
267 269
268 void reportLintForToken(Token token) { 270 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 }
270 } 274 }
271 275
272 void reportPubLint(PSNode node) { 276 void reportPubLint(PSNode node) {
273 Source source = createSource(node.span.sourceUrl); 277 Source source = createSource(node.span.sourceUrl);
274 278
275 // Cache error and location info for creating AnalysisErrorInfos 279 // Cache error and location info for creating AnalysisErrorInfos
276 // Note that error columns are 1-based 280 // Note that error columns are 1-based
277 var error = new AnalysisError(source, node.span.start.column + 1, 281 var error = new AnalysisError(source, node.span.start.column + 1,
278 node.span.length, new _LintCode(name, description)); 282 node.span.length, new _LintCode(name, description));
279 283
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 436 }
433 437
434 class _LintCode extends LintCode { 438 class _LintCode extends LintCode {
435 static final registry = <String, LintCode>{}; 439 static final registry = <String, LintCode>{};
436 440
437 factory _LintCode(String name, String message) => registry.putIfAbsent( 441 factory _LintCode(String name, String message) => registry.putIfAbsent(
438 name + message, () => new _LintCode._(name, message)); 442 name + message, () => new _LintCode._(name, message));
439 443
440 _LintCode._(String name, String message) : super(name, message); 444 _LintCode._(String name, String message) : super(name, message);
441 } 445 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698