Commit Graph

626 Commits

Author SHA1 Message Date
Brian Wilkerson 7a3df2c801 Move the last of the local reference contributor to the first pass
Change-Id: Ib345a5facef37e2d9d9fc8494b8df116d36c23f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341332
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-13 18:01:03 +00:00
Danny Tuppeny 367b8fdc16 [analysis_server] Add inlay hints for for-in and for elements
Fixes https://github.com/Dart-Code/Dart-Code/issues/4891

Change-Id: I788008bca06f98b4308c897d41b2dc034579c6a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-12-11 22:48:27 +00:00
Danny Tuppeny 315d0b7fa7 [analysis_server] Prevent LSP formatting from adding \r to files formatted with \n if a previous file was formatted with \r\n
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>
2023-12-07 00:21:31 +00:00
Danny Tuppeny 23e1437f6a [analysis_server] Update generated code to match latest spec
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>
2023-12-05 19:58:47 +00:00
Danny Tuppeny b1620d1ba0 [analyzer] Drop return type from element display for setters
Change-Id: Id580f2c5796b3024b127464ffffdb420511a5632
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-04 06:16:26 +00:00
Danny Tuppeny 7f9099e75a [analysis_server] Fix static type on hovers for non-synthetic getters/setters
Fixes https://github.com/Dart-Code/Dart-Code/issues/4863

Change-Id: Ie4272b77e81fcee282e22002a8cc3f58611af969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338821
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-29 23:18:09 +00:00
Danny Tuppeny 07d40a0210 [analysis_server] Fix Rename+References for forElements outside of blocks
Fixes https://github.com/Dart-Code/Dart-Code/issues/4849

Change-Id: Iceeeab549235622d4fe8c5c129c754cea53012b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337741
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-28 21:23:39 +00:00
Danny Tuppeny 4f0dc3bfd9 [analysis_server] Ensure textDocument/didClose removes overlays synchronously to avoid races when files are closed/opened quickly
Plugin re-registration could cause VS Code to send us a close/open request very close together and this `await` before removing the overlay could result in them being processed in the wrong order. This resulted in subsequent file updates failing with "Unable to edit document because the file was not previously opened"

Fixes https://github.com/Dart-Code/Dart-Code/issues/4862
See also https://github.com/Dart-Code/Dart-Code/issues/4740

Change-Id: If6beeebdd79914e1b26553b81f4fb38f000cbaf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338660
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-11-28 17:52:57 +00:00
Sam Rawlins 28ca02d3a0 Remove WithoutNullSafety tests in DAS and analyzer_plugin tests
Change-Id: I3ea9e767ff49b16a8dcdec5540a6b2d68f414930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337844
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-11-27 21:40:11 +00:00
Danny Tuppeny 2aa6fa772b [analysis_server] Don't send redundant empty LSP diagnostics
We never need to send empty diagnostics to the client unless we have previously sent a non-empty set. These empty diagnostics account for a large amount of traffic during initial analysis and also could be quite large when modifying files with dependencies.

See https://github.com/dart-lang/sdk/issues/53501

Change-Id: I3d0e2ea2633469da905c8ca328dcc89e38a64edc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337582
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 20:05:04 +00:00
Danny Tuppeny cfcd74e72c [analysis_server] Remove some boilerplate from LSP tests
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>
2023-11-21 19:02:16 +00:00
Brian Wilkerson 974b97ca3f Fix the semantic highlighting for both extension types and mixins
Change-Id: Ie64494adbe9d54810b0b156b4884734bdb801309
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336601
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-11-15 23:01:13 +00:00
Danny Tuppeny be709b288c [analysis_server] Ensure exclude folder paths are always normalized
Workspace folder paths were normalized but these ignore paths are not.

Change-Id: Idc6197b04d740e473bc3f3fede1d7798f5b94944
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336364
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-15 18:08:32 +00:00
Danny Tuppeny 4dddc98fc6 [analysis_server] Include 'required' keyword in closure completion text
This adds missing 'required' keywords when completing closures. The keyword is only added to the completion text and not the displayed label because there's limited space for completions and seeing the end of the completion (for example `=>` vs `{}` is more useful.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4834

Change-Id: I3cb791bcd84533e9bc3819d8a527233f026849bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336021
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-14 22:38:39 +00:00
Danny Tuppeny 28d9ac03ef [analysis_server] Fix missing closure completions in LSP
Closure completions disappeared in eb73dba14d because we ended up wiping our the filterText/label when trying to clean them up for functions.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4837

Change-Id: I61976734356117aa1ec0fae81c8a56245f2b35c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335822
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-14 22:33:01 +00:00
pq 440ea59ee0 enable flutter_style_todos in server
Change-Id: I4921d538e1498e66c8cab2d84dfcad21d1a7b555
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335952
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-11-14 21:08:12 +00:00
Danny Tuppeny bdab586ec6 [analysis_server] Don't fail when adding non-file workspace folders
I'd previously fixed non-file workspace folders that existed during initialization, but not those added later via `didChangeWorkspaceFolders`.

Fixes https://github.com/dart-lang/sdk/issues/53966

Change-Id: Ie991fc9755857cb1786505fce34c47e5a1be72d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-11-08 17:42:40 +00:00
Danny Tuppeny 29c4b557eb [analysis_server] Migrate all remaining tests using legacy marker functions
+ 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>
2023-11-06 17:58:56 +00:00
Danny Tuppeny d1a1a273ee [analysis_server] Migrate some LSP tests off old marker functions
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>
2023-11-02 16:18:01 +00:00
Danny Tuppeny 4d9c40860f [analysis_server] Add support for LSP Document Links for example/api links
This extracts the code that finds "examples/api" paths in code from the navigation code so that it can be re-used by LSP's DocumentLink request.

This allows the links to be more visible in the editor (they are underlined and clearly clickable like hyperlinks, whereas definition required you to hover and hold Ctrl before you'd seen an underline in VS Code).

Example: https://github.com/Dart-Code/Dart-Code/assets/1078012/be9db467-dbc9-4206-9dd5-f8ca72d95596

There may be an argument for making this more general (so that links other than example/api could be detected) but for now the goal was to make these existing links more obvious.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4186

Change-Id: Id00425175b24394e565e13406ea4bac5691d2c72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333082
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-02 15:51:49 +00:00
Danny Tuppeny 939e081d43 [analysis_server] Include inlay hints for type arguments in "if case"
Previously we only added the type args in constructor invocations, this changes to any named type without explicit type args.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4712

Change-Id: I11a6a96bf34c7e4acff93607a922401d2f0eed83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332960
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-10-31 17:46:58 +00:00
Danny Tuppeny 28456ae716 [analysis_server] Fix LSP "Fix All" command for part files
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>
2023-10-26 14:11:12 +00:00
Danny Tuppeny 0c91d4195e [analysis_server] Fix race condition in will_rename_files test
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>
2023-10-24 16:13:02 +00:00
Danny Tuppeny 9e753794cb [analsysis_server] Fix missing types on record fields in LSP completion detail
Fixes https://github.com/Dart-Code/Dart-Code/issues/4788

Change-Id: Iaa57a5e486dac6c1978b8576b4855f8c3e8955f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330107
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-10-23 17:08:27 +00:00
Danny Tuppeny 9f9d5045b4 [analysis_server] Don't send ranges on snippet completions if they're same as defaults
See https://github.com/dart-lang/sdk/issues/53501

Change-Id: Ia8956ab1477dcd5c4146cc3358477f43571defbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-10-23 15:01:37 +00:00
Danny Tuppeny 3ce3bdb6ed [analysis_server] Reduce completion payload sizes
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>
2023-10-19 19:55:35 +00:00
Danny Tuppeny 7bc521d0ed [analysis_server] Don't include empty labelDetails objects in completion payload
See https://github.com/dart-lang/sdk/issues/53501

Change-Id: I13777df766e0eca069c229dc62d0e94b9bac186c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331100
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-10-19 15:47:20 +00:00
Danny Tuppeny e3451cb526 [analyzer] Fix some issues running tests with Windows paths on macOS
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>
2023-10-18 16:26:31 +00:00
Danny Tuppeny 8493e98bc4 [analysis_server] Add a failing test for enum completion
Raised at https://github.com/Dart-Code/Dart-Code/issues/4794.

Change-Id: I0df73481ddd68f3950b342581233a823455cddc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330426
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-10-18 15:45:14 +00:00
Danny Tuppeny e7eda9a4fc [analysis_server] Migrate a few more tests to TestCode from old markers
+ tweak indenting to be consistent with other tests.

Most of the larger test files are done with this change, and there are around 40 remaining calls to withoutMarkers() spread across around 20 files.

Change-Id: Icfa516f7ca869e09822442b02a1b2eafca692b86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330423
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-10-16 20:42:59 +00:00
Danny Tuppeny 2c0a33400e [analysis_server] Use existing file state for Dart files to get LineInfo
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>
2023-10-12 19:58:22 +00:00
Danny Tuppeny 23e9681392 [analysis_server] Handle object patterns without explicit field names
+ merge overlapping occurrences groups in LSP.

See https://github.com/dart-lang/sdk/issues/53478

Change-Id: I5a855f68963fc06e2e878a0a8f872f3f68ea1d34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-10-12 18:44:16 +00:00
Danny Tuppeny e44d114297 [analysis_server] Enable workspace/willRenameFiles for LSP-over-Legacy
Change-Id: Ib572663a247f7e5521b0a9c69f201c22cea29b16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330102
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-10-12 18:36:12 +00:00
Danny Tuppeny ab22dc07e7 [analysis_server] Migrate call hierarchy + super tests from old markers to TestCode
No functional changes, just changing the tests from the old markers to TestCode for consistency (and also removed the extra indenting of test code also for consistency).

Change-Id: Id41f660f8fb7c45b5c75dcf43d0b79bccac6b64e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330340
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-10-12 17:20:36 +00:00
Danny Tuppeny 09f3eb0c8b [analysis_server] Support renaming multiple files in a single operation
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>
2023-10-11 03:56:29 +00:00
Danny Tuppeny 800421bc60 [analysis_server] Refactor servers to allow producing edits for LSP over Legacy
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>
2023-10-10 21:30:25 +00:00
Danny Tuppeny 9b1be91249 [analysis_server] Tolerate added/removed commas when computing minimal diffs for formatting
Fixes https://github.com/dart-lang/sdk/issues/53561

Change-Id: Iaa93c1fd3565bd079676a146592279d42863b018
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329602
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-10-10 15:36:20 +00:00
Alexander Thomas 49f4c5f94a [analysis_server] Move language server protocol to third_party
Bug: b/286184681
Change-Id: Iabb9070e354f85d29bb94dee4bdd52a0cf664c94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326643
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2023-10-10 07:48:30 +00:00
Danny Tuppeny 20d598c7ce [analysis_server] Change LSP server to truncate using Fuzzy Score before Relevance
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>
2023-10-09 17:05:08 +00:00
Danny Tuppeny 2d0985340b [analysis_server] Add explicit test for generating minimal edits
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>
2023-10-06 18:46:25 +00:00
Danny Tuppeny bf13d89902 [analysis_server] Ensure variables declared in patterns are recorded in navigation data
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>
2023-09-19 19:39:31 +00:00
Danny Tuppeny 55be7147eb [analysis_server] Migrate rename tests to use TestCode
No functional changes, just moving some more tests from old functions to the "new" TestCode class

Change-Id: If146725ec71460512988f7104d7d4ec77fa55f0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326823
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-19 18:07:56 +00:00
Danny Tuppeny 1f460143e9 [analysis_server] Migrate definition tests to use TestCode
No functional changes, just migrating a few more tests to Test Code.

Change-Id: Iae9ced80ddbfb2fceab080f32c899dfcbb5ed5df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326824
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-19 17:49:04 +00:00
Sam Rawlins a46738c378 analysis_server: enforce prefer_void_to_null
Change-Id: I9dbb5d28ef92ac1af3a505e2790e42a136e3a417
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325801
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-15 19:35:21 +00:00
Sam Rawlins 283dad4ddc analysis_server: Enforce single quotes preference
Change-Id: I553befc2c45e66bfc569004d810b4e0a958d4baa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325544
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-09-13 17:48:22 +00:00
Danny Tuppeny ccbc3d95dc [analysis_server] Add additional tests for file delete/create with overlays
Change-Id: Iec6a158f394611a84bce6e4bf107039fbf82241e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-11 18:26:15 +00:00
Danny Tuppeny f2eee8bf71 [analysis_server] Don't flush diagnostics for deleted files that have overlays
Fixes https://github.com/dart-lang/sdk/issues/53475

Change-Id: I5eaba2192e8d9d141cbee02f4c9bbe941db026f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325262
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-11 18:16:38 +00:00
Danny Tuppeny 3bf8a233a5 [analysis_server] Add a preview flag for surveys
Change-Id: Iaacdeb24a222df3cf6d730641c7c4cf7355f0f2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-11 18:08:06 +00:00
Danny Tuppeny c11697af90 [analysis_server] Migrate remaining LSP tests to new set() methods for capabilities
No functional changes, just flattening capabilities into using set...() methods instead of providing them inline to the `initialize` method.

Change-Id: I0182a7dfa6ad2a3b3d83519b7a90f296722d05b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324523
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-11 18:00:10 +00:00
Keerti Parthasarathy 5b44717c63 Fixes for organize imports
- consider prefix when sorting
- remove duplicates
- ignore comment if there is a line break

fixes b/299271413, b/299270948, b/299272871

Change-Id: I0e5e72ae0d326042ee1bec777189c645a52e9ed7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324840
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-08 04:50:15 +00:00