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

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

Issue 1754813003: Suppress lints on synthetic nodes/tokens (#193). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: review_fix Created 4 years, 9 months 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 | test/_data/synthetic/synthetic.dart » ('j') | 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 ProjectVisitor getProjectVisitor() => null; 254 ProjectVisitor getProjectVisitor() => null;
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, {bool ignoreSyntheticNodes: true}) {
265 if (node != null) { 265 if (node != null && (!node.isSynthetic || !ignoreSyntheticNodes)) {
266 reporter.reportErrorForNode(new _LintCode(name, description), node, []); 266 reporter.reportErrorForNode(new _LintCode(name, description), node, []);
267 } 267 }
268 } 268 }
269 269
270 void reportLintForToken(Token token) { 270 void reportLintForToken(Token token, {bool ignoreSyntheticTokens: true}) {
271 if (token != null) { 271 if (token != null && (!token.isSynthetic || !ignoreSyntheticTokens)) {
272 reporter.reportErrorForToken(new _LintCode(name, description), token, []); 272 reporter.reportErrorForToken(new _LintCode(name, description), token, []);
273 } 273 }
274 } 274 }
275 275
276 void reportPubLint(PSNode node) { 276 void reportPubLint(PSNode node) {
277 Source source = createSource(node.span.sourceUrl); 277 Source source = createSource(node.span.sourceUrl);
278 278
279 // Cache error and location info for creating AnalysisErrorInfos 279 // Cache error and location info for creating AnalysisErrorInfos
280 // Note that error columns are 1-based 280 // Note that error columns are 1-based
281 var error = new AnalysisError(source, node.span.start.column + 1, 281 var error = new AnalysisError(source, node.span.start.column + 1,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 426 }
427 427
428 class _LintCode extends LintCode { 428 class _LintCode extends LintCode {
429 static final registry = <String, LintCode>{}; 429 static final registry = <String, LintCode>{};
430 430
431 factory _LintCode(String name, String message) => registry.putIfAbsent( 431 factory _LintCode(String name, String message) => registry.putIfAbsent(
432 name + message, () => new _LintCode._(name, message)); 432 name + message, () => new _LintCode._(name, message));
433 433
434 _LintCode._(String name, String message) : super(name, message); 434 _LintCode._(String name, String message) : super(name, message);
435 } 435 }
OLDNEW
« no previous file with comments | « no previous file | test/_data/synthetic/synthetic.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698