Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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)) { |
|
Brian Wilkerson
2016/03/01 21:26:54
Interesting. In the parser, when we're not ignorin
pquitslund
2016/03/01 21:30:01
Hmmmm. That is interesting. Maybe I should just
Brian Wilkerson
2016/03/01 21:38:55
It seems consistent to disable lints on synthetic
| |
| 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 Loading... | |
| 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 } |
| OLD | NEW |