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

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

Issue 1317213004: Use contributed ResultDescriptor(s) while computing DART_ERRORS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/task.dart ('k') | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.engine_plugin; 5 library analyzer.src.plugin.engine_plugin;
6 6
7 import 'package:analyzer/plugin/task.dart'; 7 import 'package:analyzer/plugin/task.dart';
8 import 'package:analyzer/src/generated/engine.dart' 8 import 'package:analyzer/src/generated/engine.dart'
9 show InternalAnalysisContext; 9 show InternalAnalysisContext;
10 import 'package:analyzer/src/task/dart.dart'; 10 import 'package:analyzer/src/task/dart.dart';
11 import 'package:analyzer/src/task/dart_work_manager.dart'; 11 import 'package:analyzer/src/task/dart_work_manager.dart';
12 import 'package:analyzer/src/task/general.dart'; 12 import 'package:analyzer/src/task/general.dart';
13 import 'package:analyzer/src/task/html.dart'; 13 import 'package:analyzer/src/task/html.dart';
14 import 'package:analyzer/src/task/html_work_manager.dart'; 14 import 'package:analyzer/src/task/html_work_manager.dart';
15 import 'package:analyzer/task/model.dart'; 15 import 'package:analyzer/task/model.dart';
16 import 'package:plugin/plugin.dart'; 16 import 'package:plugin/plugin.dart';
17 17
18 /** 18 /**
19 * A plugin that defines the extension points and extensions that are inherently 19 * A plugin that defines the extension points and extensions that are inherently
20 * defined by the analysis engine. 20 * defined by the analysis engine.
21 */ 21 */
22 class EnginePlugin implements Plugin { 22 class EnginePlugin implements Plugin {
23 /** 23 /**
24 * The simple identifier of the extension point that allows plugins to 24 * The simple identifier of the extension point that allows plugins to
25 * register new analysis error results to compute for a Dart source.
26 */
27 static const String DART_ERRORS_FOR_SOURCE_EXTENSION_POINT =
28 'dartErrorsForSource';
29
30 /**
31 * The simple identifier of the extension point that allows plugins to
32 * register new analysis error results to compute for a Dart library
33 * specific unit.
34 */
35 static const String DART_ERRORS_FOR_UNIT_EXTENSION_POINT =
36 'dartErrorsForUnit';
37
38 /**
39 * The simple identifier of the extension point that allows plugins to
25 * register new analysis tasks with the analysis engine. 40 * register new analysis tasks with the analysis engine.
26 */ 41 */
27 static const String TASK_EXTENSION_POINT = 'task'; 42 static const String TASK_EXTENSION_POINT = 'task';
28 43
29 /** 44 /**
30 * The simple identifier of the extension point that allows plugins to 45 * The simple identifier of the extension point that allows plugins to
31 * register new work manager factories with the analysis engine. 46 * register new work manager factories with the analysis engine.
32 */ 47 */
33 static const String WORK_MANAGER_FACTORY_EXTENSION_POINT = 48 static const String WORK_MANAGER_FACTORY_EXTENSION_POINT =
34 'workManagerFactory'; 49 'workManagerFactory';
35 50
36 /** 51 /**
37 * The unique identifier of this plugin. 52 * The unique identifier of this plugin.
38 */ 53 */
39 static const String UNIQUE_IDENTIFIER = 'analysis_engine.core'; 54 static const String UNIQUE_IDENTIFIER = 'analysis_engine.core';
40 55
41 /** 56 /**
57 * The extension point that allows plugins to register new analysis error
58 * results for a Dart source.
59 */
60 ExtensionPoint dartErrorsForSourceExtensionPoint;
61
62 /**
63 * The extension point that allows plugins to register new analysis error
64 * results for a Dart library specific unit.
65 */
66 ExtensionPoint dartErrorsForUnitExtensionPoint;
67
68 /**
42 * The extension point that allows plugins to register new analysis tasks with 69 * The extension point that allows plugins to register new analysis tasks with
43 * the analysis engine. 70 * the analysis engine.
44 */ 71 */
45 ExtensionPoint taskExtensionPoint; 72 ExtensionPoint taskExtensionPoint;
46 73
47 /** 74 /**
48 * The extension point that allows plugins to register new work manager 75 * The extension point that allows plugins to register new work manager
49 * factories with the analysis engine. 76 * factories with the analysis engine.
50 */ 77 */
51 ExtensionPoint workManagerFactoryExtensionPoint; 78 ExtensionPoint workManagerFactoryExtensionPoint;
52 79
53 /** 80 /**
54 * Initialize a newly created plugin. 81 * Initialize a newly created plugin.
55 */ 82 */
56 EnginePlugin(); 83 EnginePlugin();
57 84
58 /** 85 /**
86 * Return a list containing all of the contributed analysis error result
87 * descriptors for Dart sources.
88 */
89 List<TaskDescriptor> get dartErrorsForSource =>
90 dartErrorsForSourceExtensionPoint.extensions;
91
92 /**
93 * Return a list containing all of the contributed analysis error result
94 * descriptors for Dart library specific units.
95 */
96 List<TaskDescriptor> get dartErrorsForUnit =>
97 dartErrorsForUnitExtensionPoint.extensions;
98
99 /**
59 * Return a list containing all of the task descriptors that were contributed. 100 * Return a list containing all of the task descriptors that were contributed.
60 */ 101 */
61 List<TaskDescriptor> get taskDescriptors => taskExtensionPoint.extensions; 102 List<TaskDescriptor> get taskDescriptors => taskExtensionPoint.extensions;
62 103
63 @override 104 @override
64 String get uniqueIdentifier => UNIQUE_IDENTIFIER; 105 String get uniqueIdentifier => UNIQUE_IDENTIFIER;
65 106
66 /** 107 /**
67 * Return a list containing all of the work manager factories that were 108 * Return a list containing all of the work manager factories that were
68 * contributed. 109 * contributed.
69 */ 110 */
70 List<WorkManagerFactory> get workManagerFactories => 111 List<WorkManagerFactory> get workManagerFactories =>
71 workManagerFactoryExtensionPoint.extensions; 112 workManagerFactoryExtensionPoint.extensions;
72 113
73 @override 114 @override
74 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { 115 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
116 dartErrorsForSourceExtensionPoint = registerExtensionPoint(
117 DART_ERRORS_FOR_SOURCE_EXTENSION_POINT, _validateResultDescriptor);
118 dartErrorsForUnitExtensionPoint = registerExtensionPoint(
119 DART_ERRORS_FOR_UNIT_EXTENSION_POINT, _validateResultDescriptor);
75 taskExtensionPoint = 120 taskExtensionPoint =
76 registerExtensionPoint(TASK_EXTENSION_POINT, _validateTaskExtension); 121 registerExtensionPoint(TASK_EXTENSION_POINT, _validateTaskExtension);
77 workManagerFactoryExtensionPoint = registerExtensionPoint( 122 workManagerFactoryExtensionPoint = registerExtensionPoint(
78 WORK_MANAGER_FACTORY_EXTENSION_POINT, 123 WORK_MANAGER_FACTORY_EXTENSION_POINT,
79 _validateWorkManagerFactoryExtension); 124 _validateWorkManagerFactoryExtension);
80 } 125 }
81 126
82 @override 127 @override
83 void registerExtensions(RegisterExtension registerExtension) { 128 void registerExtensions(RegisterExtension registerExtension) {
84 _registerTaskExtensions(registerExtension); 129 _registerTaskExtensions(registerExtension);
85 _registerWorkManagerFactoryExtensions(registerExtension); 130 _registerWorkManagerFactoryExtensions(registerExtension);
131 _registerDartErrorsForSource(registerExtension);
132 _registerDartErrorsForUnit(registerExtension);
133 }
134
135 void _registerDartErrorsForSource(RegisterExtension registerExtension) {
136 String id = DART_ERRORS_FOR_SOURCE_EXTENSION_POINT_ID;
137 registerExtension(id, BUILD_DIRECTIVES_ERRORS);
138 registerExtension(id, BUILD_LIBRARY_ERRORS);
139 registerExtension(id, PARSE_ERRORS);
140 registerExtension(id, SCAN_ERRORS);
141 }
142
143 void _registerDartErrorsForUnit(RegisterExtension registerExtension) {
144 String id = DART_ERRORS_FOR_UNIT_EXTENSION_POINT_ID;
145 registerExtension(id, LIBRARY_UNIT_ERRORS);
86 } 146 }
87 147
88 void _registerTaskExtensions(RegisterExtension registerExtension) { 148 void _registerTaskExtensions(RegisterExtension registerExtension) {
89 String taskId = TASK_EXTENSION_POINT_ID; 149 String taskId = TASK_EXTENSION_POINT_ID;
90 // 150 //
91 // Register general tasks. 151 // Register general tasks.
92 // 152 //
93 registerExtension(taskId, GetContentTask.DESCRIPTOR); 153 registerExtension(taskId, GetContentTask.DESCRIPTOR);
94 // 154 //
95 // Register Dart tasks. 155 // Register Dart tasks.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void _registerWorkManagerFactoryExtensions( 198 void _registerWorkManagerFactoryExtensions(
139 RegisterExtension registerExtension) { 199 RegisterExtension registerExtension) {
140 String taskId = WORK_MANAGER_EXTENSION_POINT_ID; 200 String taskId = WORK_MANAGER_EXTENSION_POINT_ID;
141 registerExtension(taskId, 201 registerExtension(taskId,
142 (InternalAnalysisContext context) => new DartWorkManager(context)); 202 (InternalAnalysisContext context) => new DartWorkManager(context));
143 registerExtension(taskId, 203 registerExtension(taskId,
144 (InternalAnalysisContext context) => new HtmlWorkManager(context)); 204 (InternalAnalysisContext context) => new HtmlWorkManager(context));
145 } 205 }
146 206
147 /** 207 /**
148 * Validate the given extension by throwing an [ExtensionError] if it is not a 208 * Validate the given extension by throwing an [ExtensionError] if it is not
149 * valid domain. 209 * a [ResultDescriptor].
210 */
211 void _validateResultDescriptor(Object extension) {
212 if (extension is! ResultDescriptor) {
213 String id = taskExtensionPoint.uniqueIdentifier;
214 throw new ExtensionError('Extensions to $id must be a ResultDescriptor');
215 }
216 }
217
218 /**
219 * Validate the given extension by throwing an [ExtensionError] if it is not
220 * a [TaskDescriptor].
150 */ 221 */
151 void _validateTaskExtension(Object extension) { 222 void _validateTaskExtension(Object extension) {
152 if (extension is! TaskDescriptor) { 223 if (extension is! TaskDescriptor) {
153 String id = taskExtensionPoint.uniqueIdentifier; 224 String id = taskExtensionPoint.uniqueIdentifier;
154 throw new ExtensionError('Extensions to $id must be a TaskDescriptor'); 225 throw new ExtensionError('Extensions to $id must be a TaskDescriptor');
155 } 226 }
156 } 227 }
157 228
158 /** 229 /**
159 * Validate the given extension by throwing an [ExtensionError] if it is not a 230 * Validate the given extension by throwing an [ExtensionError] if it is not
160 * valid domain. 231 * a [WorkManagerFactory].
161 */ 232 */
162 void _validateWorkManagerFactoryExtension(Object extension) { 233 void _validateWorkManagerFactoryExtension(Object extension) {
163 if (extension is! WorkManagerFactory) { 234 if (extension is! WorkManagerFactory) {
164 String id = taskExtensionPoint.uniqueIdentifier; 235 String id = taskExtensionPoint.uniqueIdentifier;
165 throw new ExtensionError( 236 throw new ExtensionError(
166 'Extensions to $id must be a WorkManagerFactory'); 237 'Extensions to $id must be a WorkManagerFactory');
167 } 238 }
168 } 239 }
169 } 240 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/plugin/task.dart ('k') | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698