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

Side by Side Diff: pkg/analysis_server/lib/src/services/linter/linter.dart

Issue 2553203002: Move the linter core to the analyzer package (Closed)
Patch Set: Add missed files Created 4 years 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 services.src.linter; 5 library services.src.linter;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/plugin/options.dart'; 8 import 'package:analyzer/plugin/options.dart';
9 import 'package:linter/src/rules.dart'; 9 import 'package:analyzer/src/lint/registry.dart';
10 import 'package:yaml/yaml.dart'; 10 import 'package:yaml/yaml.dart';
11 11
12 /** 12 /**
13 * An error code indicating an undefined lint rule. 13 * An error code indicating an undefined lint rule.
14 * 14 *
15 * Parameters: 15 * Parameters:
16 * 0: the rule name 16 * 0: the rule name
17 */ 17 */
18 const AnalysisOptionsWarningCode UNDEFINED_LINT_WARNING = 18 const AnalysisOptionsWarningCode UNDEFINED_LINT_WARNING =
19 const AnalysisOptionsWarningCode( 19 const AnalysisOptionsWarningCode(
(...skipping 11 matching lines...) Expand all
31 if (node is YamlMap) { 31 if (node is YamlMap) {
32 var rules = node.nodes[rulesKey]; 32 var rules = node.nodes[rulesKey];
33 validateRules(rules, reporter); 33 validateRules(rules, reporter);
34 } 34 }
35 return errors; 35 return errors;
36 } 36 }
37 37
38 validateRules(dynamic rules, ErrorReporter reporter) { 38 validateRules(dynamic rules, ErrorReporter reporter) {
39 if (rules is YamlList) { 39 if (rules is YamlList) {
40 //TODO(pq): migrate this to a proper API once there is one. 40 //TODO(pq): migrate this to a proper API once there is one.
41 Iterable<String> registeredLints = ruleRegistry.map((r) => r.name); 41 Iterable<String> registeredLints =
42 Registry.ruleRegistry.map((r) => r.name);
42 rules.nodes.forEach((YamlNode ruleNode) { 43 rules.nodes.forEach((YamlNode ruleNode) {
43 Object value = ruleNode.value; 44 Object value = ruleNode.value;
44 if (value != null && !registeredLints.contains(value)) { 45 if (value != null && !registeredLints.contains(value)) {
45 reporter.reportErrorForSpan( 46 reporter.reportErrorForSpan(
46 UNDEFINED_LINT_WARNING, ruleNode.span, [value]); 47 UNDEFINED_LINT_WARNING, ruleNode.span, [value]);
47 } 48 }
48 }); 49 });
49 } 50 }
50 } 51 }
51 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698