This CL contains breaking changes for package:dtd and prepares both package:dart_service_protocol_shared and package:dtd for publish.
This CL also fixes https://github.com/dart-lang/sdk/issues/60757 so that DTD-registered services are sent over the `Service` stream upon initial subscription like what is done for client-registered services.
Change-Id: I619af816e64af01864c7ed9b98743c6691bf7e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429161
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
This slightly improves the performance of applying edits in LSP tests. The previous code would sort the edits in reverse and then sequentially replace each edit into a string. With a large number of edits, both the string replacement and the subsequent rebuilding of LineInfo after each change could be quite slow.
With this change, we instead work through the edits forwards, appending the original text + new text into a StringBuffer to be combined once at the end.
Since most tests don't make large numbers of edits this only shaved a few seconds off the whole server test run, however when running a small benchmark of 20000 edits that Brian sent me recently, the time taken comes down from 42s (which hit the default test timeout) to 17s (which is not fast, but is faster).
Change-Id: Ia91937f4912b35ee1fe29f31157db3ef0e4bd79e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
No current tests hit this, but if you call verifyCodeActionLiteralEdits without a "title", you could trigger a failed expectation here that you should not - the mismatched actions should just be filtered out.
Change-Id: I6962c9f99a7a3051afcf3f76ad90945cd1381e0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429621
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
When a synchronous function body has an `await` expression, we report
an error. We don't need to _also_ report a lint.
The noted error, `CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT`, already
is associated with the "add async" fix. Reporting a lint when an error
is also definitely reported is just double reporting.
Change-Id: If6d260a01cc654c87897480996d3f6f4b61373dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429063
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
There are a few things in this CL that were difficult to separate testing of (because they're all part of the same feature):
1. sets `requiresTrustedCaller=false` on the `executeCommand` handler so that commands can be called over DTD. It adds the same flag to the command handlers themselves, so a command can control whether it can be called over DTD or not (right now we allow everything except `logAction` and `sendWorkspaceEdit` which are both commands used internally and not appropriate for DTD clients to call).
2. Removes the allow-list on DTD methods, allowing all LSP shared methods to be available over DTD
3. Extends the integration test classes to support reverse-requests so we can verify the edits being sent back to the editor when calling the code actions commands over DTD
4. It also fixes a few bugs where we read the callers capabilities instead of the editors capabilities (which until now would always be the same in those places, but with this change are not).
Change-Id: I6d271ddad6dc1b00a98b10b735763a368c91af7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428784
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
A minor refactor towards supporting CodeActions over DTD.
The (existing) `LspRequestHelpersMixin` is a collection of helper methods like `getHover()` that allow sharing strongly-typed access to LSP methods across different kinds of tests (LSP, LSP-over-Legacy, and in-process vs out-of-process).
This adds a class (`DtdHelper`) that allows those same helpers to be used to call LSP over DTD (it has to be a separate instance because these helpers already exist on the base test classes to communicate with the server directly without DTD).
As part of this, the mixin was split up to separate request, reverse-requests and notifications, since only outbound requests apply over DTD and it cannot provide an implementation for the others.
This change also adds `textDocument/hover` to the allow-list so that some of these tests can be unskipped (since in an upcoming change the allow-list will be removed entirely anyway).
Change-Id: Id7bf40020cb5397e4cb8bbdefeed71745f58c4cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
There was a mix of the term "field formal" and "initializing formal" in fixes and assists. This changes those that used "field formal" to "initializing formal" (which seems to be the term used most here and on the website).
I did not update all places that use this (for example there are many in the analyzer, including classes).
Change-Id: Ia4a1095a756adb35ca7faa8dc06c541abb04bfcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413781
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This moves the codeAction handler and the refactor commands to be shared (and therefor work for either base server kind). It also adds LSP-over-Legacy test classes that use the shared mixins so that all relevant tests run in both modes.
It does _not_ yet enable this functionality for DTD (though this is a requirement to do so in a way that will work for either IDE/server).
Change-Id: I790b98dafc59e83e72b399c9b88b94003a102f66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428322
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This is some more final (🙃) cleanup before having CodeActions work for LSP-over-Legacy and run all the same tests. Includes:
- Adding some additional signatures to the SharedTestInterface
- Moving some setup code (that uses those methods) into the shared test mixins
- Add a field for `testPackageName` to allow tests to handle differences between the test package name between LSP/Legacy (something that should probably consolidated but is probably not for this CL)
- Move plugin tests back out of the shared code action tests (these require some additional abstraction to work the same across both kinds of tests - TODO added)
Change-Id: Iad25f1ff1e141d3315e9b972a6d0850e71d4a4bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427443
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The next CL will make CodeActions a shared handler (so it can run for both LSP and legacy servers). This moves the tests to a shared mixin (without any changes) to keep that change smaller and easier to review if the tests do end up requiring changes.
Not all tests are moved yet - plugins are not (because the plugin code is not the same across server types), not "Fix All" (because it will require some additional changes to not be LSP-specific compared to others).
Change-Id: Ib4727ef1b1cc5b96d98cdbd6e17bf4b7b2791e3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428003
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
No functional changes, this is just a small refactor extracting from a future CL that makes the LSP CodeActions tests (and the supporting mixin) work against the `SharedTestInterface` so that they can be shared between the LSP server and Legacy server tests.
It also removes a redundant implementation of `verifyEdit` so both LSP+Legacy tests can use the same implementation, which required fixing the LspOverLegacy base test class to correctly set the local capabilities to match the default set the legacy server uses if the client doesn't provide any explicitly.
Change-Id: Ie6396a6425205aba9bfdcc3f08f34fdfa215ad92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428002
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This updates the `ApplyCodeActionCommandHandler` to be a "shared" command that can work for either kind of server (although it does not yet allow calling over DTD - the executeCommand handler still requires trusted callers).
It also moves all of the tests into a shared mixin so they will be run for both server kinds.
Change-Id: I831cc5a1a9feadc528e5b33b82e3469c60111dfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>