| Index: pkg/analyzer/lib/src/plugin/options_plugin.dart
|
| diff --git a/pkg/analyzer/lib/src/plugin/options_plugin.dart b/pkg/analyzer/lib/src/plugin/options_plugin.dart
|
| index bde9376f613d48b1c41c234c73f641723c711fa4..6e0ebd61e84cbfd698139466e9e221ef012e8a3c 100644
|
| --- a/pkg/analyzer/lib/src/plugin/options_plugin.dart
|
| +++ b/pkg/analyzer/lib/src/plugin/options_plugin.dart
|
| @@ -17,17 +17,28 @@ class OptionsPlugin implements Plugin {
|
| /// register new options processors.
|
| static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor';
|
|
|
| + /// The simple identifier of the extension point that allows plugins to
|
| + /// register new options validators.
|
| + static const String OPTIONS_VALIDATOR_EXTENSION_POINT = 'optionsValidator';
|
| +
|
| /// The unique identifier of this plugin.
|
| static const String UNIQUE_IDENTIFIER = 'options.core';
|
|
|
| - /// The extension point that allows plugins to register new options processors.
|
| + /// The extension point that allows plugins to register new options
|
| + /// processors.
|
| ExtensionPoint optionsProcessorExtensionPoint;
|
|
|
| + /// The extension point that allows plugins to register new options
|
| + /// validators.
|
| + ExtensionPoint optionsValidatorExtensionPoint;
|
| +
|
| /// All contributed options processors.
|
| List<OptionsProcessor> get optionsProcessors =>
|
| - optionsProcessorExtensionPoint == null
|
| - ? const []
|
| - : optionsProcessorExtensionPoint.extensions;
|
| + optionsProcessorExtensionPoint?.extensions ?? const [];
|
| +
|
| + /// All contributed options validators.
|
| + List<OptionsValidator> get optionsValidators =>
|
| + optionsValidatorExtensionPoint?.extensions ?? const [];
|
|
|
| @override
|
| String get uniqueIdentifier => UNIQUE_IDENTIFIER;
|
| @@ -36,6 +47,8 @@ class OptionsPlugin implements Plugin {
|
| void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
|
| optionsProcessorExtensionPoint = registerExtensionPoint(
|
| OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension);
|
| + optionsValidatorExtensionPoint = registerExtensionPoint(
|
| + OPTIONS_VALIDATOR_EXTENSION_POINT, _validateOptionsValidatorExtension);
|
| }
|
|
|
| @override
|
| @@ -43,14 +56,26 @@ class OptionsPlugin implements Plugin {
|
| // Analyze options files.
|
| registerExtension(
|
| TASK_EXTENSION_POINT_ID, GenerateOptionsErrorsTask.DESCRIPTOR);
|
| + // Validate analyzer analysis options.
|
| + registerExtension(
|
| + OPTIONS_VALIDATOR_EXTENSION_POINT_ID, new AnalyzerOptionsValidator());
|
| }
|
|
|
| - /// Validate the given extension by throwing an [ExtensionError] if it is not a
|
| - /// valid options processor.
|
| + /// Validate the given extension by throwing an [ExtensionError] if it is not
|
| + /// a valid options processor.
|
| void _validateOptionsProcessorExtension(Object extension) {
|
| if (extension is! OptionsProcessor) {
|
| String id = optionsProcessorExtensionPoint.uniqueIdentifier;
|
| throw new ExtensionError('Extensions to $id must be an OptionsProcessor');
|
| }
|
| }
|
| +
|
| + /// Validate the given extension by throwing an [ExtensionError] if it is not
|
| + /// a valid options validator.
|
| + void _validateOptionsValidatorExtension(Object extension) {
|
| + if (extension is! OptionsValidator) {
|
| + String id = optionsValidatorExtensionPoint.uniqueIdentifier;
|
| + throw new ExtensionError('Extensions to $id must be an OptionsValidator');
|
| + }
|
| + }
|
| }
|
|
|