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

Side by Side Diff: packages/analyzer/lib/src/plugin/options_plugin.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.plugin.options; 5 library analyzer.src.plugin.options_plugin;
6 6
7 import 'package:analyzer/plugin/options.dart'; 7 import 'package:analyzer/plugin/options.dart';
8 import 'package:analyzer/plugin/task.dart';
9 import 'package:analyzer/src/task/options.dart';
8 import 'package:plugin/plugin.dart'; 10 import 'package:plugin/plugin.dart';
9 11
10 /// A plugin that defines the extension points and extensions that are defined 12 /// A plugin that defines the extension points and extensions that are defined
11 /// by applications that want to consume options defined in the analysis 13 /// by applications that want to consume options defined in the analysis
12 /// options file. 14 /// options file.
13 class OptionsPlugin implements Plugin { 15 class OptionsPlugin implements Plugin {
14 /// The simple identifier of the extension point that allows plugins to 16 /// The simple identifier of the extension point that allows plugins to
15 /// register new options processors. 17 /// register new options processors.
16 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor'; 18 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor';
17 19
20 /// The simple identifier of the extension point that allows plugins to
21 /// register new options validators.
22 static const String OPTIONS_VALIDATOR_EXTENSION_POINT = 'optionsValidator';
23
18 /// The unique identifier of this plugin. 24 /// The unique identifier of this plugin.
19 static const String UNIQUE_IDENTIFIER = 'options.core'; 25 static const String UNIQUE_IDENTIFIER = 'options.core';
20 26
21 /// The extension point that allows plugins to register new options processors . 27 /// The extension point that allows plugins to register new options
22 ExtensionPoint optionsProcessorExtensionPoint; 28 /// processors.
29 ExtensionPoint<OptionsProcessor> optionsProcessorExtensionPoint;
30
31 /// The extension point that allows plugins to register new options
32 /// validators.
33 ExtensionPoint<OptionsValidator> optionsValidatorExtensionPoint;
23 34
24 /// All contributed options processors. 35 /// All contributed options processors.
25 List<OptionsProcessor> get optionsProcessors => 36 List<OptionsProcessor> get optionsProcessors =>
26 optionsProcessorExtensionPoint == null 37 optionsProcessorExtensionPoint?.extensions ?? const <OptionsProcessor>[];
27 ? const [] 38
28 : optionsProcessorExtensionPoint.extensions; 39 /// All contributed options validators.
40 List<OptionsValidator> get optionsValidators =>
41 optionsValidatorExtensionPoint?.extensions ?? const <OptionsValidator>[];
29 42
30 @override 43 @override
31 String get uniqueIdentifier => UNIQUE_IDENTIFIER; 44 String get uniqueIdentifier => UNIQUE_IDENTIFIER;
32 45
33 @override 46 @override
34 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { 47 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
35 optionsProcessorExtensionPoint = registerExtensionPoint( 48 optionsProcessorExtensionPoint = new ExtensionPoint<OptionsProcessor>(
36 OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension); 49 this, OPTIONS_PROCESSOR_EXTENSION_POINT, null);
50 registerExtensionPoint(optionsProcessorExtensionPoint);
51 optionsValidatorExtensionPoint = new ExtensionPoint<OptionsValidator>(
52 this, OPTIONS_VALIDATOR_EXTENSION_POINT, null);
53 registerExtensionPoint(optionsValidatorExtensionPoint);
37 } 54 }
38 55
39 @override 56 @override
40 void registerExtensions(RegisterExtension registerExtension) { 57 void registerExtensions(RegisterExtension registerExtension) {
41 // There are no default extensions. 58 // Analyze options files.
42 } 59 registerExtension(
43 60 TASK_EXTENSION_POINT_ID, GenerateOptionsErrorsTask.DESCRIPTOR);
44 /// Validate the given extension by throwing an [ExtensionError] if it is not a 61 // Validate analyzer analysis options.
45 /// valid options processor. 62 registerExtension(
46 void _validateOptionsProcessorExtension(Object extension) { 63 OPTIONS_VALIDATOR_EXTENSION_POINT_ID, new AnalyzerOptionsValidator());
47 if (extension is! OptionsProcessor) {
48 String id = optionsProcessorExtensionPoint.uniqueIdentifier;
49 throw new ExtensionError('Extensions to $id must be an OptionsProcessor');
50 }
51 } 64 }
52 } 65 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/plugin/engine_plugin.dart ('k') | packages/analyzer/lib/src/plugin/plugin_configuration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698