| Index: pkg/analyzer/lib/src/task/options.dart
|
| diff --git a/pkg/analyzer/lib/src/task/options.dart b/pkg/analyzer/lib/src/task/options.dart
|
| index c80687bd88967f86b884e324dc7d2f06a9554716..80ac44f714593cafc19bd5acfeb3558165b3b79b 100644
|
| --- a/pkg/analyzer/lib/src/task/options.dart
|
| +++ b/pkg/analyzer/lib/src/task/options.dart
|
| @@ -5,6 +5,7 @@
|
| library analyzer.src.task.options;
|
|
|
| import 'package:analyzer/analyzer.dart';
|
| +import 'package:analyzer/plugin/options.dart';
|
| import 'package:analyzer/source/analysis_options_provider.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| @@ -27,6 +28,16 @@ class AnalyzerOptionsValidator extends TopLevelOptionValidator {
|
| : super('analyzer', const ['exclude', 'plugins', 'strong-mode']);
|
| }
|
|
|
| +/// Convenience class for composing validators.
|
| +class CompositeValidator extends OptionsValidator {
|
| + final List<OptionsValidator> validators;
|
| + CompositeValidator(this.validators);
|
| +
|
| + @override
|
| + void validate(ErrorReporter reporter, Map<String, YamlNode> options) =>
|
| + validators.forEach((v) => v.validate(reporter, options));
|
| +}
|
| +
|
| /// A task that generates errors for an `.analysis_options` file.
|
| class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask {
|
| /// The name of the input whose value is the content of the file.
|
| @@ -96,12 +107,15 @@ class LinterOptionsValidator extends TopLevelOptionValidator {
|
| /// Validates options defined in an `.analysis_options` file.
|
| class OptionsFileValidator {
|
| // TODO(pq): move to an extension point.
|
| - static final List<OptionsValidator> _validators = [
|
| - new AnalyzerOptionsValidator(), new LinterOptionsValidator()
|
| + final List<OptionsValidator> _validators = [
|
| + new AnalyzerOptionsValidator(),
|
| + new LinterOptionsValidator()
|
| ];
|
|
|
| final Source source;
|
| - OptionsFileValidator(this.source);
|
| + OptionsFileValidator(this.source) {
|
| + _validators.addAll(AnalysisEngine.instance.optionsPlugin.optionsValidators);
|
| + }
|
|
|
| List<AnalysisError> validate(Map<String, YamlNode> options) {
|
| RecordingErrorListener recorder = new RecordingErrorListener();
|
| @@ -111,12 +125,6 @@ class OptionsFileValidator {
|
| }
|
| }
|
|
|
| -/// Validates options.
|
| -abstract class OptionsValidator {
|
| - /// Validate [options], reporting any errors to the given [reporter].
|
| - void validate(ErrorReporter reporter, Map<String, YamlNode> options);
|
| -}
|
| -
|
| /// Validates top-level options. For example,
|
| /// plugin:
|
| /// top-level-option: true
|
|
|