| 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/index/index_core.dart'; | 7 import 'package:analysis_server/analysis/index/index_core.dart'; |
| 8 import 'package:analysis_server/analysis/navigation/navigation_core.dart'; |
| 8 import 'package:analysis_server/completion/completion_core.dart'; | 9 import 'package:analysis_server/completion/completion_core.dart'; |
| 9 import 'package:analysis_server/edit/assist/assist_core.dart'; | 10 import 'package:analysis_server/edit/assist/assist_core.dart'; |
| 10 import 'package:analysis_server/edit/fix/fix_core.dart'; | 11 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| 11 import 'package:analysis_server/plugin/analyzed_files.dart'; | 12 import 'package:analysis_server/plugin/analyzed_files.dart'; |
| 12 import 'package:analysis_server/plugin/assist.dart'; | 13 import 'package:analysis_server/plugin/assist.dart'; |
| 13 import 'package:analysis_server/plugin/fix.dart'; | 14 import 'package:analysis_server/plugin/fix.dart'; |
| 15 import 'package:analysis_server/plugin/navigation.dart'; |
| 14 import 'package:analysis_server/src/analysis_server.dart'; | 16 import 'package:analysis_server/src/analysis_server.dart'; |
| 15 import 'package:analysis_server/src/domain_analysis.dart'; | 17 import 'package:analysis_server/src/domain_analysis.dart'; |
| 16 import 'package:analysis_server/src/domain_completion.dart'; | 18 import 'package:analysis_server/src/domain_completion.dart'; |
| 17 import 'package:analysis_server/src/domain_execution.dart'; | 19 import 'package:analysis_server/src/domain_execution.dart'; |
| 18 import 'package:analysis_server/src/domain_server.dart'; | 20 import 'package:analysis_server/src/domain_server.dart'; |
| 21 import 'package:analysis_server/src/domains/analysis/navigation_dart.dart'; |
| 19 import 'package:analysis_server/src/edit/edit_domain.dart'; | 22 import 'package:analysis_server/src/edit/edit_domain.dart'; |
| 20 import 'package:analysis_server/src/protocol.dart'; | 23 import 'package:analysis_server/src/protocol.dart'; |
| 21 import 'package:analysis_server/src/search/search_domain.dart'; | 24 import 'package:analysis_server/src/search/search_domain.dart'; |
| 22 import 'package:analysis_server/src/services/correction/assist_internal.dart'; | 25 import 'package:analysis_server/src/services/correction/assist_internal.dart'; |
| 23 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 26 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
| 24 import 'package:analyzer/file_system/file_system.dart'; | 27 import 'package:analyzer/file_system/file_system.dart'; |
| 25 import 'package:analyzer/src/generated/engine.dart'; | 28 import 'package:analyzer/src/generated/engine.dart'; |
| 26 import 'package:plugin/plugin.dart'; | 29 import 'package:plugin/plugin.dart'; |
| 27 | 30 |
| 28 /** | 31 /** |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 */ | 70 */ |
| 68 static const String FIX_CONTRIBUTOR_EXTENSION_POINT = 'fixContributor'; | 71 static const String FIX_CONTRIBUTOR_EXTENSION_POINT = 'fixContributor'; |
| 69 | 72 |
| 70 /** | 73 /** |
| 71 * The simple identifier of the extension point that allows plugins to | 74 * The simple identifier of the extension point that allows plugins to |
| 72 * register index contributors. | 75 * register index contributors. |
| 73 */ | 76 */ |
| 74 static const String INDEX_CONTRIBUTOR_EXTENSION_POINT = 'indexContributor'; | 77 static const String INDEX_CONTRIBUTOR_EXTENSION_POINT = 'indexContributor'; |
| 75 | 78 |
| 76 /** | 79 /** |
| 80 * The simple identifier of the extension point that allows plugins to |
| 81 * register navigation contributors. |
| 82 */ |
| 83 static const String NAVIGATION_CONTRIBUTOR_EXTENSION_POINT = |
| 84 'navigationContributor'; |
| 85 |
| 86 /** |
| 77 * The unique identifier of this plugin. | 87 * The unique identifier of this plugin. |
| 78 */ | 88 */ |
| 79 static const String UNIQUE_IDENTIFIER = 'analysis_server.core'; | 89 static const String UNIQUE_IDENTIFIER = 'analysis_server.core'; |
| 80 | 90 |
| 81 /** | 91 /** |
| 82 * The extension point that allows plugins to register functions that can | 92 * The extension point that allows plugins to register functions that can |
| 83 * cause files to be analyzed. | 93 * cause files to be analyzed. |
| 84 */ | 94 */ |
| 85 ExtensionPoint analyzeFileExtensionPoint; | 95 ExtensionPoint analyzeFileExtensionPoint; |
| 86 | 96 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 106 * the server. | 116 * the server. |
| 107 */ | 117 */ |
| 108 ExtensionPoint fixContributorExtensionPoint; | 118 ExtensionPoint fixContributorExtensionPoint; |
| 109 | 119 |
| 110 /** | 120 /** |
| 111 * The extension point that allows plugins to register index contributors. | 121 * The extension point that allows plugins to register index contributors. |
| 112 */ | 122 */ |
| 113 ExtensionPoint indexContributorExtensionPoint; | 123 ExtensionPoint indexContributorExtensionPoint; |
| 114 | 124 |
| 115 /** | 125 /** |
| 126 * The extension point that allows plugins to register navigation contributors
. |
| 127 */ |
| 128 ExtensionPoint navigationContributorExtensionPoint; |
| 129 |
| 130 /** |
| 116 * Initialize a newly created plugin. | 131 * Initialize a newly created plugin. |
| 117 */ | 132 */ |
| 118 ServerPlugin(); | 133 ServerPlugin(); |
| 119 | 134 |
| 120 /** | 135 /** |
| 121 * Return a list containing all of the functions that can cause files to be | 136 * Return a list containing all of the functions that can cause files to be |
| 122 * analyzed. | 137 * analyzed. |
| 123 */ | 138 */ |
| 124 List<ShouldAnalyzeFile> get analyzeFileFunctions => | 139 List<ShouldAnalyzeFile> get analyzeFileFunctions => |
| 125 analyzeFileExtensionPoint.extensions; | 140 analyzeFileExtensionPoint.extensions; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 List<FixContributor> get fixContributors => | 159 List<FixContributor> get fixContributors => |
| 145 fixContributorExtensionPoint.extensions; | 160 fixContributorExtensionPoint.extensions; |
| 146 | 161 |
| 147 /** | 162 /** |
| 148 * Return a list containing all of the index contributors that were | 163 * Return a list containing all of the index contributors that were |
| 149 * contributed. | 164 * contributed. |
| 150 */ | 165 */ |
| 151 List<IndexContributor> get indexContributors => | 166 List<IndexContributor> get indexContributors => |
| 152 indexContributorExtensionPoint.extensions; | 167 indexContributorExtensionPoint.extensions; |
| 153 | 168 |
| 169 /** |
| 170 * Return a list containing all of the navigation contributors that were |
| 171 * contributed. |
| 172 */ |
| 173 List<NavigationContributor> get navigationContributors => |
| 174 navigationContributorExtensionPoint.extensions; |
| 175 |
| 154 @override | 176 @override |
| 155 String get uniqueIdentifier => UNIQUE_IDENTIFIER; | 177 String get uniqueIdentifier => UNIQUE_IDENTIFIER; |
| 156 | 178 |
| 157 /** | 179 /** |
| 158 * Use the given [server] to create all of the domains ([RequestHandler]'s) | 180 * Use the given [server] to create all of the domains ([RequestHandler]'s) |
| 159 * that have been registered and return the newly created domains. | 181 * that have been registered and return the newly created domains. |
| 160 */ | 182 */ |
| 161 List<RequestHandler> createDomains(AnalysisServer server) { | 183 List<RequestHandler> createDomains(AnalysisServer server) { |
| 162 if (domainExtensionPoint == null) { | 184 if (domainExtensionPoint == null) { |
| 163 return <RequestHandler>[]; | 185 return <RequestHandler>[]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 176 _validateAssistContributorExtension); | 198 _validateAssistContributorExtension); |
| 177 completionContributorExtensionPoint = registerExtensionPoint( | 199 completionContributorExtensionPoint = registerExtensionPoint( |
| 178 COMPLETION_CONTRIBUTOR_EXTENSION_POINT, | 200 COMPLETION_CONTRIBUTOR_EXTENSION_POINT, |
| 179 _validateCompletionContributorExtension); | 201 _validateCompletionContributorExtension); |
| 180 domainExtensionPoint = registerExtensionPoint( | 202 domainExtensionPoint = registerExtensionPoint( |
| 181 DOMAIN_EXTENSION_POINT, _validateDomainExtension); | 203 DOMAIN_EXTENSION_POINT, _validateDomainExtension); |
| 182 fixContributorExtensionPoint = registerExtensionPoint( | 204 fixContributorExtensionPoint = registerExtensionPoint( |
| 183 FIX_CONTRIBUTOR_EXTENSION_POINT, _validateFixContributorExtension); | 205 FIX_CONTRIBUTOR_EXTENSION_POINT, _validateFixContributorExtension); |
| 184 indexContributorExtensionPoint = registerExtensionPoint( | 206 indexContributorExtensionPoint = registerExtensionPoint( |
| 185 INDEX_CONTRIBUTOR_EXTENSION_POINT, _validateIndexContributorExtension); | 207 INDEX_CONTRIBUTOR_EXTENSION_POINT, _validateIndexContributorExtension); |
| 208 navigationContributorExtensionPoint = registerExtensionPoint( |
| 209 NAVIGATION_CONTRIBUTOR_EXTENSION_POINT, |
| 210 _validateNavigationContributorExtension); |
| 186 } | 211 } |
| 187 | 212 |
| 188 @override | 213 @override |
| 189 void registerExtensions(RegisterExtension registerExtension) { | 214 void registerExtensions(RegisterExtension registerExtension) { |
| 190 // | 215 // |
| 191 // Register analyze file functions. | 216 // Register analyze file functions. |
| 192 // | 217 // |
| 193 registerExtension(ANALYZE_FILE_EXTENSION_POINT_ID, | 218 registerExtension( |
| 219 ANALYZE_FILE_EXTENSION_POINT_ID, |
| 194 (File file) => AnalysisEngine.isDartFileName(file.path) || | 220 (File file) => AnalysisEngine.isDartFileName(file.path) || |
| 195 AnalysisEngine.isHtmlFileName(file.path)); | 221 AnalysisEngine.isHtmlFileName(file.path)); |
| 196 // | 222 // |
| 197 // Register assist contributors. | 223 // Register assist contributors. |
| 198 // | 224 // |
| 199 registerExtension( | 225 registerExtension( |
| 200 ASSIST_CONTRIBUTOR_EXTENSION_POINT_ID, new DefaultAssistContributor()); | 226 ASSIST_CONTRIBUTOR_EXTENSION_POINT_ID, new DefaultAssistContributor()); |
| 201 // | 227 // |
| 202 // Register completion contributors. | 228 // Register completion contributors. |
| 203 // | 229 // |
| 204 // TODO(brianwilkerson) Register the completion contributors. | 230 // TODO(brianwilkerson) Register the completion contributors. |
| 205 // registerExtension(COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, ???); | 231 // registerExtension(COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, ???); |
| 206 // | 232 // |
| 233 // Register navigation contributors. |
| 234 // |
| 235 registerExtension(NAVIGATION_CONTRIBUTOR_EXTENSION_POINT_ID, |
| 236 new DartNavigationComputer()); |
| 237 // |
| 207 // Register domains. | 238 // Register domains. |
| 208 // | 239 // |
| 209 String domainId = Plugin.join(UNIQUE_IDENTIFIER, DOMAIN_EXTENSION_POINT); | 240 String domainId = Plugin.join(UNIQUE_IDENTIFIER, DOMAIN_EXTENSION_POINT); |
| 210 registerExtension( | 241 registerExtension( |
| 211 domainId, (AnalysisServer server) => new ServerDomainHandler(server)); | 242 domainId, (AnalysisServer server) => new ServerDomainHandler(server)); |
| 212 registerExtension( | 243 registerExtension( |
| 213 domainId, (AnalysisServer server) => new AnalysisDomainHandler(server)); | 244 domainId, (AnalysisServer server) => new AnalysisDomainHandler(server)); |
| 214 registerExtension( | 245 registerExtension( |
| 215 domainId, (AnalysisServer server) => new EditDomainHandler(server)); | 246 domainId, (AnalysisServer server) => new EditDomainHandler(server)); |
| 216 registerExtension( | 247 registerExtension( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 /** | 324 /** |
| 294 * Validate the given extension by throwing an [ExtensionError] if it is not a | 325 * Validate the given extension by throwing an [ExtensionError] if it is not a |
| 295 * valid index contributor. | 326 * valid index contributor. |
| 296 */ | 327 */ |
| 297 void _validateIndexContributorExtension(Object extension) { | 328 void _validateIndexContributorExtension(Object extension) { |
| 298 if (extension is! IndexContributor) { | 329 if (extension is! IndexContributor) { |
| 299 String id = indexContributorExtensionPoint.uniqueIdentifier; | 330 String id = indexContributorExtensionPoint.uniqueIdentifier; |
| 300 throw new ExtensionError('Extensions to $id must be an IndexContributor'); | 331 throw new ExtensionError('Extensions to $id must be an IndexContributor'); |
| 301 } | 332 } |
| 302 } | 333 } |
| 334 |
| 335 /** |
| 336 * Validate the given extension by throwing an [ExtensionError] if it is not a |
| 337 * valid navigation contributor. |
| 338 */ |
| 339 void _validateNavigationContributorExtension(Object extension) { |
| 340 if (extension is! NavigationContributor) { |
| 341 String id = navigationContributorExtensionPoint.uniqueIdentifier; |
| 342 throw new ExtensionError( |
| 343 'Extensions to $id must be an NavigationContributor'); |
| 344 } |
| 345 } |
| 303 } | 346 } |
| OLD | NEW |