| OLD | NEW |
| 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 analysis_server.src.plugin.server_plugin; | 5 library analysis_server.src.plugin.server_plugin; |
| 6 | 6 |
| 7 import 'package:analysis_server/analysis/analysis_domain.dart'; |
| 7 import 'package:analysis_server/analysis/index/index_core.dart'; | 8 import 'package:analysis_server/analysis/index/index_core.dart'; |
| 8 import 'package:analysis_server/analysis/navigation/navigation_core.dart'; | 9 import 'package:analysis_server/analysis/navigation/navigation_core.dart'; |
| 9 import 'package:analysis_server/completion/completion_core.dart'; | 10 import 'package:analysis_server/completion/completion_core.dart'; |
| 10 import 'package:analysis_server/edit/assist/assist_core.dart'; | 11 import 'package:analysis_server/edit/assist/assist_core.dart'; |
| 11 import 'package:analysis_server/edit/fix/fix_core.dart'; | 12 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| 12 import 'package:analysis_server/plugin/analyzed_files.dart'; | 13 import 'package:analysis_server/plugin/analyzed_files.dart'; |
| 13 import 'package:analysis_server/plugin/assist.dart'; | 14 import 'package:analysis_server/plugin/assist.dart'; |
| 14 import 'package:analysis_server/plugin/fix.dart'; | 15 import 'package:analysis_server/plugin/fix.dart'; |
| 15 import 'package:analysis_server/plugin/navigation.dart'; | 16 import 'package:analysis_server/plugin/navigation.dart'; |
| 16 import 'package:analysis_server/src/analysis_server.dart'; | 17 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 static const String INDEX_CONTRIBUTOR_EXTENSION_POINT = 'indexContributor'; | 78 static const String INDEX_CONTRIBUTOR_EXTENSION_POINT = 'indexContributor'; |
| 78 | 79 |
| 79 /** | 80 /** |
| 80 * The simple identifier of the extension point that allows plugins to | 81 * The simple identifier of the extension point that allows plugins to |
| 81 * register navigation contributors. | 82 * register navigation contributors. |
| 82 */ | 83 */ |
| 83 static const String NAVIGATION_CONTRIBUTOR_EXTENSION_POINT = | 84 static const String NAVIGATION_CONTRIBUTOR_EXTENSION_POINT = |
| 84 'navigationContributor'; | 85 'navigationContributor'; |
| 85 | 86 |
| 86 /** | 87 /** |
| 88 * The simple identifier of the extension point that allows plugins to |
| 89 * register analysis result listeners. |
| 90 */ |
| 91 static const String SET_ANALISYS_DOMAIN_EXTENSION_POINT = 'setAnalysisDomain'; |
| 92 |
| 93 /** |
| 87 * The unique identifier of this plugin. | 94 * The unique identifier of this plugin. |
| 88 */ | 95 */ |
| 89 static const String UNIQUE_IDENTIFIER = 'analysis_server.core'; | 96 static const String UNIQUE_IDENTIFIER = 'analysis_server.core'; |
| 90 | 97 |
| 91 /** | 98 /** |
| 92 * The extension point that allows plugins to register functions that can | 99 * The extension point that allows plugins to register functions that can |
| 93 * cause files to be analyzed. | 100 * cause files to be analyzed. |
| 94 */ | 101 */ |
| 95 ExtensionPoint analyzeFileExtensionPoint; | 102 ExtensionPoint analyzeFileExtensionPoint; |
| 96 | 103 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 121 * The extension point that allows plugins to register index contributors. | 128 * The extension point that allows plugins to register index contributors. |
| 122 */ | 129 */ |
| 123 ExtensionPoint indexContributorExtensionPoint; | 130 ExtensionPoint indexContributorExtensionPoint; |
| 124 | 131 |
| 125 /** | 132 /** |
| 126 * The extension point that allows plugins to register navigation contributors
. | 133 * The extension point that allows plugins to register navigation contributors
. |
| 127 */ | 134 */ |
| 128 ExtensionPoint navigationContributorExtensionPoint; | 135 ExtensionPoint navigationContributorExtensionPoint; |
| 129 | 136 |
| 130 /** | 137 /** |
| 138 * The extension point that allows plugins to get access to the `analysis` |
| 139 * domain. |
| 140 */ |
| 141 ExtensionPoint setAnalysisDomainExtensionPoint; |
| 142 |
| 143 /** |
| 131 * Initialize a newly created plugin. | 144 * Initialize a newly created plugin. |
| 132 */ | 145 */ |
| 133 ServerPlugin(); | 146 ServerPlugin(); |
| 134 | 147 |
| 135 /** | 148 /** |
| 136 * Return a list containing all of the functions that can cause files to be | 149 * Return a list containing all of the functions that can cause files to be |
| 137 * analyzed. | 150 * analyzed. |
| 138 */ | 151 */ |
| 139 List<ShouldAnalyzeFile> get analyzeFileFunctions => | 152 List<ShouldAnalyzeFile> get analyzeFileFunctions => |
| 140 analyzeFileExtensionPoint.extensions; | 153 analyzeFileExtensionPoint.extensions; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 166 List<IndexContributor> get indexContributors => | 179 List<IndexContributor> get indexContributors => |
| 167 indexContributorExtensionPoint.extensions; | 180 indexContributorExtensionPoint.extensions; |
| 168 | 181 |
| 169 /** | 182 /** |
| 170 * Return a list containing all of the navigation contributors that were | 183 * Return a list containing all of the navigation contributors that were |
| 171 * contributed. | 184 * contributed. |
| 172 */ | 185 */ |
| 173 List<NavigationContributor> get navigationContributors => | 186 List<NavigationContributor> get navigationContributors => |
| 174 navigationContributorExtensionPoint.extensions; | 187 navigationContributorExtensionPoint.extensions; |
| 175 | 188 |
| 189 /** |
| 190 * Return a list containing all of the receivers of the `analysis` domain |
| 191 * instance. |
| 192 */ |
| 193 List<SetAnalysisDomain> get setAnalysisDomainFunctions => |
| 194 setAnalysisDomainExtensionPoint.extensions; |
| 195 |
| 176 @override | 196 @override |
| 177 String get uniqueIdentifier => UNIQUE_IDENTIFIER; | 197 String get uniqueIdentifier => UNIQUE_IDENTIFIER; |
| 178 | 198 |
| 179 /** | 199 /** |
| 180 * Use the given [server] to create all of the domains ([RequestHandler]'s) | 200 * Use the given [server] to create all of the domains ([RequestHandler]'s) |
| 181 * that have been registered and return the newly created domains. | 201 * that have been registered and return the newly created domains. |
| 182 */ | 202 */ |
| 183 List<RequestHandler> createDomains(AnalysisServer server) { | 203 List<RequestHandler> createDomains(AnalysisServer server) { |
| 184 if (domainExtensionPoint == null) { | 204 if (domainExtensionPoint == null) { |
| 185 return <RequestHandler>[]; | 205 return <RequestHandler>[]; |
| 186 } | 206 } |
| 187 return domainExtensionPoint.extensions | 207 return domainExtensionPoint.extensions |
| 188 .map((RequestHandlerFactory factory) => factory(server)) | 208 .map((RequestHandlerFactory factory) => factory(server)) |
| 189 .toList(); | 209 .toList(); |
| 190 } | 210 } |
| 191 | 211 |
| 192 @override | 212 @override |
| 193 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { | 213 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { |
| 214 setAnalysisDomainExtensionPoint = registerExtensionPoint( |
| 215 SET_ANALISYS_DOMAIN_EXTENSION_POINT, |
| 216 _validateSetAnalysisDomainFunction); |
| 194 analyzeFileExtensionPoint = registerExtensionPoint( | 217 analyzeFileExtensionPoint = registerExtensionPoint( |
| 195 ANALYZE_FILE_EXTENSION_POINT, _validateAnalyzeFileExtension); | 218 ANALYZE_FILE_EXTENSION_POINT, _validateAnalyzeFileExtension); |
| 196 assistContributorExtensionPoint = registerExtensionPoint( | 219 assistContributorExtensionPoint = registerExtensionPoint( |
| 197 ASSIST_CONTRIBUTOR_EXTENSION_POINT, | 220 ASSIST_CONTRIBUTOR_EXTENSION_POINT, |
| 198 _validateAssistContributorExtension); | 221 _validateAssistContributorExtension); |
| 199 completionContributorExtensionPoint = registerExtensionPoint( | 222 completionContributorExtensionPoint = registerExtensionPoint( |
| 200 COMPLETION_CONTRIBUTOR_EXTENSION_POINT, | 223 COMPLETION_CONTRIBUTOR_EXTENSION_POINT, |
| 201 _validateCompletionContributorExtension); | 224 _validateCompletionContributorExtension); |
| 202 domainExtensionPoint = registerExtensionPoint( | 225 domainExtensionPoint = registerExtensionPoint( |
| 203 DOMAIN_EXTENSION_POINT, _validateDomainExtension); | 226 DOMAIN_EXTENSION_POINT, _validateDomainExtension); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 286 } |
| 264 | 287 |
| 265 /** | 288 /** |
| 266 * Validate the given extension by throwing an [ExtensionError] if it is not a | 289 * Validate the given extension by throwing an [ExtensionError] if it is not a |
| 267 * valid assist contributor. | 290 * valid assist contributor. |
| 268 */ | 291 */ |
| 269 void _validateAnalyzeFileExtension(Object extension) { | 292 void _validateAnalyzeFileExtension(Object extension) { |
| 270 if (extension is! ShouldAnalyzeFile) { | 293 if (extension is! ShouldAnalyzeFile) { |
| 271 String id = analyzeFileExtensionPoint.uniqueIdentifier; | 294 String id = analyzeFileExtensionPoint.uniqueIdentifier; |
| 272 throw new ExtensionError( | 295 throw new ExtensionError( |
| 273 'Extensions to $id must be an ShouldAnalyzeFile function'); | 296 'Extensions to $id must be a ShouldAnalyzeFile function'); |
| 274 } | 297 } |
| 275 } | 298 } |
| 276 | 299 |
| 277 /** | 300 /** |
| 278 * Validate the given extension by throwing an [ExtensionError] if it is not a | 301 * Validate the given extension by throwing an [ExtensionError] if it is not a |
| 279 * valid assist contributor. | 302 * valid assist contributor. |
| 280 */ | 303 */ |
| 281 void _validateAssistContributorExtension(Object extension) { | 304 void _validateAssistContributorExtension(Object extension) { |
| 282 if (extension is! AssistContributor) { | 305 if (extension is! AssistContributor) { |
| 283 String id = assistContributorExtensionPoint.uniqueIdentifier; | 306 String id = assistContributorExtensionPoint.uniqueIdentifier; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 * Validate the given extension by throwing an [ExtensionError] if it is not a | 359 * Validate the given extension by throwing an [ExtensionError] if it is not a |
| 337 * valid navigation contributor. | 360 * valid navigation contributor. |
| 338 */ | 361 */ |
| 339 void _validateNavigationContributorExtension(Object extension) { | 362 void _validateNavigationContributorExtension(Object extension) { |
| 340 if (extension is! NavigationContributor) { | 363 if (extension is! NavigationContributor) { |
| 341 String id = navigationContributorExtensionPoint.uniqueIdentifier; | 364 String id = navigationContributorExtensionPoint.uniqueIdentifier; |
| 342 throw new ExtensionError( | 365 throw new ExtensionError( |
| 343 'Extensions to $id must be an NavigationContributor'); | 366 'Extensions to $id must be an NavigationContributor'); |
| 344 } | 367 } |
| 345 } | 368 } |
| 369 |
| 370 /** |
| 371 * Validate the given extension by throwing an [ExtensionError] if it is not a |
| 372 * valid analysis domain receiver. |
| 373 */ |
| 374 void _validateSetAnalysisDomainFunction(Object extension) { |
| 375 if (extension is! SetAnalysisDomain) { |
| 376 String id = setAnalysisDomainExtensionPoint.uniqueIdentifier; |
| 377 throw new ExtensionError( |
| 378 'Extensions to $id must be a SetAnalysisDomain function'); |
| 379 } |
| 380 } |
| 346 } | 381 } |
| OLD | NEW |