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

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

Issue 1808123005: First batch of changes to make analyzer package strong mode error free (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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) ?? _noLints; 28 context.getConfigurationData(CONFIGURED_LINTS_KEY) as List<Linter> ??
29 _noLints;
29 30
30 /// Associate these [lints] with the given [context]. 31 /// Associate these [lints] with the given [context].
31 void setLints(AnalysisContext context, List<Linter> lints) { 32 void setLints(AnalysisContext context, List<Linter> lints) {
32 context.setConfigurationData(CONFIGURED_LINTS_KEY, lints); 33 context.setConfigurationData(CONFIGURED_LINTS_KEY, lints);
33 } 34 }
34 35
35 /// Implementers contribute lint warnings via the provided error [reporter]. 36 /// Implementers contribute lint warnings via the provided error [reporter].
36 abstract class Linter { 37 abstract class Linter {
37 /// Used to report lint warnings. 38 /// Used to report lint warnings.
38 /// NOTE: this is set by the framework before visit begins. 39 /// NOTE: this is set by the framework before visit begins.
(...skipping 11 matching lines...) Expand all
50 /// Manages lint timing. 51 /// Manages lint timing.
51 class LintRegistry { 52 class LintRegistry {
52 /// Dictionary mapping lints (by name) to timers. 53 /// Dictionary mapping lints (by name) to timers.
53 final Map<String, Stopwatch> timers = new HashMap<String, Stopwatch>(); 54 final Map<String, Stopwatch> timers = new HashMap<String, Stopwatch>();
54 55
55 /// Get a timer associated with the given lint rule (or create one if none 56 /// Get a timer associated with the given lint rule (or create one if none
56 /// exists). 57 /// exists).
57 Stopwatch getTimer(Linter linter) => 58 Stopwatch getTimer(Linter linter) =>
58 timers.putIfAbsent(linter.name, () => new Stopwatch()); 59 timers.putIfAbsent(linter.name, () => new Stopwatch());
59 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698