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

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

Issue 1175253005: Options plugin API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: doc updates Created 5 years, 6 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
« no previous file with comments | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analyzer.src.plugin.options;
6
7 import 'package:analyzer/plugin/options.dart';
8 import 'package:plugin/plugin.dart';
9
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
12 /// options file.
13 class OptionsPlugin implements Plugin {
14
15 /// The simple identifier of the extension point that allows plugins to
16 /// register new options processors.
17 static const String OPTIONS_PROCESSOR_EXTENSION_POINT = 'optionsProcessor';
18
19 /// The unique identifier of this plugin.
20 static const String UNIQUE_IDENTIFIER = 'options.core';
21
22 /// The extension point that allows plugins to register new options processors .
23 ExtensionPoint optionsProcessorExtensionPoint;
24
25 /// All contributed options processors.
26 List<OptionsProcessor> get optionsProcessors =>
27 optionsProcessorExtensionPoint.extensions;
28
29 @override
30 String get uniqueIdentifier => UNIQUE_IDENTIFIER;
31
32 @override
33 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
34 optionsProcessorExtensionPoint = registerExtensionPoint(
35 OPTIONS_PROCESSOR_EXTENSION_POINT, _validateOptionsProcessorExtension);
36 }
37
38 @override
39 void registerExtensions(RegisterExtension registerExtension) {
40 // There are no default extensions.
41 }
42
43 /// Validate the given extension by throwing an [ExtensionError] if it is not a
44 /// valid options processor.
45 void _validateOptionsProcessorExtension(Object extension) {
46 if (extension is! OptionsProcessor) {
47 String id = optionsProcessorExtensionPoint.uniqueIdentifier;
48 throw new ExtensionError('Extensions to $id must be an OptionsProcessor');
49 }
50 }
51 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698