OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library analyzer.src.plugin.options_plugin; | |
6 | |
7 import 'package:analyzer/plugin/options.dart'; | |
8 import 'package:analyzer/plugin/task.dart'; | |
9 import 'package:analyzer/src/task/options.dart'; | |
10 import 'package:plugin/plugin.dart'; | |
11 | |
12 /// A plugin that defines the extension points and extensions that are defined | |
13 /// by applications that want to consume options defined in the analysis | |
14 /// options file. | |
15 class OptionsPlugin implements Plugin { | |
16 /// The simple identifier of the extension point that allows plugins to | |
17 /// register new options validators. | |
18 static const String OPTIONS_VALIDATOR_EXTENSION_POINT = 'optionsValidator'; | |
19 | |
20 /// The unique identifier of this plugin. | |
21 static const String UNIQUE_IDENTIFIER = 'options.core'; | |
22 | |
23 /// The extension point that allows plugins to register new options | |
24 /// validators. | |
25 ExtensionPoint<OptionsValidator> optionsValidatorExtensionPoint; | |
26 | |
27 /// All contributed options validators. | |
28 List<OptionsValidator> get optionsValidators => | |
29 optionsValidatorExtensionPoint?.extensions ?? const <OptionsValidator>[]; | |
30 | |
31 @override | |
32 String get uniqueIdentifier => UNIQUE_IDENTIFIER; | |
33 | |
34 @override | |
35 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { | |
36 optionsValidatorExtensionPoint = new ExtensionPoint<OptionsValidator>( | |
37 this, OPTIONS_VALIDATOR_EXTENSION_POINT, null); | |
38 registerExtensionPoint(optionsValidatorExtensionPoint); | |
39 } | |
40 | |
41 @override | |
42 void registerExtensions(RegisterExtension registerExtension) { | |
43 // Analyze options files. | |
44 registerExtension( | |
45 TASK_EXTENSION_POINT_ID, GenerateOptionsErrorsTask.DESCRIPTOR); | |
46 // Validate analyzer analysis options. | |
47 registerExtension( | |
48 OPTIONS_VALIDATOR_EXTENSION_POINT_ID, new AnalyzerOptionsValidator()); | |
49 } | |
50 } | |
OLD | NEW |