Commit Graph

42 Commits

Author SHA1 Message Date
Danny Tuppeny 56e5655353 [analyzer] Migrate more LSP tests to null-safety
Change-Id: Iaeb2152d47df05434ab470901900da56cae7e792
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196125
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-20 21:15:28 +00:00
Danny Tuppeny 2dcbd22e0c [analyzer] Don't send Dart's trigger/commit characters for non-Dart LSP completion registrations
Change-Id: I703b183ebd9aedaf87dbbce664107d5bcff14367
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195509
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-15 19:44:27 +00:00
Danny Tuppeny ea9c6484f1 [analyzer] Fix path format in test for windows
Change-Id: I20ddb29e18303ad38a29a98c8ace00ced858b120
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194763
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-09 14:11:28 +00:00
Danny Tuppeny e8d53cff92 [analyzer] Improve handling of loose files and context rebuilds
Change-Id: Ifd047a29953503a70216ce29b3fe4cdbfc4132df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192926
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-08 17:49:35 +00:00
Konstantin Shcheglov e97f1bdbf0 Switch analysis_server to language 2.12, so null safety, but opt-out files.
This should allow doing partial migration, specifically protocol files,
which are imported by other libraries, but are a small library cycle
that does not import much outside of it.

Change-Id: I904c05d6d5b444ee9a9dbd1f7ada12aabdcc5165
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-03-30 23:39:37 +00:00
Danny Tuppeny ab8335b4fd [analyzer] Don't fail to initialize LSP server with non-file:// workspace folders/roots
Change-Id: I52fa0620ef563ff0362cb86b24ffc287e8e007c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184461
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-11 16:10:19 +00:00
Danny Tuppeny 28523a5e31 [Analyzer] Fix race condition in LSP semantic tokens + re-enable
Change-Id: I52c4eb18dd09e3334f21bbf5fac9ce4e716ea234
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-01-06 17:50:11 +00:00
Danny Tuppeny 3ee3dac08e [Analyzer] Disable LSP semantic tokens
There's a race condition in semantic tokens that's causing errors that I've yet to track down or reproduce in a test (though can relatively easily reproduce manually).

Change-Id: Icf65ec52e0307ed71f10c74ded120076e4fcd90c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176525
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-12-18 20:29:15 +00:00
Danny Tuppeny cb2ede57b7 [Analyzer] Add LSP support for textDocument/semanticTokens/full
Fixes https://github.com/Dart-Code/Dart-Code/issues/2202 + many more.

Change-Id: Ia2e8ec2415836a77618821144699971e97b4fc5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-14 20:37:29 +00:00
Danny Tuppeny 069a2f83d9 [Analyzer] Add support to LSP server for updating imports on file renames
Fixes https://github.com/Dart-Code/Dart-Code/issues/2761.

Change-Id: I9e4779760a02bc91850c45aa0d0bf261ef922222
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175485
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-14 17:06:03 +00:00
Danny Tuppeny 4525525a9d [Analyzer] Handle parsing v3.16 LSP Spec
Change-Id: I6afd5c32673ba580cdf6691bdfa521766f65c3b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158392
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-09 20:29:30 +00:00
Danny Tuppeny 44e680ac53 [Analyzer] Add LSP support for Format Selection/Range
Fixes https://github.com/Dart-Code/Dart-Code/issues/812.

Change-Id: I099654483f3799344d68640b4d00df88e6bbca01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171722
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-12 16:20:36 +00:00
Danny Tuppeny ca16e49baa [Analyzer] Close streams to remove listeners in LSP tests
Change-Id: I7b000de76c81c1d4786d4ced35b6e6f40b0f6ca4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
2020-09-30 16:27:29 +00:00
Konstantin Shcheglov 7ec28c3f08 Enforce await_only_futures and fix violations.
R=brianwilkerson@google.com

Change-Id: Icfc093d46562ddc7084151e76f495cc1462bb900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164257
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-24 14:28:00 +00:00
Danny Tuppeny f7b1a1ee1f [Analyzer] Support excluding folders from analysis with LSP configuration
Change-Id: Idc0ac1107e0e82dab15533739712a20bb5f24efc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164094
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
2020-09-23 15:01:09 +00:00
Danny Tuppeny 7b6c102137 [Analyzer] Encode/decode LSP payloads in tests to ensure they behave the same as real messages
Change-Id: Ia9efb2d5ba02fe60560b8deb663856ec27c79a87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162745
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-15 20:10:11 +00:00
Danny Tuppeny 047c0f860a [Analyzer] Support analyzing open files without open workspaces
This introduces the concept of temporary analysis roots, used to ensure loose files that are opened can be analyzed even when there are no other analysis roots (and therefore no existing analysis drivers).

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

Change-Id: I6b208f7c2fe8b538d7254691221fb72604ef156e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161500
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-02 17:46:02 +00:00
Danny Tuppeny c4a2efd6e7 Switch all generated LSP classes to use named constructor arguments
Change-Id: I111b58fa5d04314247d5f92650491cdeef6bd4a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153841
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
2020-07-09 17:18:07 +00:00
Danny Tuppeny 6db0396c83 Regenerate code from v3.15 LSP spec
Commit v3.15 of LSP spec + regen generated code

Change-Id: Ic0823063791900f347e1ff1f2242a6e4e6ed8ca6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153778
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-09 17:18:07 +00:00
Danny Tuppeny e9125c17c9 Minor refactor of LSP server capabilities+init test
Change-Id: I1447bac22e09c94b89e67a26f7b7ea98086bd152
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149589
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-06-02 14:33:51 +00:00
Danny Tuppeny 039581df15 Ensure plugin file types are registered for all LSP capabilities
Change-Id: Ic691aa83ae37700502a6d6de26a1b8a92b071287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149289
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-05-28 17:10:48 +00:00
Simon Binder aa529bc684 Support plugin notifications in LSP server
This adds support for analysis domains that plugins contribute to by
sending notifications. I've only implemented folding so far, but most
of this CL is to cache results from plugins and to adapt sending server
capabilities.

Instead of using a NullNotificationManager, the LSP server now uses a
regular NotificationManager, except that results won't be forwarded to
clients. LSP handlers will fetch partial results from plugins and merge
them with data from the server that will be computed when needed.

I've extracted the server capabilities calculation from the init
handlers into ServerCapabilityComputer. It will also contain the
interestingFiles glob from active plugins and re-register capabilities
whenever plugins change.

Change-Id: I9869240cbfa284592e952498933e638b89a2a763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142981
Reviewed-by: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-04-24 20:36:07 +00:00
Brian Wilkerson 8969b1839c Enable omit_local_variable_types in analysis_server
Change-Id: I7e5c13d40fd276854601681fc84be321e6031b10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141583
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-03-30 03:58:44 +00:00
Brian Wilkerson 58a9c22f80 Add return types to more methods in analysis_server
Change-Id: I65bed353bcff4f991faf8c3bdde979789a8d962b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-30 21:43:34 +00:00
Danny Tuppeny 7981947f75 Don't statically register LSP capabilities that will be dynamically registered
Fixes https://github.com/dart-lang/sdk/issues/39949.

Bug: https://github.com/dart-lang/sdk/issues/39949
Change-Id: I3a18ecfafae04d2a79841ead1481c8ad6c6cee83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129711
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-01-02 17:23:06 +00:00
Brian Wilkerson 4043a6fce3 Remove unnecessary uses of new in analysis_server
Other than analysis_options.yaml, all of the changes were from running
dartfix.

Change-Id: I92411642f12a00fc6bd0bfd24dd60fe67f0fed16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128845
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-12-18 19:01:51 +00:00
Danny Tuppeny 34bdcec877 Don't statically register for LSP document changes when dynamic registration is supported
Change-Id: I672a3207ab0a0f869721f6cce81b2b81c97db4ea
Bug: https://github.com/dart-lang/sdk/issues/38490
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119333
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-09-30 14:51:36 +00:00
Danny Tuppeny bd9be3c4ba Ensure opened LSP files end up in the cache when using onlyAnalyzeProjectsWithOpenFiles
Fixes https://github.com/dart-lang/sdk/issues/37338.

Change-Id: Icc04e77badfce51107633f55ce5dc602d1033ca4
Bug: https://github.com/dart-lang/sdk/issues/37338
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107286
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-06-28 12:37:25 +00:00
Danny Tuppeny e4362612b0 Add support for dynamic registration for LSP
Change-Id: I55c7b2f7d683acab0f6aa4bdbcba3b155d2de32c


Change-Id: I6a0b13856053bd86e77637b9664c7fe41194c5f3


Change-Id: I7472cf93efc29585ccbcbd1e6c7b9f703872b3c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103532
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-05-27 17:36:20 +00:00
Danny Tuppeny 4fc86d726f Fix some lints in LSP tests
Change-Id: Iff7e69d5d452a7bd405b727ab4966e1d71a89bda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103531
Auto-Submit: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-05-23 17:54:03 +00:00
Danny Tuppeny be6bbfc06b Remove redundant error notifications from LSP server
Change-Id: Ie2b4ac3c348835ad817cb34f24cc9b4108f1076d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101989
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-05-09 18:09:31 +00:00
Danny Tuppeny 15f1fc212c Add a flag to allow only analyzing project folders that contain open files
Change-Id: I7239043292315871d77739858b8342c434ac837c
Reviewed-on: https://dart-review.googlesource.com/c/93430
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-03-04 10:29:16 +00:00
Danny Tuppeny f484e1b05e Call canParse() for all LSP requests before passing to handlers
Any requests with params that don't pass canParse() will result in an InvalidParams error being returned without the handler being invoked.

Change-Id: Ic3e84b9259a467179baa2309fb58ee207f1225fa
Reviewed-on: https://dart-review.googlesource.com/c/94298
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-02-27 08:12:02 +00:00
Danny Tuppeny 26d91cf4b6 If LSP initialize fails in tests, throw
Previously if a test didn't expect initialize to error (and didn't check for it), the test failure would be hard to diagnose. With this, if you don't explicitly opt-in to allowing failure, an error during initialize will just throw and fail the test.

Change-Id: I01283a70b3571415ec16f2fc4d781c08a953a6a1
Reviewed-on: https://dart-review.googlesource.com/c/94291
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-02-27 08:12:02 +00:00
Danny Tuppeny 0adc9a4853 Split helpers out of LSP base test into a mixin
This splits the helper functions out of the abstract base test, which will allow them to be reused in integration tests that have their own transport (real stdio to a process).

Change-Id: I7777dc873582b4bacd91d998fed740ada47bd2b0
Reviewed-on: https://dart-review.googlesource.com/c/90062
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-01-21 16:06:28 +00:00
Danny Tuppeny e7b783ba5d Fix bug with deprecated rootPath + add tests
Change-Id: I53d0a9b9a367839cc4ecf463017463f343947dfc
Reviewed-on: https://dart-review.googlesource.com/c/88826
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-01-09 16:04:12 +00:00
Danny Tuppeny 7d0823a97c Advertise the commands/code actions we support to the client
Change-Id: I08064742f6591a702955408f023b2534bd7a2887
Reviewed-on: https://dart-review.googlesource.com/c/86883
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-12-11 15:13:57 +00:00
Danny Tuppeny 6ae01bacbe Tweak LSP test names
Change-Id: I74470c606e30775eb4efe3185551f6527268e9a1
Reviewed-on: https://dart-review.googlesource.com/c/85381
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-27 09:29:06 +00:00
Danny Tuppeny 285f7ddb1b Switch to using constants for LSP method names
Change-Id: I4fd1b4e192ec1d0e53a4b3d81e5fdb8c1bb40208
Reviewed-on: https://dart-review.googlesource.com/c/85380
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-26 17:01:29 +00:00
Danny Tuppeny 6f2fad87d9 Improve handling of errors
Don't send raw errors in showMessage, send a generic message and put the rest in a log (this is to stop dart exceptions being shown unexpectedly in error popups in the editor).

Change-Id: Ie919d0efe098dfde5de1e25cb8718d37b22f9673
Reviewed-on: https://dart-review.googlesource.com/c/84906
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-21 08:26:30 +00:00
Danny Tuppeny 257a6c8d2b Don't send error responses to $/ notifications/requests
The LSP spec says requests/notifications starting $/ can be ignored if they are not understood.

Change-Id: I6c0d011057b2f958c38fa2c4e92a1787944cb8d0
Reviewed-on: https://dart-review.googlesource.com/c/84902
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-11-20 15:31:16 +00:00
Danny Tuppeny 90d2c4f406 Split tests out into separate classes
Change-Id: I279b2426d0a6ecc1d9e04677bbb8d93ceb9b2d64
Reviewed-on: https://dart-review.googlesource.com/c/83743
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-11-08 17:11:15 +00:00