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.test.rule; | 5 library linter.test.rule; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
| 9 import 'mock_sdk.dart'; |
9 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
10 import 'package:analyzer/src/generated/error.dart'; | 11 import 'package:analyzer/src/generated/error.dart'; |
11 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
12 import 'package:linter/src/ast.dart'; | 13 import 'package:linter/src/ast.dart'; |
13 import 'package:linter/src/formatter.dart'; | 14 import 'package:linter/src/formatter.dart'; |
14 import 'package:linter/src/io.dart'; | 15 import 'package:linter/src/io.dart'; |
15 import 'package:linter/src/linter.dart'; | 16 import 'package:linter/src/linter.dart'; |
16 import 'package:linter/src/rules.dart'; | 17 import 'package:linter/src/rules.dart'; |
17 import 'package:linter/src/rules/camel_case_types.dart'; | 18 import 'package:linter/src/rules/camel_case_types.dart'; |
18 import 'package:linter/src/rules/implementation_imports.dart'; | 19 import 'package:linter/src/rules/implementation_imports.dart'; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 ++lineNumber; | 403 ++lineNumber; |
403 } | 404 } |
404 | 405 |
405 LintRule rule = ruleRegistry[ruleName]; | 406 LintRule rule = ruleRegistry[ruleName]; |
406 if (rule == null) { | 407 if (rule == null) { |
407 print('WARNING: Test skipped -- rule `$ruleName` is not registered.'); | 408 print('WARNING: Test skipped -- rule `$ruleName` is not registered.'); |
408 return; | 409 return; |
409 } | 410 } |
410 | 411 |
411 LinterOptions options = new LinterOptions([rule]) | 412 LinterOptions options = new LinterOptions([rule]) |
412 ..useMockSdk = true | 413 ..mockSdk = new MockSdk() |
413 ..packageRootPath = '.'; | 414 ..packageRootPath = '.'; |
414 | 415 |
415 DartLinter driver = new DartLinter(options); | 416 DartLinter driver = new DartLinter(options); |
416 | 417 |
417 Iterable<AnalysisErrorInfo> lints = driver.lintFiles([file]); | 418 Iterable<AnalysisErrorInfo> lints = driver.lintFiles([file]); |
418 | 419 |
419 List<Annotation> actual = []; | 420 List<Annotation> actual = []; |
420 lints.forEach((AnalysisErrorInfo info) { | 421 lints.forEach((AnalysisErrorInfo info) { |
421 info.errors.forEach((AnalysisError error) { | 422 info.errors.forEach((AnalysisError error) { |
422 if (error.errorCode.type == ErrorType.LINT) { | 423 if (error.errorCode.type == ErrorType.LINT) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 508 |
508 class NoFilter implements LintFilter { | 509 class NoFilter implements LintFilter { |
509 @override | 510 @override |
510 bool filter(AnalysisError lint) => false; | 511 bool filter(AnalysisError lint) => false; |
511 } | 512 } |
512 | 513 |
513 class ResultReporter extends DetailedReporter { | 514 class ResultReporter extends DetailedReporter { |
514 ResultReporter(Iterable<AnalysisErrorInfo> errors) | 515 ResultReporter(Iterable<AnalysisErrorInfo> errors) |
515 : super(errors, new NoFilter(), stdout); | 516 : super(errors, new NoFilter(), stdout); |
516 } | 517 } |
OLD | NEW |