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

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

Issue 1977413002: Improve type information and minor clean up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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 analyzer.src.services.lint; 5 library analyzer.src.services.lint;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/generated/error.dart'; 11 import 'package:analyzer/src/generated/error.dart';
12 import 'package:analyzer/src/task/model.dart'; 12 import 'package:analyzer/src/task/model.dart';
13 import 'package:analyzer/task/model.dart'; 13 import 'package:analyzer/task/model.dart';
14 14
15 const List<Linter> _noLints = const <Linter>[]; 15 const List<Linter> _noLints = const <Linter>[];
16 16
17 /// The descriptor used to associate lints with analysis contexts in 17 /// The descriptor used to associate lints with analysis contexts in
18 /// configuration data. 18 /// configuration data.
19 final ResultDescriptor<List<Linter>> CONFIGURED_LINTS_KEY = 19 final ResultDescriptor<List<Linter>> CONFIGURED_LINTS_KEY =
20 new ResultDescriptorImpl('configured.lints', _noLints); 20 new ResultDescriptorImpl('configured.lints', _noLints);
21 21
22 /// Shared lint registry. 22 /// Shared lint registry.
23 LintRegistry lintRegistry = new LintRegistry(); 23 LintRegistry lintRegistry = new LintRegistry();
24 24
25 /// Return lints associated with this [context], or an empty list if there are 25 /// Return lints associated with this [context], or an empty list if there are
26 /// none. 26 /// none.
27 List<Linter> getLints(AnalysisContext context) => 27 List<Linter> getLints(AnalysisContext context) =>
28 context.getConfigurationData(CONFIGURED_LINTS_KEY) as List<Linter> ?? 28 context.getConfigurationData(CONFIGURED_LINTS_KEY) ?? _noLints;
29 _noLints;
30 29
31 /// Associate these [lints] with the given [context]. 30 /// Associate these [lints] with the given [context].
32 void setLints(AnalysisContext context, List<Linter> lints) { 31 void setLints(AnalysisContext context, List<Linter> lints) {
33 context.setConfigurationData(CONFIGURED_LINTS_KEY, lints); 32 context.setConfigurationData(CONFIGURED_LINTS_KEY, lints);
34 } 33 }
35 34
36 /// Implementers contribute lint warnings via the provided error [reporter]. 35 /// Implementers contribute lint warnings via the provided error [reporter].
37 abstract class Linter { 36 abstract class Linter {
38 /// Used to report lint warnings. 37 /// Used to report lint warnings.
39 /// NOTE: this is set by the framework before visit begins. 38 /// NOTE: this is set by the framework before visit begins.
(...skipping 11 matching lines...) Expand all
51 /// Manages lint timing. 50 /// Manages lint timing.
52 class LintRegistry { 51 class LintRegistry {
53 /// Dictionary mapping lints (by name) to timers. 52 /// Dictionary mapping lints (by name) to timers.
54 final Map<String, Stopwatch> timers = new HashMap<String, Stopwatch>(); 53 final Map<String, Stopwatch> timers = new HashMap<String, Stopwatch>();
55 54
56 /// Get a timer associated with the given lint rule (or create one if none 55 /// Get a timer associated with the given lint rule (or create one if none
57 /// exists). 56 /// exists).
58 Stopwatch getTimer(Linter linter) => 57 Stopwatch getTimer(Linter linter) =>
59 timers.putIfAbsent(linter.name, () => new Stopwatch()); 58 timers.putIfAbsent(linter.name, () => new Stopwatch());
60 } 59 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/member.dart ('k') | pkg/analyzer/test/src/task/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698