Commit Graph

20 Commits

Author SHA1 Message Date
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 73e544ed0b Improve errors when LSP integration tests fail to spawn server
When the server fails to start up (writing to stderr) the tests currently would just hang waiting for responses to messages. This will just throw the message as an exception, failing the test with a more useful message, for example:

```
00:07 +0 -1: ServerTest | test_exit_afterShutdown [E]
  Analysis Server wrote to stderr:

  file:///Users/dantup/Dev/Google/dart-sdk/sdk/third_party/pkg/linter/lib/src/analyzer.dart:106:27: Error: The method 'registerDefault' isn't defined for the class 'Registry'.
   - 'Registry' is from 'package:analyzer/src/lint/registry.dart' ('file:///Users/dantup/Dev/Google/dart-sdk/sdk/pkg/analyzer/lib/src/lint/registry.dart').
  Try correcting the name to the name of an existing method, or defining a method named 'registerDefault'.
      Registry.ruleRegistry.registerDefault(lint);
                            ^^^^^^^^^^^^^^^
```

Change-Id: If64b68b17a0d379f8879891f0346704d4ad360e8

Remove unused imports

Change-Id: I745499f7b038c81320c127410967d939c7756e51
Reviewed-on: https://dart-review.googlesource.com/c/94222
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-02-25 17:13:52 +00:00
Danny Tuppeny 6af24a2490 Move LSP diagnostic server test -> integration
This tests we can spawn the diagnostic server on-demand. The test was previously marked failing because it needed to be a real inrtegration test.

Change-Id: I52638682d7fb1807584601f7ff933f30b1bd6d70
Reviewed-on: https://dart-review.googlesource.com/c/93949
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-02-25 12:03:58 +00:00
Danny Tuppeny ba07724b19 Add support for LSP Integration tests w/ basic shutdown test
Change-Id: Ifbd957d1d6b287b083128cda4d7b99b8d50dd56c
Reviewed-on: https://dart-review.googlesource.com/c/90065
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-01-21 16:06:28 +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 17a439633d Add a custom LSP method dart/diagnosticServer to start server/return port
Change-Id: I9d9be244251099c947b2998f0a45ec29ef29ad83
Reviewed-on: https://dart-review.googlesource.com/c/90012
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-01-17 16:37:49 +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 7280ca87a0 LSP requests must always be responded to, even if optional
Change-Id: Ieb3314028436a566c5fe4c2786c6b9196a03e26a
Reviewed-on: https://dart-review.googlesource.com/c/87800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-12-20 17:36:58 +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 8fa1e010c4 Validate paths and offsets for all requests
Change-Id: I72ede118b825debc6a16ec227b5116aa2fc73a8e
Reviewed-on: https://dart-review.googlesource.com/c/85162
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-26 11:39:30 +00:00
Danny Tuppeny 1ac2251706 Extract state handling from LSP server to separate handlers
Change-Id: Iec52b5159a93071db1750e4ab4fe9b982810bb07
Reviewed-on: https://dart-review.googlesource.com/c/85081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-11-21 15:38:55 +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
Danny Tuppeny d5e853e0ce Improve parsing of LSP spec
Change-Id: Ica48b57c890105df346c5a133fe0389bd92dbb6e
Reviewed-on: https://dart-review.googlesource.com/c/83388
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-08 15:31:26 +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
Konstantin Shcheglov b71948faee Consolidate MockSdk(s) into one, living in analyzer/lib/src/test_utilities.
R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I70946b8e6f790608ad52c8f27cd6f506673f7b0d
Reviewed-on: https://dart-review.googlesource.com/c/82710
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-11-02 21:52:44 +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