Commit Graph

113 Commits

Author SHA1 Message Date
Konstantin Shcheglov d8da40ec52 Migrate lib/src/protocol_server.dart and related.
Change-Id: Ibb1e5a53aa8ad67fa43b315880c491093b051e20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-07 00:26:59 +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 d901f7326a [Analyzer] Add code completion for Pub package names
Change-Id: I0fa8fb1c2801e2acb2d2cf75f7efecf4f9058eeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-03-03 17:12:58 +00:00
Danny Tuppeny 468556c58d [Analyzer] Cancel LSP refactor requests when another refactor request arrives
See https://github.com/dart-lang/sdk/issues/43459.

Change-Id: I52bf26e80b0d6ddb577c89b5a18ff7563e614cb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165321
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
2020-09-30 16:27:29 +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
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 44f869d3a6 Cap the amount of time spent waiting for plugin completions in LSP
Change-Id: Ic60d9936a252a1322becc233d696dfed41af834a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150927
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-06-12 14:11:24 +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 b03ef5b3fe Convert more doc comments in analysis_server
Change-Id: I333d0af4444226a8152e840c4d9015fb4c30bd32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135700
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-02-13 19:29:28 +00:00
Brian Wilkerson 5b1065ac60 Enable avoid_init_to_null in analysis_server
Change-Id: I1909b0d8939d9b436fce772bd97dc4835f1093ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131322
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-13 00:35:34 +00:00
Sam Rawlins 327b1eb24f analysis_server: Make private fields final where possible
Change-Id: Ibdeb7e66f07bf81205d70ac5d1c4cb4aa5a97671
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-01-08 22:08:02 +00:00
Brian Wilkerson 91d6e1a0a7 Enable annotate_overrides in several packages
Other than analysis_server/test/analysis/notification_overrides_test.dart,
which had a naming conflict, all of the changes were made using dartfix.

Change-Id: I911dd75dcdee00420caa48724125e86d47c8857d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130002
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-01 21:31:40 +00:00
Brian Wilkerson 7d41ae7d15 Enable unnecessary_this in several packages
Change-Id: I743066d66dbf1dff984e8f8bf5b7a472c9bc7ff7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129821
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-12-28 20:43:16 +00:00
Brian Wilkerson 52c6620986 Enable unnecessary_const in analysis_server
Change-Id: I44d9902cb23d005ebedd4bc37d57d3751a8ebdc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-12-19 17:32:52 +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
Paul Berry c0144141ce Move TestPluginManager, MockServerChannel, and ServerError into utilities
There's no reason these classes need to be in test, and I want to
re-use them in a tool for testing NNBD migrations.

Change-Id: I43686a44d5f8d83f0d1cc23315746250eb766681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125485
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-11-18 22:26:00 +00:00
pq 52abcd3dd2 apply prefer_equal_for_default_values
Change-Id: I9b6fd3ee18ec834a5db3d0d25455b6db9ea4fbe2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108664
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2019-07-10 19:31:40 +00:00
Danny Tuppeny fca2c82be0 Add support for cancelling requests in LSP server
Change-Id: I2a651b1e4f8509c7f10d245b2369aab842d08041
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103845
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-05-29 14:52:40 +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 bfe15d87d8 Fix LSP exceptions serializing ResponseErrors with Uris
The ResponseError.data field was typed `dynamic` (as in the LSP spec) but this allows us to accidentally put non-serializable classes in it which will result in server errors when we try to send them back.

This change forces them to Strings and it's up to the code constructing the error to convert any additional data to a string first.

In order to catch this in tests, the mocks now force serialisation of all types flowing from the server to the client (this already happened for client to server).

Change-Id: I5d7f322e1a4296b1479468e36d81daebdbb4ab52
Reviewed-on: https://dart-review.googlesource.com/c/89511
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-01-16 16:57:43 +00:00
Brian Wilkerson 73ea4b1a82 Remove dead code from the analysis_server tests
Change-Id: I91f943baa191e27b7e647d78e5424fcb3a5cc990
Reviewed-on: https://dart-review.googlesource.com/c/88165
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-01-02 14:23:09 +00:00
Danny Tuppeny 64a4354a55 Improve handling of fatal errors in LSP
This adds a new type of error for when a client request to edit a document
is not valid because the document offsets don't match up. In this instance,
the client/server are out of sync and we shouldn't try to continue as we
may produce edits that ruin the users work. The server checks errors being
sent to the client and if it sees this type of error will switch to a state
that requests all messages, send a logMessage and then shut down after a few
seconds.

The LSP spec has been updated to suggest that clients automatically restart
servers if they quit unexpectedly (though advising not to do it forever in
the case of a crash at startup).

Change-Id: I7beafc87a082b971600135a4cc76eae53f5d9443
Reviewed-on: https://dart-review.googlesource.com/c/87841
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-01-02 09:07:21 +00:00
Danny Tuppeny ecccc0d94e Fix some LSP TODOs, remove some redundant code, add comments
Change-Id: Ibd51b17919245f4215fa49a64fd008ba268ca174
Reviewed-on: https://dart-review.googlesource.com/c/87442
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-12-18 07:33:35 +00:00
Danny Tuppeny cd94fce0fe Add ability for LSP server to send requests to (+ receive responses from) client
Change-Id: Iff1f8f63dc58ef2689ecc44f6e705d6811b12667
Reviewed-on: https://dart-review.googlesource.com/c/86420
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-12-06 19:11:46 +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 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 04777b58cc Add analysis (publishDiagnostics) and handling of opening/editing/closing files
Change-Id: I6dadf125b1a71c4f321f4ab9a01ff2bbfcbd1d4a
Reviewed-on: https://dart-review.googlesource.com/c/82500
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-08 08:52:48 +00:00
Danny Tuppeny d802c7d33d Improve LSP server tests
Change-Id: Ib9c7cd2966c6cf4d0c02e56ec405761f899e6668
Reviewed-on: https://dart-review.googlesource.com/c/82441
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-01 17:08:16 +00:00
Danny Tuppeny 8852d36315 Add --lsp flag to analysis server and add basic Initialize handler
Change-Id: Iaf6c2a7cd56dea27233c4be1df2da900653e1822
Reviewed-on: https://dart-review.googlesource.com/c/81275
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-31 20:00:51 +00:00
Peter von der Ahé ed42aab273 Move source.dart to package:analyzer
Change-Id: Ide66d4f69b8588f04967c510eae0a733b4b3f0c5
Reviewed-on: https://dart-review.googlesource.com/c/77860
Auto-Submit: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-10-03 12:56:49 +00:00
Konstantin Shcheglov 6f9073bb9d Wait for Analysis Server errors only while waiting for a response.
Change-Id: Ifd07293322b69cc9bab98e3698d63249b62abdb0
Reviewed-on: https://dart-review.googlesource.com/69242
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-08-10 00:34:48 +00:00
Brian Wilkerson 95d1ebd9f0 Fix one cause of timeouts in tests
Change-Id: I8514c7a1e89c69bbbf11882fa734903cd7c7569c
Reviewed-on: https://dart-review.googlesource.com/68430
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-08-06 16:08:05 +00:00
Devon Carew 6e322f794c No longer run pub list-package-dirs from the analysis server.
Change-Id: Id02bdfc25cb8827873ff607f7c4d4a3401c9a199
Reviewed-on: https://dart-review.googlesource.com/67205
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-07-27 23:05:41 +00:00
Brian Wilkerson b936ffb329 Move several libraries out of the public API
Change-Id: I8259de00134310f25b1c6168940aea5190488999
Reviewed-on: https://dart-review.googlesource.com/51443
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-04-17 17:35:27 +00:00
Brian Wilkerson d06dbb2ba8 Make most of the server Dart 2 safe
Change-Id: Ic9e8ea2557d01c05caedc126486778865af0396d
Reviewed-on: https://dart-review.googlesource.com/48262
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-24 15:33:53 +00:00
Konstantin Shcheglov 94d8d6bf3b Remove unnecessary cast and wrapping Future.
R=brianwilkerson@google.com

Change-Id: I7b164019e55274c58f13fc67d0dc92e47f01aad7
Reviewed-on: https://dart-review.googlesource.com/40466
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-09 20:25:19 +00:00
Paul Berry 105b170ddb Roll package test to 0.12.29+1 and stack_trace to 1.9.0
This required some changes to analysis_server, since analysis_server
used to have its own version of pumpEventQueue().  Since
pumpEventQueue() is now provided by the test package, I've removed
analysis_server's version, and I've updated some of the call sites to
pass in "times: 5000" to replicate the old analysis_server behavior.

This also required some changes to analyzer, since the fail() method
is now marked as @alwaysThrows, so no code may follow it without
producing a dead code hint.

Change-Id: Ie5ef3a5cc685c18da02de699e59f63f3bb8865f7
Reviewed-on: https://dart-review.googlesource.com/32683
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-01-07 14:22:23 +00:00
Brian Wilkerson e8b617217f Remove most of the remaining references to AnalysisContext
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/3007493002 .
2017-08-23 12:57:09 -07:00
Konstantin Shcheglov b1589bf879 Replace typed_mock with mockito in analysis_server.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991773002 .
2017-07-26 08:14:25 -07:00
Brian Wilkerson 55d735911b Remove the unused operations queue
R=devoncarew@google.com

Review-Url: https://codereview.chromium.org/2957643002 .
2017-06-23 09:04:13 -07:00
Brian Wilkerson fb982f5476 Make server use the common protocol classes
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2879273002 .
2017-05-15 09:35:46 -07:00
Brian Wilkerson e55812a3f2 Unify the server and plugin versions of the generators
R=devoncarew@google.com

Review-Url: https://codereview.chromium.org/2844273003 .
2017-04-28 07:46:29 -07:00
Lasse Reichstein Holst Nielsen d4c1531b5b Use the *correct* type for the fix to analysis_server/test/mocks.dart.
It's a stream, not an iterable, so the return type is a Future.

Review-Url: https://codereview.chromium.org/2784363003 .
2017-03-31 16:36:24 +02:00
Lasse R.H. Nielsen 83298690b0 Fix static typing problem in analysis_server tests.
After changing argument of `Future` constructor to be `()->FutureOr<T>`,
the `()->Future<dynamic>` argument didn't work.
Problem compounded by return type of `Stream<T>.firstWhere` being `dynamic`.

R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2794503002 .
2017-03-31 14:12:32 +02:00
Konstantin Shcheglov de4d8b3a78 Switch analysis_server to use 'package:test'.
I'm changing DEPS in the corresponding analyzer CL.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2394683006 .
2016-10-06 08:47:15 -07:00
Brian Wilkerson 685e4ff9e1 Revert "Remove unused option in server API"
Review URL: https://codereview.chromium.org/2382033003 .
2016-09-30 10:14:12 -07:00
Brian Wilkerson 2972bd0d6b Remove unused option in server API
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2382053002 .
2016-09-30 09:04:38 -07:00
Florian Schneider 2a6847de41 Make some pkg tests less timing-dependent.
Testing should not depend on how long it takes to get a response from the
analysis server.

Depending on how long an analysis step takes, these tests will randomly fail
e.g. when run in -mdebug mode, or with other VM flags that change (i.e. slow-down)
timing (--trace-compiler, --optimization-counter-threshold=5"

There are probably more problematic places like this. I just fixed the ones that
I saw failing when running with --optimization-counter-threshold=5.

BUG=#26556
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2016993004 .
2016-05-30 12:14:16 +02:00
Harry Terkelsen 1745ba77f5 fix all instances of "the the"
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1980573003 .
2016-05-13 12:38:25 -07:00
Brian Wilkerson 3bf8b18680 More strong mode clean-up in server
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1966453002 .
2016-05-09 13:24:56 -07:00