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

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

Issue 1026483002: Add engine plugin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename missed variable Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | no next file » | 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.engine_plugin;
6
7 import 'package:analyzer/plugin/plugin.dart';
8 import 'package:analyzer/plugin/task.dart';
9 import 'package:analyzer/src/task/dart.dart';
10 import 'package:analyzer/src/task/general.dart';
11 import 'package:analyzer/task/model.dart';
12
13 /**
14 * A plugin that defines the extension points and extensions that are inherently
15 * defined by the analysis engine.
16 */
17 class EnginePlugin implements Plugin {
18 /**
19 * The simple identifier of the extension point that allows plugins to
20 * register new analysis tasks with the analysis engine.
21 */
22 static const String TASK_EXTENSION_POINT = 'task';
23
24 /**
25 * The unique identifier of this plugin.
26 */
27 static const String UNIQUE_IDENTIFIER = 'analysis_engine.core';
28
29 /**
30 * The extension point that allows plugins to register new analysis tasks with
31 * the analysis engine.
32 */
33 ExtensionPoint taskExtensionPoint;
34
35 /**
36 * Initialize a newly created plugin.
37 */
38 EnginePlugin();
39
40 /**
41 * Return a list containing all of the task descriptors that were contributed.
42 */
43 List<TaskDescriptor> taskDescriptors() {
44 return taskExtensionPoint.extensions;
45 }
46
47 @override
48 String get uniqueIdentifier => UNIQUE_IDENTIFIER;
49
50 @override
51 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
52 taskExtensionPoint =
53 registerExtensionPoint(TASK_EXTENSION_POINT, _validateTaskExtension);
54 }
55
56 @override
57 void registerExtensions(RegisterExtension registerExtension) {
58 String taskId = TASK_EXTENSION_POINT_ID;
59 //
60 // Register general tasks.
61 //
62 registerExtension(taskId, GetContentTask.DESCRIPTOR);
63 //
64 // Register Dart tasks.
65 //
66 registerExtension(taskId, BuildCompilationUnitElementTask.DESCRIPTOR);
67 registerExtension(taskId, BuildDirectiveElementsTask.DESCRIPTOR);
68 registerExtension(taskId, BuildEnumMemberElementsTask.DESCRIPTOR);
69 registerExtension(taskId, BuildExportNamespaceTask.DESCRIPTOR);
70 registerExtension(taskId, BuildExportSourceClosureTask.DESCRIPTOR);
71 registerExtension(taskId, BuildFunctionTypeAliasesTask.DESCRIPTOR);
72 registerExtension(taskId, BuildLibraryElementTask.DESCRIPTOR);
73 registerExtension(taskId, BuildPublicNamespaceTask.DESCRIPTOR);
74 registerExtension(taskId, BuildTypeProviderTask.DESCRIPTOR);
75 registerExtension(taskId, ParseDartTask.DESCRIPTOR);
76 registerExtension(taskId, ResolveTypeNamesTask.DESCRIPTOR);
77 registerExtension(taskId, ScanDartTask.DESCRIPTOR);
78 //
79 // Register HTML tasks.
80 //
81 }
82
83 /**
84 * Validate the given extension by throwing an [ExtensionError] if it is not a
85 * valid domain.
86 */
87 void _validateTaskExtension(Object extension) {
88 if (extension is! TaskDescriptor) {
89 String id = taskExtensionPoint.uniqueIdentifier;
90 throw new ExtensionError('Extensions to $id must be a TaskDescriptor');
91 }
92 }
93 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698