Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: pkg/analyzer/lib/src/plugin/options_plugin.dart

Issue 1418333002: OptionsValidator plugin extension and linter service. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Review feedback. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/lib/src/task/options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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');
+ }
+ }
}
« no previous file with comments | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/lib/src/task/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698