| 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 lint; | 5 library lint; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/utilities_general.dart'; | 8 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 final Iterable<CompilationUnit> _compilationUnits; | 36 final Iterable<CompilationUnit> _compilationUnits; |
| 37 final AnalysisErrorListener _errorListener; | 37 final AnalysisErrorListener _errorListener; |
| 38 final Iterable<Linter> _linters; | 38 final Iterable<Linter> _linters; |
| 39 | 39 |
| 40 LintGenerator(this._compilationUnits, this._errorListener, | 40 LintGenerator(this._compilationUnits, this._errorListener, |
| 41 [Iterable<Linter> linters]) | 41 [Iterable<Linter> linters]) |
| 42 : _linters = linters != null ? linters : LINTERS; | 42 : _linters = linters != null ? linters : LINTERS; |
| 43 | 43 |
| 44 void generate() { | 44 void generate() { |
| 45 TimeCounter_TimeCounterHandle timeCounter = | 45 PerformanceTag prevTag = PerformanceStatistics.lint.makeCurrent(); |
| 46 PerformanceStatistics.lint.start(); | |
| 47 try { | 46 try { |
| 48 _compilationUnits.forEach((cu) { | 47 _compilationUnits.forEach((cu) { |
| 49 if (cu.element != null) { | 48 if (cu.element != null) { |
| 50 _generate(cu, cu.element.source); | 49 _generate(cu, cu.element.source); |
| 51 } | 50 } |
| 52 }); | 51 }); |
| 53 } finally { | 52 } finally { |
| 54 timeCounter.stop(); | 53 prevTag.makeCurrent(); |
| 55 } | 54 } |
| 56 } | 55 } |
| 57 | 56 |
| 58 void _generate(CompilationUnit unit, Source source) { | 57 void _generate(CompilationUnit unit, Source source) { |
| 59 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); | 58 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); |
| 60 _linters.forEach((l) => l.reporter = errorReporter); | 59 _linters.forEach((l) => l.reporter = errorReporter); |
| 61 Iterable<AstVisitor> visitors = _linters.map((l) => l.getVisitor()); | 60 Iterable<AstVisitor> visitors = _linters.map((l) => l.getVisitor()); |
| 62 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null))); | 61 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null))); |
| 63 } | 62 } |
| 64 } | 63 } |
| OLD | NEW |