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 library analyzer.src.task.options; | 5 library analyzer.src.task.options; |
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:analyzer/source/analysis_options_provider.dart'; | 9 import 'package:analyzer/source/analysis_options_provider.dart'; |
10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
11 import 'package:analyzer/src/generated/java_engine.dart'; | 11 import 'package:analyzer/src/generated/java_engine.dart'; |
12 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
13 import 'package:analyzer/src/task/general.dart'; | 13 import 'package:analyzer/src/task/general.dart'; |
14 import 'package:analyzer/task/general.dart'; | 14 import 'package:analyzer/task/general.dart'; |
15 import 'package:analyzer/task/model.dart'; | 15 import 'package:analyzer/task/model.dart'; |
16 import 'package:source_span/source_span.dart'; | 16 import 'package:source_span/source_span.dart'; |
17 import 'package:yaml/yaml.dart'; | 17 import 'package:yaml/yaml.dart'; |
18 | 18 |
19 /// The errors produced while parsing `.analysis_options` files. | 19 /// The errors produced while parsing `.analysis_options` files. |
20 /// | 20 /// |
21 /// The list will be empty if there were no errors, but will not be `null`. | 21 /// The list will be empty if there were no errors, but will not be `null`. |
22 final ListResultDescriptor<AnalysisError> ANALYSIS_OPTIONS_ERRORS = | 22 final ListResultDescriptor<AnalysisError> ANALYSIS_OPTIONS_ERRORS = |
23 new ListResultDescriptor<AnalysisError>( | 23 new ListResultDescriptor<AnalysisError>( |
24 'ANALYSIS_OPTIONS_ERRORS', AnalysisError.NO_ERRORS); | 24 'ANALYSIS_OPTIONS_ERRORS', AnalysisError.NO_ERRORS); |
25 | 25 |
| 26 /// `analyzer` analysis options constants. |
| 27 class AnalyzerOptions { |
| 28 static const String errors = 'errors'; |
| 29 static const String exclude = 'exclude'; |
| 30 static const String plugins = 'plugins'; |
| 31 static const String strong_mode = 'strong-mode'; |
| 32 |
| 33 /// Supported top-level `analyzer` options. |
| 34 static const List<String> top_level = const [ |
| 35 errors, |
| 36 exclude, |
| 37 plugins, |
| 38 strong_mode |
| 39 ]; |
| 40 } |
| 41 |
26 /// Validates `analyzer` top-level options. | 42 /// Validates `analyzer` top-level options. |
27 class AnalyzerOptionsValidator extends TopLevelOptionValidator { | 43 class AnalyzerOptionsValidator extends TopLevelOptionValidator { |
28 AnalyzerOptionsValidator() | 44 AnalyzerOptionsValidator() : super('analyzer', AnalyzerOptions.top_level); |
29 : super('analyzer', const ['exclude', 'plugins', 'strong-mode']); | |
30 } | 45 } |
31 | 46 |
32 /// Convenience class for composing validators. | 47 /// Convenience class for composing validators. |
33 class CompositeValidator extends OptionsValidator { | 48 class CompositeValidator extends OptionsValidator { |
34 final List<OptionsValidator> validators; | 49 final List<OptionsValidator> validators; |
35 CompositeValidator(this.validators); | 50 CompositeValidator(this.validators); |
36 | 51 |
37 @override | 52 @override |
38 void validate(ErrorReporter reporter, Map<String, YamlNode> options) => | 53 void validate(ErrorReporter reporter, Map<String, YamlNode> options) => |
39 validators.forEach((v) => v.validate(reporter, options)); | 54 validators.forEach((v) => v.validate(reporter, options)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION, | 167 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION, |
153 k.span, | 168 k.span, |
154 [pluginName, k.value]); | 169 [pluginName, k.value]); |
155 } | 170 } |
156 } | 171 } |
157 //TODO(pq): consider an error if the node is not a Scalar. | 172 //TODO(pq): consider an error if the node is not a Scalar. |
158 }); | 173 }); |
159 } | 174 } |
160 } | 175 } |
161 } | 176 } |
OLD | NEW |