| 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 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' | 9 import 'package:analyzer/src/generated/engine.dart' |
| 10 show AnalysisErrorInfo, AnalysisErrorInfoImpl, Logger; | 10 show AnalysisErrorInfo, AnalysisErrorInfoImpl, Logger; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 /// The total number of sources that were analyzed. Only valid after | 56 /// The total number of sources that were analyzed. Only valid after |
| 57 /// [lintFiles] has been called. | 57 /// [lintFiles] has been called. |
| 58 int numSourcesAnalyzed; | 58 int numSourcesAnalyzed; |
| 59 | 59 |
| 60 /// Creates a new linter. | 60 /// Creates a new linter. |
| 61 DartLinter(this.options, {this.reporter: const PrintingReporter()}); | 61 DartLinter(this.options, {this.reporter: const PrintingReporter()}); |
| 62 | 62 |
| 63 Iterable<AnalysisErrorInfo> lintFiles(List<File> files) { | 63 Iterable<AnalysisErrorInfo> lintFiles(List<File> files) { |
| 64 List<AnalysisErrorInfo> errors = []; | 64 List<AnalysisErrorInfo> errors = []; |
| 65 var analysisDriver = new AnalysisDriver(options); | 65 var analysisDriver = new LintDriver(options); |
| 66 errors.addAll(analysisDriver.analyze(files.where((f) => isDartFile(f)))); | 66 errors.addAll(analysisDriver.analyze(files.where((f) => isDartFile(f)))); |
| 67 numSourcesAnalyzed = analysisDriver.numSourcesAnalyzed; | 67 numSourcesAnalyzed = analysisDriver.numSourcesAnalyzed; |
| 68 files.where((f) => isPubspecFile(f)).forEach((p) { | 68 files.where((f) => isPubspecFile(f)).forEach((p) { |
| 69 numSourcesAnalyzed++; | 69 numSourcesAnalyzed++; |
| 70 return errors.addAll(_lintPubspecFile(p)); | 70 return errors.addAll(_lintPubspecFile(p)); |
| 71 }); | 71 }); |
| 72 return errors; | 72 return errors; |
| 73 } | 73 } |
| 74 | 74 |
| 75 Iterable<AnalysisErrorInfo> lintPubspecSource( | 75 Iterable<AnalysisErrorInfo> lintPubspecSource( |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 final Reporter reporter; | 356 final Reporter reporter; |
| 357 | 357 |
| 358 @override | 358 @override |
| 359 int numSourcesAnalyzed; | 359 int numSourcesAnalyzed; |
| 360 | 360 |
| 361 SourceLinter(this.options, {this.reporter: const PrintingReporter()}); | 361 SourceLinter(this.options, {this.reporter: const PrintingReporter()}); |
| 362 | 362 |
| 363 @override | 363 @override |
| 364 Iterable<AnalysisErrorInfo> lintFiles(List<File> files) { | 364 Iterable<AnalysisErrorInfo> lintFiles(List<File> files) { |
| 365 List<AnalysisErrorInfo> errors = []; | 365 List<AnalysisErrorInfo> errors = []; |
| 366 var analysisDriver = new AnalysisDriver(options); | 366 var analysisDriver = new LintDriver(options); |
| 367 errors.addAll(analysisDriver.analyze(files.where((f) => isDartFile(f)))); | 367 errors.addAll(analysisDriver.analyze(files.where((f) => isDartFile(f)))); |
| 368 numSourcesAnalyzed = analysisDriver.numSourcesAnalyzed; | 368 numSourcesAnalyzed = analysisDriver.numSourcesAnalyzed; |
| 369 files.where((f) => isPubspecFile(f)).forEach((p) { | 369 files.where((f) => isPubspecFile(f)).forEach((p) { |
| 370 numSourcesAnalyzed++; | 370 numSourcesAnalyzed++; |
| 371 return errors.addAll(_lintPubspecFile(p)); | 371 return errors.addAll(_lintPubspecFile(p)); |
| 372 }); | 372 }); |
| 373 return errors; | 373 return errors; |
| 374 } | 374 } |
| 375 | 375 |
| 376 @override | 376 @override |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 | 421 |
| 422 class _LintCode extends LintCode { | 422 class _LintCode extends LintCode { |
| 423 static final registry = <String, LintCode>{}; | 423 static final registry = <String, LintCode>{}; |
| 424 | 424 |
| 425 factory _LintCode(String name, String message) => registry.putIfAbsent( | 425 factory _LintCode(String name, String message) => registry.putIfAbsent( |
| 426 name + message, () => new _LintCode._(name, message)); | 426 name + message, () => new _LintCode._(name, message)); |
| 427 | 427 |
| 428 _LintCode._(String name, String message) : super(name, message); | 428 _LintCode._(String name, String message) : super(name, message); |
| 429 } | 429 } |
| OLD | NEW |