Caching the formatter (something we recently discussed removing) was causing issues if you formatted multiple files with different line endings.
It might be a VS Code bug that "\r\n" is being rendered with a blank line in between when the document was in LF mode, but I'll investigate that separately and file an issue there if required.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4865
Change-Id: Ib5ec5355f078bc8dd2b30440fd253663727a2b66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
This should have been a small change to keep us in-sync with small changes so when there are bigger changes (LSP 3.18.0) the change is less noisy.
However, it turns out the meta model is built from the latest version always, so it includes 3.18.0 proposed features.
So this change not only regenerates the code with the latest spec, it also adds some handling to exclude any types (and methods) marked as proposed.
It also includes a few minor fixes to things like re-wrapping of comments where there are references.
So, it should still essentially be a non-functional change, but the CL isn't as small as planned because of the cleanup.
- The lsp_meta_model.json file is downloaded and not changes I've made
- The protocol_generated.dart file is the output of the code-gen
- All other files are changes I made manually
Change-Id: I6380f86848d2799cf94d58a419ace0bf0d5a35ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
No functional changes, just some refactoring extracted from another change to simplify reviewing.
This just:
- adds an `initialAnalysis` getter for tests since it's very common to wait for
- adds a `diagnostics` map that tracks the current state of diagnostics in a test (to avoid tests setting up their own tracking)
- removes some duplicating code for sending diagnostics by having NotificationManager call LspAnalysisServer to send them
- removes unnecessary experiment flags from LSP tests
Change-Id: I1811f393a6d3446550f9007ede926f9ca4556563
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
+ remove legacy functions
Some of these tests still use `indexOf` to find positions (like `rangeAtSearch`) that could perhaps be changed to use ranges marked in the code too, however I'm not sure if that'll make them more readable and this CL ended up already being a little larger than originally planned.
Change-Id: If23b712134171c9d716aa0585045489d109fb39a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333923
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
No functional changes, just moves the snippets tests and a few others off the old marker functions to the new TestCode class for consistency.
With this change, there are approximately 15 remaining instances of "withoutMarkers" to remove (inc. the declaration).
Change-Id: I7f11992bb9ce47740adf6972ed097cabbd011607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333520
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The original code here called getResolvedLibrary() and then _fixErrorsInLibrary which meant if it was invoked in a part file it would do nothing (it found no resolved library) and in a container file it would also fix the part file (because _fixErrorsInLibrary enumerates the units).
This fix splits _fixErrorsInLibrary in two so it can fix libraries and units and calls the unit version from the LSP Fix All command.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4813
Change-Id: Iea72c572b6e442f6846f5ba823194b30142606db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332242
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
During this test, sometimes the refactor would complete before the overlay modification was processed, which means we don't get the expected failure response.
This isn't a server bug because the results are still consistent (and clients should discard any responses if a file was modified since the request was sent). This test was to ensure we handled the obvious cases of this in case the client did not handle it.
The fix is to artificially slow down the refactor to ensure the overlay change has time to execute before we check for consistency at the end.
Change-Id: I5697a73d7ca6dd7115dc6c0e87b8a93ba3cd533b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331940
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This makes some reductions in completion payload sizes:
- Don't include empty additionalTextEdits (use null, which is excluded from the payload)
- Don't set filterText if same as labels
- Reduce number of characters used in sortText
Additionally, this adds some methods that assert these rules (and previous rules) for all completion items during test runs to ensure these do not regress.
See https://github.com/dart-lang/sdk/issues/53501
Change-Id: I3b45ce3e1a79bf94c98af222c1a7cf0943920965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
While tidying up some branches on my Mac I found this change I'd never uploaded. It fixes some (thought not all) failures when running with the memory resource provider set to Windows-style paths on non-Windows.
It also allows an environment variable (TEST_ANALYZER_WINDOWS_PATHS) to be used to set this behaviour to avoid modifying the code.
Change-Id: I4cb7e0c0aa6a10f28b43397c33ac8649af73a459
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331046
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Make this change broke some tests because the Fix All code which uses temporary overlays would revert the overlays but not immediately apply those changes (so the file state was out of sync) to compute edits.
To fix this, the step to revert overlays also immediately applies those changes (rather than leaving them until the whole operation has completed).
+ improve a variable name
Change-Id: Ic76b1c25d808c07e1d9d7e304babf6c79556dc36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
We already supported moving a single folder, which we expanded to each file inside it. This adds support for moving multiple distinct items at the same time (eg. dragging multiple files).
To support this, we need to track a full mapping of source/destination paths (because files might be moved from different levels into the same level - we can't compute destination paths from a single `newFile` variable), and also build a unique set of references that need updating (rather than building edits as we go - where we might try to edit the same reference from both ends).
Fixes https://github.com/Dart-Code/Dart-Code/issues/4533
This is currently only supported for LSP.
Change-Id: I3a8ab8b2dcb13451111d38d2ec0e2f69d6084e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This is a no-op refactor extracted from an upcoming change to enable the onWillRenameFiles request to work for LSP over the Legacy protocol.
It's mostly lifting some API from the LSP server to the base server and some into a new mixin (`LspVerifyEditHelpersMixin`) to provide the required methods for verifying edits without the usual LSP base test classes.
Change-Id: Id6084a80e3afb9c6af1a84d9e8a18d460b5f4cce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329980
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Previously the fuzzy score was only used for filtering, then we truncated using the relevance score. This change uses the fuzzy score for sorting prior to truncation (calling back to relevance if it's the same) too.
Currently, VS Code in non-web contexts does not truncate (it's set to 100,000 items) so this change will only impact web contexts (currently set to 1,000 items to reduce payload sizes). From my testing, the difference in the first 30 items that will be seen is negligible (there are some differences between the servers fuzzy score and VS Codes, but they tend to be when there are typos).
Change-Id: Ia10d1991085054cec9c0c1071a516c8aa286156c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329323
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This is a minor refactor that adds an explicit test for generating minimal edits without going through the formatter.
There's no change in behaviour - this is just to reduce the noise in a future CL for inserted/deleted commas to be supported in computing minimal diffs.
Change-Id: I3d254bd7a90ccc7b11700b54110ece040e837363
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329601
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Previously the pattern would only be recorded as a reference to the getter. If there was a reference to the declared variable elsewhere in the visited code, it would then record the variable declaration (via the reference).
In LSP, we locate declarations by only looking at the node at the cursor, so we can't rely on the declaration being recorded by some other reference (if one even exists) so this ensure it is recorded explicitly.
Fixes https://github.com/dart-lang/sdk/issues/53554.
Change-Id: I8983d0637f2d89a427fb1fa11293eec8e06fede8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326700
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>