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 import 'dart:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import 'package:analyzer/src/lint/config.dart'; | 7 import 'package:analyzer/src/lint/config.dart'; |
8 import 'package:analyzer/src/lint/linter.dart'; | 8 import 'package:analyzer/src/lint/linter.dart'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 27 matching lines...) Expand all Loading... |
38 * Return a list of the rules that are defined. | 38 * Return a list of the rules that are defined. |
39 */ | 39 */ |
40 Iterable<LintRule> get rules => _ruleMap.values; | 40 Iterable<LintRule> get rules => _ruleMap.values; |
41 | 41 |
42 /** | 42 /** |
43 * Return the lint rule with the given [name]. | 43 * Return the lint rule with the given [name]. |
44 */ | 44 */ |
45 LintRule operator [](String name) => _ruleMap[name]; | 45 LintRule operator [](String name) => _ruleMap[name]; |
46 | 46 |
47 /** | 47 /** |
48 * Return the lint rule with the given [name]. | |
49 */ | |
50 LintRule getRule(String name) => _ruleMap[name]; | |
51 | |
52 /** | |
53 * Return a list of the lint rules explicitly enabled by the given [config]. | 48 * Return a list of the lint rules explicitly enabled by the given [config]. |
54 * | 49 * |
55 * For example: | 50 * For example: |
56 * my_rule: true | 51 * my_rule: true |
57 * | 52 * |
58 * enables `my_rule`. | 53 * enables `my_rule`. |
59 * | 54 * |
60 * Unspecified rules are treated as disabled by default. | 55 * Unspecified rules are treated as disabled by default. |
61 */ | 56 */ |
62 Iterable<LintRule> enabled(LintConfig config) => rules | 57 Iterable<LintRule> enabled(LintConfig config) => rules |
63 .where((rule) => config.ruleConfigs.any((rc) => rc.enables(rule.name))); | 58 .where((rule) => config.ruleConfigs.any((rc) => rc.enables(rule.name))); |
64 | 59 |
65 /** | 60 /** |
| 61 * Return the lint rule with the given [name]. |
| 62 */ |
| 63 LintRule getRule(String name) => _ruleMap[name]; |
| 64 |
| 65 /** |
66 * Add the given lint [rule] to this registry. | 66 * Add the given lint [rule] to this registry. |
67 */ | 67 */ |
68 void register(LintRule rule) { | 68 void register(LintRule rule) { |
69 _ruleMap[rule.name] = rule; | 69 _ruleMap[rule.name] = rule; |
70 } | 70 } |
71 | 71 |
72 /** | 72 /** |
73 * Add the given lint [rule] to this registry and mark it as being a default | 73 * Add the given lint [rule] to this registry and mark it as being a default |
74 * lint (one that will be run if lints are requested but no rules are enabled. | 74 * lint (one that will be run if lints are requested but no rules are enabled. |
75 */ | 75 */ |
76 void registerDefault(LintRule rule) { | 76 void registerDefault(LintRule rule) { |
77 register(rule); | 77 register(rule); |
78 _defaultRules.add(rule); | 78 _defaultRules.add(rule); |
79 } | 79 } |
80 } | 80 } |
OLD | NEW |