| 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 PerformanceTag prevTag = PerformanceStatistics.lint.makeCurrent(); | 45 PerformanceStatistics.lint.makeCurrentWhile(() { |
| 46 try { | |
| 47 _compilationUnits.forEach((cu) { | 46 _compilationUnits.forEach((cu) { |
| 48 if (cu.element != null) { | 47 if (cu.element != null) { |
| 49 _generate(cu, cu.element.source); | 48 _generate(cu, cu.element.source); |
| 50 } | 49 } |
| 51 }); | 50 }); |
| 52 } finally { | 51 }); |
| 53 prevTag.makeCurrent(); | |
| 54 } | |
| 55 } | 52 } |
| 56 | 53 |
| 57 void _generate(CompilationUnit unit, Source source) { | 54 void _generate(CompilationUnit unit, Source source) { |
| 58 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); | 55 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); |
| 59 _linters.forEach((l) => l.reporter = errorReporter); | 56 _linters.forEach((l) => l.reporter = errorReporter); |
| 60 Iterable<AstVisitor> visitors = _linters.map((l) => l.getVisitor()); | 57 Iterable<AstVisitor> visitors = _linters.map((l) => l.getVisitor()); |
| 61 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null))); | 58 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null))); |
| 62 } | 59 } |
| 63 } | 60 } |
| OLD | NEW |