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

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

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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;
6 6
7 import 'package:analyzer/plugin/options.dart'; 7 import 'package:analyzer/plugin/options.dart';
8 import 'package:plugin/plugin.dart'; 8 import 'package:plugin/plugin.dart';
9 9
10 /// A plugin that defines the extension points and extensions that are defined 10 /// A plugin that defines the extension points and extensions that are defined
11 /// by applications that want to consume options defined in the analysis 11 /// by applications that want to consume options defined in the analysis
12 /// options file. 12 /// options file.
13 class OptionsPlugin implements Plugin { 13 class OptionsPlugin implements Plugin {
14 /// The simple identifier of the extension point that allows plugins to 14 /// The simple identifier of the extension point that allows plugins to
15 /// register new options processors. 15 /// register new options processors.
16 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor'; 16 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor';
17 17
18 /// The unique identifier of this plugin. 18 /// The unique identifier of this plugin.
19 static const String UNIQUE_IDENTIFIER = 'options.core'; 19 static const String UNIQUE_IDENTIFIER = 'options.core';
20 20
21 /// The extension point that allows plugins to register new options processors . 21 /// The extension point that allows plugins to register new options processors .
22 ExtensionPoint optionsProcessorExtensionPoint; 22 ExtensionPoint optionsProcessorExtensionPoint;
23 23
24 /// All contributed options processors. 24 /// All contributed options processors.
25 List<OptionsProcessor> get optionsProcessors => 25 List<OptionsProcessor> get optionsProcessors =>
26 optionsProcessorExtensionPoint.extensions; 26 optionsProcessorExtensionPoint == null
27 ? const []
28 : optionsProcessorExtensionPoint.extensions;
27 29
28 @override 30 @override
29 String get uniqueIdentifier => UNIQUE_IDENTIFIER; 31 String get uniqueIdentifier => UNIQUE_IDENTIFIER;
30 32
31 @override 33 @override
32 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { 34 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
33 optionsProcessorExtensionPoint = registerExtensionPoint( 35 optionsProcessorExtensionPoint = registerExtensionPoint(
34 OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension); 36 OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension);
35 } 37 }
36 38
37 @override 39 @override
38 void registerExtensions(RegisterExtension registerExtension) { 40 void registerExtensions(RegisterExtension registerExtension) {
39 // There are no default extensions. 41 // There are no default extensions.
40 } 42 }
41 43
42 /// Validate the given extension by throwing an [ExtensionError] if it is not a 44 /// Validate the given extension by throwing an [ExtensionError] if it is not a
43 /// valid options processor. 45 /// valid options processor.
44 void _validateOptionsProcessorExtension(Object extension) { 46 void _validateOptionsProcessorExtension(Object extension) {
45 if (extension is! OptionsProcessor) { 47 if (extension is! OptionsProcessor) {
46 String id = optionsProcessorExtensionPoint.uniqueIdentifier; 48 String id = optionsProcessorExtensionPoint.uniqueIdentifier;
47 throw new ExtensionError('Extensions to $id must be an OptionsProcessor'); 49 throw new ExtensionError('Extensions to $id must be an OptionsProcessor');
48 } 50 }
49 } 51 }
50 } 52 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/plugin/engine_plugin.dart ('k') | packages/analyzer/lib/src/services/lint.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698