Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: pkg/analyzer/lib/src/services/lint.dart

Issue 954013002: Replace try/finally with PerformanceTag.makeCurrentWhile(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698