| Index: packages/analyzer/lib/src/plugin/options_plugin.dart
|
| diff --git a/packages/analyzer/lib/src/plugin/options_plugin.dart b/packages/analyzer/lib/src/plugin/options_plugin.dart
|
| index 3fb5e914eaf63d8d3c356721fb9be413f3f5e4f4..aceaf3b6815ae96b610252ce3b9476a971280d9e 100644
|
| --- a/packages/analyzer/lib/src/plugin/options_plugin.dart
|
| +++ b/packages/analyzer/lib/src/plugin/options_plugin.dart
|
| @@ -2,9 +2,11 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -library analyzer.src.plugin.options;
|
| +library analyzer.src.plugin.options_plugin;
|
|
|
| import 'package:analyzer/plugin/options.dart';
|
| +import 'package:analyzer/plugin/task.dart';
|
| +import 'package:analyzer/src/task/options.dart';
|
| import 'package:plugin/plugin.dart';
|
|
|
| /// A plugin that defines the extension points and extensions that are defined
|
| @@ -15,38 +17,49 @@ 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.
|
| - ExtensionPoint optionsProcessorExtensionPoint;
|
| + /// The extension point that allows plugins to register new options
|
| + /// processors.
|
| + ExtensionPoint<OptionsProcessor> optionsProcessorExtensionPoint;
|
| +
|
| + /// The extension point that allows plugins to register new options
|
| + /// validators.
|
| + ExtensionPoint<OptionsValidator> optionsValidatorExtensionPoint;
|
|
|
| /// All contributed options processors.
|
| List<OptionsProcessor> get optionsProcessors =>
|
| - optionsProcessorExtensionPoint == null
|
| - ? const []
|
| - : optionsProcessorExtensionPoint.extensions;
|
| + optionsProcessorExtensionPoint?.extensions ?? const <OptionsProcessor>[];
|
| +
|
| + /// All contributed options validators.
|
| + List<OptionsValidator> get optionsValidators =>
|
| + optionsValidatorExtensionPoint?.extensions ?? const <OptionsValidator>[];
|
|
|
| @override
|
| String get uniqueIdentifier => UNIQUE_IDENTIFIER;
|
|
|
| @override
|
| void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
|
| - optionsProcessorExtensionPoint = registerExtensionPoint(
|
| - OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension);
|
| + optionsProcessorExtensionPoint = new ExtensionPoint<OptionsProcessor>(
|
| + this, OPTIONS_PROCESSOR_EXTENSION_POINT, null);
|
| + registerExtensionPoint(optionsProcessorExtensionPoint);
|
| + optionsValidatorExtensionPoint = new ExtensionPoint<OptionsValidator>(
|
| + this, OPTIONS_VALIDATOR_EXTENSION_POINT, null);
|
| + registerExtensionPoint(optionsValidatorExtensionPoint);
|
| }
|
|
|
| @override
|
| void registerExtensions(RegisterExtension registerExtension) {
|
| - // There are no default extensions.
|
| - }
|
| -
|
| - /// 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');
|
| - }
|
| + // Analyze options files.
|
| + registerExtension(
|
| + TASK_EXTENSION_POINT_ID, GenerateOptionsErrorsTask.DESCRIPTOR);
|
| + // Validate analyzer analysis options.
|
| + registerExtension(
|
| + OPTIONS_VALIDATOR_EXTENSION_POINT_ID, new AnalyzerOptionsValidator());
|
| }
|
| }
|
|
|