OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, 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 // This file has been automatically generated. Please do not edit it manually. |
| 6 // To regenerate the file, use the script |
| 7 // "pkg/analysis_server/tool/spec/generate_files". |
| 8 |
| 9 /** |
| 10 * Convenience methods for running integration tests |
| 11 */ |
| 12 import 'dart:async'; |
| 13 |
| 14 import 'package:analyzer_plugin/protocol/generated_protocol.dart'; |
| 15 import 'package:analyzer_plugin/src/protocol/protocol_internal.dart'; |
| 16 import 'package:test/test.dart'; |
| 17 |
| 18 import 'integration_tests.dart'; |
| 19 import 'protocol_matchers.dart'; |
| 20 |
| 21 /** |
| 22 * Convenience methods for running integration tests |
| 23 */ |
| 24 abstract class IntegrationTestMixin { |
| 25 Server get server; |
| 26 |
| 27 /** |
| 28 * Used to request that the plugin perform a version check to confirm that it |
| 29 * works with the version of the analysis server that is executing it. |
| 30 * |
| 31 * Parameters |
| 32 * |
| 33 * version (String) |
| 34 * |
| 35 * The version number of the plugin spec supported by the analysis server |
| 36 * that is executing the plugin. |
| 37 * |
| 38 * Returns |
| 39 * |
| 40 * isCompatible (bool) |
| 41 * |
| 42 * A flag indicating whether the plugin supports the same version of the |
| 43 * plugin spec as the analysis server. If the value is false, then the |
| 44 * plugin is expected to shutdown after returning the response. |
| 45 * |
| 46 * name (String) |
| 47 * |
| 48 * The name of the plugin. This value is only used when the server needs to |
| 49 * identify the plugin, either to the user or for debugging purposes. |
| 50 * |
| 51 * version (String) |
| 52 * |
| 53 * The version of the plugin. This value is only used when the server needs |
| 54 * to identify the plugin, either to the user or for debugging purposes. |
| 55 * |
| 56 * email (optional String) |
| 57 * |
| 58 * An e-mail address that either the client or the user can use to contact |
| 59 * the maintainers of the plugin when there is a problem. |
| 60 * |
| 61 * interestingFiles (List<String>) |
| 62 * |
| 63 * The glob patterns of the files for which the plugin will provide |
| 64 * information. This value is ignored if the isCompatible field is false. |
| 65 * Otherwise, it will be used to identify the files for which the plugin |
| 66 * should be notified of changes. |
| 67 */ |
| 68 Future<PluginVersionCheckResult> sendPluginVersionCheck(String version) async
{ |
| 69 var params = new PluginVersionCheckParams(version).toJson(); |
| 70 var result = await server.send("plugin.versionCheck", params); |
| 71 ResponseDecoder decoder = new ResponseDecoder(null); |
| 72 return new PluginVersionCheckResult.fromJson(decoder, 'result', result); |
| 73 } |
| 74 |
| 75 /** |
| 76 * Used to request that the plugin exit. The server will not send any other |
| 77 * requests after this request. The plugin should not send any responses or |
| 78 * notifications after sending the response to this request. |
| 79 */ |
| 80 Future sendPluginShutdown() async { |
| 81 var result = await server.send("plugin.shutdown", null); |
| 82 outOfTestExpect(result, isNull); |
| 83 return null; |
| 84 } |
| 85 |
| 86 /** |
| 87 * Used to report that an unexpected error has occurred while executing the |
| 88 * plugin. This notification is not used for problems with specific requests |
| 89 * (which should be returned as part of the response) but is used for |
| 90 * exceptions that occur while performing other tasks, such as analysis or |
| 91 * preparing notifications. |
| 92 * |
| 93 * Parameters |
| 94 * |
| 95 * isFatal (bool) |
| 96 * |
| 97 * A flag indicating whether the error is a fatal error, meaning that the |
| 98 * plugin will shutdown automatically after sending this notification. If |
| 99 * true, the server will not expect any other responses or notifications |
| 100 * from the plugin. |
| 101 * |
| 102 * message (String) |
| 103 * |
| 104 * The error message indicating what kind of error was encountered. |
| 105 * |
| 106 * stackTrace (String) |
| 107 * |
| 108 * The stack trace associated with the generation of the error, used for |
| 109 * debugging the plugin. |
| 110 */ |
| 111 Stream<PluginErrorParams> onPluginError; |
| 112 |
| 113 /** |
| 114 * Stream controller for [onPluginError]. |
| 115 */ |
| 116 StreamController<PluginErrorParams> _onPluginError; |
| 117 |
| 118 /** |
| 119 * Used to inform the plugin of changes to files in the file system. Only |
| 120 * events associated with files that match the interestingFiles glob patterns |
| 121 * will be forwarded to the plugin. |
| 122 * |
| 123 * Parameters |
| 124 * |
| 125 * events (List<WatchEvent>) |
| 126 * |
| 127 * The watch events that the plugin should handle. |
| 128 */ |
| 129 Future sendAnalysisHandleWatchEvents(List<WatchEvent> events) async { |
| 130 var params = new AnalysisHandleWatchEventsParams(events).toJson(); |
| 131 var result = await server.send("analysis.handleWatchEvents", params); |
| 132 outOfTestExpect(result, isNull); |
| 133 return null; |
| 134 } |
| 135 |
| 136 /** |
| 137 * Used to force the re-analysis of everything contained in the specified |
| 138 * context roots. This should cause all previously computed analysis results |
| 139 * to be discarded and recomputed, and should cause all subscribed |
| 140 * notifications to be re-sent. |
| 141 * |
| 142 * Parameters |
| 143 * |
| 144 * roots (optional List<FilePath>) |
| 145 * |
| 146 * A list of the context roots that are to be re-analyzed. |
| 147 * |
| 148 * If no context roots are provided, then all current context roots should |
| 149 * be re-analyzed. |
| 150 */ |
| 151 Future sendAnalysisReanalyze({List<String> roots}) async { |
| 152 var params = new AnalysisReanalyzeParams(roots: roots).toJson(); |
| 153 var result = await server.send("analysis.reanalyze", params); |
| 154 outOfTestExpect(result, isNull); |
| 155 return null; |
| 156 } |
| 157 |
| 158 /** |
| 159 * Used to set the options used to build analysis contexts. This request will |
| 160 * be sent exactly once before any context roots have been specified. |
| 161 * |
| 162 * Parameters |
| 163 * |
| 164 * options (ContextBuilderOptions) |
| 165 * |
| 166 * The options used to build the analysis contexts. |
| 167 */ |
| 168 Future sendAnalysisSetContextBuilderOptions(ContextBuilderOptions options) asy
nc { |
| 169 var params = new AnalysisSetContextBuilderOptionsParams(options).toJson(); |
| 170 var result = await server.send("analysis.setContextBuilderOptions", params); |
| 171 outOfTestExpect(result, isNull); |
| 172 return null; |
| 173 } |
| 174 |
| 175 /** |
| 176 * Set the list of context roots that should be analyzed. |
| 177 * |
| 178 * Parameters |
| 179 * |
| 180 * roots (List<ContextRoot>) |
| 181 * |
| 182 * A list of the context roots that should be analyzed. |
| 183 */ |
| 184 Future sendAnalysisSetContextRoots(List<ContextRoot> roots) async { |
| 185 var params = new AnalysisSetContextRootsParams(roots).toJson(); |
| 186 var result = await server.send("analysis.setContextRoots", params); |
| 187 outOfTestExpect(result, isNull); |
| 188 return null; |
| 189 } |
| 190 |
| 191 /** |
| 192 * Used to set the priority files to the files in the given list. A priority |
| 193 * file is a file that should be given priority when scheduling which |
| 194 * analysis work to do first. The list typically contains those files that |
| 195 * are visible to the user and those for which analysis results will have the |
| 196 * biggest impact on the user experience. The order of the files within the |
| 197 * list is significant: the first file will be given higher priority than the |
| 198 * second, the second higher priority than the third, and so on. |
| 199 * |
| 200 * Parameters |
| 201 * |
| 202 * files (List<FilePath>) |
| 203 * |
| 204 * The files that are to be a priority for analysis. |
| 205 */ |
| 206 Future sendAnalysisSetPriorityFiles(List<String> files) async { |
| 207 var params = new AnalysisSetPriorityFilesParams(files).toJson(); |
| 208 var result = await server.send("analysis.setPriorityFiles", params); |
| 209 outOfTestExpect(result, isNull); |
| 210 return null; |
| 211 } |
| 212 |
| 213 /** |
| 214 * Used to subscribe for services that are specific to individual files. All |
| 215 * previous subscriptions should be replaced by the current set of |
| 216 * subscriptions. If a given service is not included as a key in the map then |
| 217 * no files should be subscribed to the service, exactly as if the service |
| 218 * had been included in the map with an explicit empty list of files. |
| 219 * |
| 220 * Parameters |
| 221 * |
| 222 * subscriptions (Map<AnalysisService, List<FilePath>>) |
| 223 * |
| 224 * A table mapping services to a list of the files being subscribed to the |
| 225 * service. |
| 226 */ |
| 227 Future sendAnalysisSetSubscriptions(Map<AnalysisService, List<String>> subscri
ptions) async { |
| 228 var params = new AnalysisSetSubscriptionsParams(subscriptions).toJson(); |
| 229 var result = await server.send("analysis.setSubscriptions", params); |
| 230 outOfTestExpect(result, isNull); |
| 231 return null; |
| 232 } |
| 233 |
| 234 /** |
| 235 * Used to update the content of one or more files. Files that were |
| 236 * previously updated but not included in this update remain unchanged. This |
| 237 * effectively represents an overlay of the filesystem. The files whose |
| 238 * content is overridden are therefore seen by the plugin as being files with |
| 239 * the given content, even if the files do not exist on the filesystem or if |
| 240 * the file path represents the path to a directory on the filesystem. |
| 241 * |
| 242 * Parameters |
| 243 * |
| 244 * files (Map<FilePath, AddContentOverlay | ChangeContentOverlay | |
| 245 * RemoveContentOverlay>) |
| 246 * |
| 247 * A table mapping the files whose content has changed to a description of |
| 248 * the content change. |
| 249 */ |
| 250 Future sendAnalysisUpdateContent(Map<String, dynamic> files) async { |
| 251 var params = new AnalysisUpdateContentParams(files).toJson(); |
| 252 var result = await server.send("analysis.updateContent", params); |
| 253 outOfTestExpect(result, isNull); |
| 254 return null; |
| 255 } |
| 256 |
| 257 /** |
| 258 * Used to report the errors associated with a given file. The set of errors |
| 259 * included in the notification is always a complete list that supersedes any |
| 260 * previously reported errors. |
| 261 * |
| 262 * TODO: Decide whether we need to support the '--no-error-notification' |
| 263 * option. |
| 264 * |
| 265 * Parameters |
| 266 * |
| 267 * file (FilePath) |
| 268 * |
| 269 * The file containing the errors. |
| 270 * |
| 271 * errors (List<AnalysisError>) |
| 272 * |
| 273 * The errors contained in the file. |
| 274 */ |
| 275 Stream<AnalysisErrorsParams> onAnalysisErrors; |
| 276 |
| 277 /** |
| 278 * Stream controller for [onAnalysisErrors]. |
| 279 */ |
| 280 StreamController<AnalysisErrorsParams> _onAnalysisErrors; |
| 281 |
| 282 /** |
| 283 * Used to report the folding regions associated with a given file. Folding |
| 284 * regions can be nested, but cannot be overlapping. Nesting occurs when a |
| 285 * foldable element, such as a method, is nested inside another foldable |
| 286 * element such as a class. |
| 287 * |
| 288 * Folding regions that overlap a folding region computed by the server, or |
| 289 * by one of the other plugins that are currently running, might be dropped |
| 290 * by the server in order to present a consistent view to the client. |
| 291 * |
| 292 * This notification should only be sent if the server has subscribed to it |
| 293 * by including the value "FOLDING" in the list of services passed in an |
| 294 * analysis.setSubscriptions request. |
| 295 * |
| 296 * Parameters |
| 297 * |
| 298 * file (FilePath) |
| 299 * |
| 300 * The file containing the folding regions. |
| 301 * |
| 302 * regions (List<FoldingRegion>) |
| 303 * |
| 304 * The folding regions contained in the file. |
| 305 */ |
| 306 Stream<AnalysisFoldingParams> onAnalysisFolding; |
| 307 |
| 308 /** |
| 309 * Stream controller for [onAnalysisFolding]. |
| 310 */ |
| 311 StreamController<AnalysisFoldingParams> _onAnalysisFolding; |
| 312 |
| 313 /** |
| 314 * Used to report the highlight regions associated with a given file. Each |
| 315 * highlight region represents a particular syntactic or semantic meaning |
| 316 * associated with some range. Note that the highlight regions that are |
| 317 * returned can overlap other highlight regions if there is more than one |
| 318 * meaning associated with a particular region. |
| 319 * |
| 320 * This notification should only be sent if the server has subscribed to it |
| 321 * by including the value "HIGHLIGHTS" in the list of services passed in an |
| 322 * analysis.setSubscriptions request. |
| 323 * |
| 324 * Parameters |
| 325 * |
| 326 * file (FilePath) |
| 327 * |
| 328 * The file containing the highlight regions. |
| 329 * |
| 330 * regions (List<HighlightRegion>) |
| 331 * |
| 332 * The highlight regions contained in the file. |
| 333 */ |
| 334 Stream<AnalysisHighlightsParams> onAnalysisHighlights; |
| 335 |
| 336 /** |
| 337 * Stream controller for [onAnalysisHighlights]. |
| 338 */ |
| 339 StreamController<AnalysisHighlightsParams> _onAnalysisHighlights; |
| 340 |
| 341 /** |
| 342 * Used to report the navigation regions associated with a given file. Each |
| 343 * navigation region represents a list of targets associated with some range. |
| 344 * The lists will usually contain a single target, but can contain more in |
| 345 * the case of a part that is included in multiple libraries or in Dart code |
| 346 * that is compiled against multiple versions of a package. Note that the |
| 347 * navigation regions that are returned should not overlap other navigation |
| 348 * regions. |
| 349 * |
| 350 * Navigation regions that overlap a navigation region computed by the |
| 351 * server, or by one of the other plugins that are currently running, might |
| 352 * be dropped or modified by the server in order to present a consistent view |
| 353 * to the client. |
| 354 * |
| 355 * This notification should only be sent if the server has subscribed to it |
| 356 * by including the value "NAVIGATION" in the list of services passed in an |
| 357 * analysis.setSubscriptions request. |
| 358 * |
| 359 * Parameters |
| 360 * |
| 361 * file (FilePath) |
| 362 * |
| 363 * The file containing the navigation regions. |
| 364 * |
| 365 * regions (List<NavigationRegion>) |
| 366 * |
| 367 * The navigation regions contained in the file. |
| 368 * |
| 369 * targets (List<NavigationTarget>) |
| 370 * |
| 371 * The navigation targets referenced in the file. They are referenced by |
| 372 * NavigationRegions by their index in this array. |
| 373 * |
| 374 * files (List<FilePath>) |
| 375 * |
| 376 * The files containing navigation targets referenced in the file. They are |
| 377 * referenced by NavigationTargets by their index in this array. |
| 378 */ |
| 379 Stream<AnalysisNavigationParams> onAnalysisNavigation; |
| 380 |
| 381 /** |
| 382 * Stream controller for [onAnalysisNavigation]. |
| 383 */ |
| 384 StreamController<AnalysisNavigationParams> _onAnalysisNavigation; |
| 385 |
| 386 /** |
| 387 * Used to report the occurrences of references to elements within a single |
| 388 * file. None of the occurrence regions should overlap. |
| 389 * |
| 390 * Occurrence regions that overlap an occurrence region computed by the |
| 391 * server, or by one of the other plugins that are currently running, might |
| 392 * be dropped or modified by the server in order to present a consistent view |
| 393 * to the client. |
| 394 * |
| 395 * This notification should only be sent if the server has subscribed to it |
| 396 * by including the value "OCCURRENCES" in the list of services passed in an |
| 397 * analysis.setSubscriptions request. |
| 398 * |
| 399 * Parameters |
| 400 * |
| 401 * file (FilePath) |
| 402 * |
| 403 * The file in which the references occur. |
| 404 * |
| 405 * occurrences (List<Occurrences>) |
| 406 * |
| 407 * The occurrences of references to elements within the file. |
| 408 */ |
| 409 Stream<AnalysisOccurrencesParams> onAnalysisOccurrences; |
| 410 |
| 411 /** |
| 412 * Stream controller for [onAnalysisOccurrences]. |
| 413 */ |
| 414 StreamController<AnalysisOccurrencesParams> _onAnalysisOccurrences; |
| 415 |
| 416 /** |
| 417 * Used to report the outline fragments associated with a single file. |
| 418 * |
| 419 * The outline fragments will be merged with any outline produced by the |
| 420 * server and with any fragments produced by other plugins. If the server |
| 421 * cannot create a coherent outline, some fragments might be dropped. |
| 422 * |
| 423 * This notification should only be sent if the server has subscribed to it |
| 424 * by including the value "OUTLINE" in the list of services passed in an |
| 425 * analysis.setSubscriptions request. |
| 426 * |
| 427 * Parameters |
| 428 * |
| 429 * file (FilePath) |
| 430 * |
| 431 * The file with which the outline is associated. |
| 432 * |
| 433 * outline (List<Outline>) |
| 434 * |
| 435 * The outline fragments associated with the file. |
| 436 */ |
| 437 Stream<AnalysisOutlineParams> onAnalysisOutline; |
| 438 |
| 439 /** |
| 440 * Stream controller for [onAnalysisOutline]. |
| 441 */ |
| 442 StreamController<AnalysisOutlineParams> _onAnalysisOutline; |
| 443 |
| 444 /** |
| 445 * Used to request that completion suggestions for the given offset in the |
| 446 * given file be returned. |
| 447 * |
| 448 * Parameters |
| 449 * |
| 450 * file (FilePath) |
| 451 * |
| 452 * The file containing the point at which suggestions are to be made. |
| 453 * |
| 454 * offset (int) |
| 455 * |
| 456 * The offset within the file at which suggestions are to be made. |
| 457 * |
| 458 * Returns |
| 459 * |
| 460 * replacementOffset (int) |
| 461 * |
| 462 * The offset of the start of the text to be replaced. This will be |
| 463 * different than the offset used to request the completion suggestions if |
| 464 * there was a portion of an identifier before the original offset. In |
| 465 * particular, the replacementOffset will be the offset of the beginning of |
| 466 * said identifier. |
| 467 * |
| 468 * replacementLength (int) |
| 469 * |
| 470 * The length of the text to be replaced if the remainder of the identifier |
| 471 * containing the cursor is to be replaced when the suggestion is applied |
| 472 * (that is, the number of characters in the existing identifier). |
| 473 * |
| 474 * results (List<CompletionSuggestion>) |
| 475 * |
| 476 * The completion suggestions being reported. The notification contains all |
| 477 * possible completions at the requested cursor position, even those that |
| 478 * do not match the characters the user has already typed. This allows the |
| 479 * client to respond to further keystrokes from the user without having to |
| 480 * make additional requests. |
| 481 */ |
| 482 Future<CompletionGetSuggestionsResult> sendCompletionGetSuggestions(String fil
e, int offset) async { |
| 483 var params = new CompletionGetSuggestionsParams(file, offset).toJson(); |
| 484 var result = await server.send("completion.getSuggestions", params); |
| 485 ResponseDecoder decoder = new ResponseDecoder(null); |
| 486 return new CompletionGetSuggestionsResult.fromJson(decoder, 'result', result
); |
| 487 } |
| 488 |
| 489 /** |
| 490 * Used to request the set of assists that are available at the given |
| 491 * location. An assist is distinguished from a refactoring primarily by the |
| 492 * fact that it affects a single file and does not require user input in |
| 493 * order to be performed. |
| 494 * |
| 495 * Parameters |
| 496 * |
| 497 * file (FilePath) |
| 498 * |
| 499 * The file containing the code for which assists are being requested. |
| 500 * |
| 501 * offset (int) |
| 502 * |
| 503 * The offset of the code for which assists are being requested. |
| 504 * |
| 505 * length (int) |
| 506 * |
| 507 * The length of the code for which assists are being requested. |
| 508 * |
| 509 * Returns |
| 510 * |
| 511 * assists (List<SourceChange>) |
| 512 * |
| 513 * The assists that are available at the given location. |
| 514 */ |
| 515 Future<EditGetAssistsResult> sendEditGetAssists(String file, int offset, int l
ength) async { |
| 516 var params = new EditGetAssistsParams(file, offset, length).toJson(); |
| 517 var result = await server.send("edit.getAssists", params); |
| 518 ResponseDecoder decoder = new ResponseDecoder(null); |
| 519 return new EditGetAssistsResult.fromJson(decoder, 'result', result); |
| 520 } |
| 521 |
| 522 /** |
| 523 * Used to request a list of the kinds of refactorings that are valid for the |
| 524 * given selection in the given file. |
| 525 * |
| 526 * Parameters |
| 527 * |
| 528 * file (FilePath) |
| 529 * |
| 530 * The file containing the code on which the refactoring would be based. |
| 531 * |
| 532 * offset (int) |
| 533 * |
| 534 * The offset of the code on which the refactoring would be based. |
| 535 * |
| 536 * length (int) |
| 537 * |
| 538 * The length of the code on which the refactoring would be based. |
| 539 * |
| 540 * Returns |
| 541 * |
| 542 * kinds (List<RefactoringKind>) |
| 543 * |
| 544 * The kinds of refactorings that are valid for the given selection. |
| 545 * |
| 546 * The list of refactoring kinds is currently limited to those defined by |
| 547 * the server API, preventing plugins from adding their own refactorings. |
| 548 * However, plugins can support pre-defined refactorings, such as a rename |
| 549 * refactoring, at locations not supported by server. |
| 550 */ |
| 551 Future<EditGetAvailableRefactoringsResult> sendEditGetAvailableRefactorings(St
ring file, int offset, int length) async { |
| 552 var params = new EditGetAvailableRefactoringsParams(file, offset, length).to
Json(); |
| 553 var result = await server.send("edit.getAvailableRefactorings", params); |
| 554 ResponseDecoder decoder = new ResponseDecoder(null); |
| 555 return new EditGetAvailableRefactoringsResult.fromJson(decoder, 'result', re
sult); |
| 556 } |
| 557 |
| 558 /** |
| 559 * Used to request the set of fixes that are available for the errors at a |
| 560 * given offset in a given file. |
| 561 * |
| 562 * Parameters |
| 563 * |
| 564 * file (FilePath) |
| 565 * |
| 566 * The file containing the errors for which fixes are being requested. |
| 567 * |
| 568 * offset (int) |
| 569 * |
| 570 * The offset used to select the errors for which fixes will be returned. |
| 571 * |
| 572 * Returns |
| 573 * |
| 574 * fixes (List<AnalysisErrorFixes>) |
| 575 * |
| 576 * The fixes that are available for the errors at the given offset. |
| 577 */ |
| 578 Future<EditGetFixesResult> sendEditGetFixes(String file, int offset) async { |
| 579 var params = new EditGetFixesParams(file, offset).toJson(); |
| 580 var result = await server.send("edit.getFixes", params); |
| 581 ResponseDecoder decoder = new ResponseDecoder(null); |
| 582 return new EditGetFixesResult.fromJson(decoder, 'result', result); |
| 583 } |
| 584 |
| 585 /** |
| 586 * Used to request the changes required to perform a refactoring. |
| 587 * |
| 588 * Parameters |
| 589 * |
| 590 * kind (RefactoringKind) |
| 591 * |
| 592 * The kind of refactoring to be performed. |
| 593 * |
| 594 * file (FilePath) |
| 595 * |
| 596 * The file containing the code involved in the refactoring. |
| 597 * |
| 598 * offset (int) |
| 599 * |
| 600 * The offset of the region involved in the refactoring. |
| 601 * |
| 602 * length (int) |
| 603 * |
| 604 * The length of the region involved in the refactoring. |
| 605 * |
| 606 * validateOnly (bool) |
| 607 * |
| 608 * True if the client is only requesting that the values of the options be |
| 609 * validated and no change be generated. |
| 610 * |
| 611 * options (optional RefactoringOptions) |
| 612 * |
| 613 * Data used to provide values provided by the user. The structure of the |
| 614 * data is dependent on the kind of refactoring being performed. The data |
| 615 * that is expected is documented in the section titled Refactorings, |
| 616 * labeled as "Options". This field can be omitted if the refactoring does |
| 617 * not require any options or if the values of those options are not known. |
| 618 * |
| 619 * Returns |
| 620 * |
| 621 * initialProblems (List<RefactoringProblem>) |
| 622 * |
| 623 * The initial status of the refactoring, that is, problems related to the |
| 624 * context in which the refactoring is requested. The list should be empty |
| 625 * if there are no known problems. |
| 626 * |
| 627 * optionsProblems (List<RefactoringProblem>) |
| 628 * |
| 629 * The options validation status, that is, problems in the given options, |
| 630 * such as light-weight validation of a new name, flags compatibility, etc. |
| 631 * The list should be empty if there are no known problems. |
| 632 * |
| 633 * finalProblems (List<RefactoringProblem>) |
| 634 * |
| 635 * The final status of the refactoring, that is, problems identified in the |
| 636 * result of a full, potentially expensive validation and / or change |
| 637 * creation. The list should be empty if there are no known problems. |
| 638 * |
| 639 * feedback (optional RefactoringFeedback) |
| 640 * |
| 641 * Data used to provide feedback to the user. The structure of the data is |
| 642 * dependent on the kind of refactoring being created. The data that is |
| 643 * returned is documented in the section titled Refactorings, labeled as |
| 644 * "Feedback". |
| 645 * |
| 646 * change (optional SourceChange) |
| 647 * |
| 648 * The changes that are to be applied to affect the refactoring. This field |
| 649 * can be omitted if there are problems that prevent a set of changes from |
| 650 * being computed, such as having no options specified for a refactoring |
| 651 * that requires them, or if only validation was requested. |
| 652 * |
| 653 * potentialEdits (optional List<String>) |
| 654 * |
| 655 * The ids of source edits that are not known to be valid. An edit is not |
| 656 * known to be valid if there was insufficient type information for the |
| 657 * plugin to be able to determine whether or not the code needs to be |
| 658 * modified, such as when a member is being renamed and there is a |
| 659 * reference to a member from an unknown type. This field can be omitted if |
| 660 * the change field is omitted or if there are no potential edits for the |
| 661 * refactoring. |
| 662 */ |
| 663 Future<EditGetRefactoringResult> sendEditGetRefactoring(RefactoringKind kind,
String file, int offset, int length, bool validateOnly, {RefactoringOptions opti
ons}) async { |
| 664 var params = new EditGetRefactoringParams(kind, file, offset, length, valida
teOnly, options: options).toJson(); |
| 665 var result = await server.send("edit.getRefactoring", params); |
| 666 ResponseDecoder decoder = new ResponseDecoder(kind); |
| 667 return new EditGetRefactoringResult.fromJson(decoder, 'result', result); |
| 668 } |
| 669 |
| 670 /** |
| 671 * Initialize the fields in InttestMixin, and ensure that notifications will |
| 672 * be handled. |
| 673 */ |
| 674 void initializeInttestMixin() { |
| 675 _onPluginError = new StreamController<PluginErrorParams>(sync: true); |
| 676 onPluginError = _onPluginError.stream.asBroadcastStream(); |
| 677 _onAnalysisErrors = new StreamController<AnalysisErrorsParams>(sync: true); |
| 678 onAnalysisErrors = _onAnalysisErrors.stream.asBroadcastStream(); |
| 679 _onAnalysisFolding = new StreamController<AnalysisFoldingParams>(sync: true)
; |
| 680 onAnalysisFolding = _onAnalysisFolding.stream.asBroadcastStream(); |
| 681 _onAnalysisHighlights = new StreamController<AnalysisHighlightsParams>(sync:
true); |
| 682 onAnalysisHighlights = _onAnalysisHighlights.stream.asBroadcastStream(); |
| 683 _onAnalysisNavigation = new StreamController<AnalysisNavigationParams>(sync:
true); |
| 684 onAnalysisNavigation = _onAnalysisNavigation.stream.asBroadcastStream(); |
| 685 _onAnalysisOccurrences = new StreamController<AnalysisOccurrencesParams>(syn
c: true); |
| 686 onAnalysisOccurrences = _onAnalysisOccurrences.stream.asBroadcastStream(); |
| 687 _onAnalysisOutline = new StreamController<AnalysisOutlineParams>(sync: true)
; |
| 688 onAnalysisOutline = _onAnalysisOutline.stream.asBroadcastStream(); |
| 689 } |
| 690 |
| 691 /** |
| 692 * Dispatch the notification named [event], and containing parameters |
| 693 * [params], to the appropriate stream. |
| 694 */ |
| 695 void dispatchNotification(String event, params) { |
| 696 ResponseDecoder decoder = new ResponseDecoder(null); |
| 697 switch (event) { |
| 698 case "plugin.error": |
| 699 outOfTestExpect(params, isPluginErrorParams); |
| 700 _onPluginError.add(new PluginErrorParams.fromJson(decoder, 'params', par
ams)); |
| 701 break; |
| 702 case "analysis.errors": |
| 703 outOfTestExpect(params, isAnalysisErrorsParams); |
| 704 _onAnalysisErrors.add(new AnalysisErrorsParams.fromJson(decoder, 'params
', params)); |
| 705 break; |
| 706 case "analysis.folding": |
| 707 outOfTestExpect(params, isAnalysisFoldingParams); |
| 708 _onAnalysisFolding.add(new AnalysisFoldingParams.fromJson(decoder, 'para
ms', params)); |
| 709 break; |
| 710 case "analysis.highlights": |
| 711 outOfTestExpect(params, isAnalysisHighlightsParams); |
| 712 _onAnalysisHighlights.add(new AnalysisHighlightsParams.fromJson(decoder,
'params', params)); |
| 713 break; |
| 714 case "analysis.navigation": |
| 715 outOfTestExpect(params, isAnalysisNavigationParams); |
| 716 _onAnalysisNavigation.add(new AnalysisNavigationParams.fromJson(decoder,
'params', params)); |
| 717 break; |
| 718 case "analysis.occurrences": |
| 719 outOfTestExpect(params, isAnalysisOccurrencesParams); |
| 720 _onAnalysisOccurrences.add(new AnalysisOccurrencesParams.fromJson(decode
r, 'params', params)); |
| 721 break; |
| 722 case "analysis.outline": |
| 723 outOfTestExpect(params, isAnalysisOutlineParams); |
| 724 _onAnalysisOutline.add(new AnalysisOutlineParams.fromJson(decoder, 'para
ms', params)); |
| 725 break; |
| 726 default: |
| 727 fail('Unexpected notification: $event'); |
| 728 break; |
| 729 } |
| 730 } |
| 731 } |
OLD | NEW |