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.plugin.options; | 5 library analyzer.src.plugin.options; |
6 | 6 |
7 import 'package:analyzer/plugin/options.dart'; | 7 import 'package:analyzer/plugin/options.dart'; |
| 8 import 'package:analyzer/plugin/task.dart'; |
| 9 import 'package:analyzer/src/task/options.dart'; |
8 import 'package:plugin/plugin.dart'; | 10 import 'package:plugin/plugin.dart'; |
9 | 11 |
10 /// A plugin that defines the extension points and extensions that are defined | 12 /// A plugin that defines the extension points and extensions that are defined |
11 /// by applications that want to consume options defined in the analysis | 13 /// by applications that want to consume options defined in the analysis |
12 /// options file. | 14 /// options file. |
13 class OptionsPlugin implements Plugin { | 15 class OptionsPlugin implements Plugin { |
14 /// The simple identifier of the extension point that allows plugins to | 16 /// The simple identifier of the extension point that allows plugins to |
15 /// register new options processors. | 17 /// register new options processors. |
16 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor'; | 18 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor'; |
17 | 19 |
(...skipping 13 matching lines...) Expand all Loading... |
31 String get uniqueIdentifier => UNIQUE_IDENTIFIER; | 33 String get uniqueIdentifier => UNIQUE_IDENTIFIER; |
32 | 34 |
33 @override | 35 @override |
34 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { | 36 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { |
35 optionsProcessorExtensionPoint = registerExtensionPoint( | 37 optionsProcessorExtensionPoint = registerExtensionPoint( |
36 OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension); | 38 OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension); |
37 } | 39 } |
38 | 40 |
39 @override | 41 @override |
40 void registerExtensions(RegisterExtension registerExtension) { | 42 void registerExtensions(RegisterExtension registerExtension) { |
41 // There are no default extensions. | 43 // Analyze options files. |
| 44 registerExtension( |
| 45 TASK_EXTENSION_POINT_ID, GenerateOptionsErrorsTask.DESCRIPTOR); |
42 } | 46 } |
43 | 47 |
44 /// Validate the given extension by throwing an [ExtensionError] if it is not
a | 48 /// Validate the given extension by throwing an [ExtensionError] if it is not
a |
45 /// valid options processor. | 49 /// valid options processor. |
46 void _validateOptionsProcessorExtension(Object extension) { | 50 void _validateOptionsProcessorExtension(Object extension) { |
47 if (extension is! OptionsProcessor) { | 51 if (extension is! OptionsProcessor) { |
48 String id = optionsProcessorExtensionPoint.uniqueIdentifier; | 52 String id = optionsProcessorExtensionPoint.uniqueIdentifier; |
49 throw new ExtensionError('Extensions to $id must be an OptionsProcessor'); | 53 throw new ExtensionError('Extensions to $id must be an OptionsProcessor'); |
50 } | 54 } |
51 } | 55 } |
52 } | 56 } |
OLD | NEW |