| 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; | |
| 6 | |
| 7 import 'package:analyzer/plugin/options.dart'; | |
| 8 import 'package:plugin/plugin.dart'; | |
| 9 | |
| 10 /// A plugin that defines the extension points and extensions that are defined | |
| 11 /// by applications that want to consume options defined in the analysis | |
| 12 /// options file. | |
| 13 class OptionsPlugin implements Plugin { | |
| 14 | |
| 15 /// The simple identifier of the extension point that allows plugins to | |
| 16 /// register new options processors. | |
| 17 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor'; | |
| 18 | |
| 19 /// The unique identifier of this plugin. | |
| 20 static const String UNIQUE_IDENTIFIER = 'options.core'; | |
| 21 | |
| 22 /// The extension point that allows plugins to register new options processors
. | |
| 23 ExtensionPoint optionsProcessorExtensionPoint; | |
| 24 | |
| 25 /// All contributed options processors. | |
| 26 List<OptionsProcessor> get optionsProcessors => | |
| 27 optionsProcessorExtensionPoint.extensions; | |
| 28 | |
| 29 @override | |
| 30 String get uniqueIdentifier => UNIQUE_IDENTIFIER; | |
| 31 | |
| 32 @override | |
| 33 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { | |
| 34 optionsProcessorExtensionPoint = registerExtensionPoint( | |
| 35 OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension); | |
| 36 } | |
| 37 | |
| 38 @override | |
| 39 void registerExtensions(RegisterExtension registerExtension) { | |
| 40 // There are no default extensions. | |
| 41 } | |
| 42 | |
| 43 /// Validate the given extension by throwing an [ExtensionError] if it is not
a | |
| 44 /// valid options processor. | |
| 45 void _validateOptionsProcessorExtension(Object extension) { | |
| 46 if (extension is! OptionsProcessor) { | |
| 47 String id = optionsProcessorExtensionPoint.uniqueIdentifier; | |
| 48 throw new ExtensionError('Extensions to $id must be an OptionsProcessor'); | |
| 49 } | |
| 50 } | |
| 51 } | |
| OLD | NEW |