Commit Graph

35 Commits

Author SHA1 Message Date
Danny Tuppeny a779db0813 Update LSP spec to latest
Change-Id: I6f7ff3c6707f992aa618ad172e81857153b75795
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102360
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-05-13 15:11:15 +00:00
Brian Wilkerson 3019a8873a Check for completeness of test_all in analysis server and analyzer plugin
Change-Id: Ia25b1f93d5f2f3942f0c76d74556228a41410182
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97352
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-03-21 13:24:03 +00:00
Danny Tuppeny 01cc5a6305 Ensure unknown fields in LSP payloads are ignored
Change-Id: I3f4a2763b2a8714a80108a895c1887b5a36d2a3d
Reviewed-on: https://dart-review.googlesource.com/c/94500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-02-27 15:00:17 +00:00
Danny Tuppeny 8fb52650e5 Ensure LSP canParse type-checks optional values
Previously we were only outputting the validation code if the value was required. This changes it to also validate in the case it's not required, but only if it's not-null.

Without this change, the test that parses `'overwrite': 1` fails (a boolean is expected), but with it, it passes.

Change-Id: Ic4afe1f6a8f78add2385831907b226022b7ecaec
Reviewed-on: https://dart-review.googlesource.com/c/94293
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-02-27 08:12:02 +00:00
Danny Tuppeny d1876531f2 Fix LSP canParse to allow nulls where the spec allows
Change-Id: I8a34fbf03e45c85a70d44a54b1715b87f84f9c3b
Reviewed-on: https://dart-review.googlesource.com/c/94290
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-02-27 08:12:02 +00:00
Danny Tuppeny a52ac7d27b Correct LSP canParse functions for classes containing restricted enums
This fixes a mistake where enum classes were resolved to their base types (string, num) before being output in canParse methods of their containing class. This meant for "restricted" enum types (those that should not allow any value), canParse would incorrectly return true for out-of-bound values as long as they were the correct type.

Change-Id: I44e37a60b49287cf7202d5a578ee9c08cf898078
Reviewed-on: https://dart-review.googlesource.com/c/94280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-02-26 07:38:12 +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
Danny Tuppeny 8cddcd20cd Handle deserialising sub-classes in the super-classes fromJson
Change-Id: Ib9048cf674ad77711401e77e20e6dd8bc7e28e00
Reviewed-on: https://dart-review.googlesource.com/c/89363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-01-14 18:35:27 +00:00
Danny Tuppeny 4f160558b3 Extract inline interfaces from results definitions in LSP spec
Change-Id: I8661c7af628f0e3125db0613149bbcbc9f27bbe6
Reviewed-on: https://dart-review.googlesource.com/c/89301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-01-14 15:04:13 +00:00
Brian Wilkerson 47e988b781 Clean up the remaining copyright notices in analysis_server
Change-Id: Iee3110f92ab0f24312ddd1eff407d2229f895321
Reviewed-on: https://dart-review.googlesource.com/c/89101
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-01-11 15:38:56 +00:00
Danny Tuppeny 44449e29d2 Add a custom toJson snippet for LSP ResponseMessage for null handling
This adds some custom code for serialising ResponseMessage to ensure that only one of result or error are ever specified, as required by JSON RPC.

Change-Id: I2736b83755553a906264b1e5251d1a535dc289fb
Reviewed-on: https://dart-review.googlesource.com/c/88953
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-01-10 14:46:30 +00:00
Danny Tuppeny 666eee40c7 Updates to pase tuples in LSP spec
Change-Id: Ia1ce7579e954a8000b3460445859a2d221cf1a8c
Reviewed-on: https://dart-review.googlesource.com/c/87441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-12-17 17:58:17 +00:00
Danny Tuppeny 2dbf91ff13 Add support for parsing Maps from the LSP spec
Change-Id: Ieafcacb3ba2f6be8d3232025d22fa5ec94de5352
Reviewed-on: https://dart-review.googlesource.com/c/85768
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-12-04 14:27:19 +00:00
Danny Tuppeny 0a7cf2a513 Allow nulls for union values where the field can be null or undefined
Change-Id: If0fea932c1534e8a6a151e67b16ad78cb14ec98d
Reviewed-on: https://dart-review.googlesource.com/c/85743
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-12-03 16:34:16 +00:00
Danny Tuppeny be6593e5c6 Reduce params type from Either2<List<dynamic>, dynamic> to just dynamic
Nothing in the LSP spec supports arrays as params (let alone a union of a single item or array).

Since the new type is dynamic, this should be non-breaking even if LSP changes (though we'll want to put it back if we need to write a handler for something that accepts a union like this).

Change-Id: Id1af1d438fede94906ae76eaa8b9a959b0b62ccf
Reviewed-on: https://dart-review.googlesource.com/c/85396
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-28 08:20:07 +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 4a1983a1a8 Fix some TODOs and remove redundant test
Change-Id: Id2f45d5bb139ff3828de5fa916a863401bb156ed
Reviewed-on: https://dart-review.googlesource.com/c/85173
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-26 10:26:00 +00:00
Danny Tuppeny 3cedae6f09 Change diagnostic.code to a simple String
Change-Id: Ieb23cda7c6f2c1dffb2e07e47dfe29ddc78f41de
Reviewed-on: https://dart-review.googlesource.com/c/85174
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-11-22 17:54:12 +00:00
Danny Tuppeny 937e950fd2 Parse inline interfaces into types
Change-Id: I33c6d12d760b0e44505a34ad1b4cb77ffa0db0f3
Reviewed-on: https://dart-review.googlesource.com/c/84039
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-11-13 08:08:52 +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 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
Danny Tuppeny a394e4f492 Fix handling of JSON with interfaces nested within Unions
Change-Id: I926c2374860824db3ceae6d74286474feb730676
Reviewed-on: https://dart-review.googlesource.com/c/81100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-23 07:08:44 +00:00
Danny Tuppeny cddc2d42e1 Handle generic types in LSP spec parsing
The regex wasn't picking up generate type args (in interface definitions or usages in field definitions). This adds <> characters to the regex and handles them in mapping of types (as well as adds some additional tests to cover this).

Change-Id: I8187b3d2abb2b35c0d7638839e3116700cfbf9e0
Reviewed-on: https://dart-review.googlesource.com/c/81004
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-22 14:40:54 +00:00
Danny Tuppeny 36551624e1 Implement fromJson() constructors for LSP types
Also add a canParse() method that can check whether some provided JSON can be decoded into that type (used for detecting with type from a union to decode as).
Support equality checks on unions and a valueEquals() helper
Remove brittle tests that do exact comparisons on generated code
Fix deserialisation of lists to be cast and toList()'d
Add a more complete JSON test that includes lists, enums

Change-Id: Id56fdad9b1454e540e55907e0ff2608263a87c40
Reviewed-on: https://dart-review.googlesource.com/c/80580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-18 13:52:59 +00:00
Danny Tuppeny 3a69805f6b Switch enums that don't have type aliases to stronger-typed values
Change-Id: Ia05c234c27c0c71bbb25ed29c3f7a0c02e938acb
Reviewed-on: https://dart-review.googlesource.com/c/80203
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-16 18:03:59 +00:00
Danny Tuppeny ea72ba3b1d Move sorting from reading to codegen
Change-Id: I060e18851319cf7874a157b99fd019cd07169581
Reviewed-on: https://dart-review.googlesource.com/c/80102
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-16 14:40:56 +00:00
Danny Tuppeny 2084c5b2a9 Add toJson() methods
Change-Id: If5ffe3743c93100e012a2463fee3db37ab7d513d
Reviewed-on: https://dart-review.googlesource.com/c/79721
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-16 06:58:56 +00:00
Danny Tuppeny 311a184cb8 Remove type merging and the only instance that used it
Change-Id: I7b1f18073e4d204d0d92b531369888ec8f1f3dfb
Reviewed-on: https://dart-review.googlesource.com/c/79685
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-15 15:31:10 +00:00
Danny Tuppeny 88bde88112 Add constructors and mark all fields final
Change-Id: I7ab81c680956f80e6fb7a30bad2af35595baccef
Reviewed-on: https://dart-review.googlesource.com/c/79682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-15 14:05:25 +00:00
Danny Tuppeny e4842a293b Remove extra spaces in headers
Change-Id: I401ad4537e7a8c3ea4bc3f693cf45b5f7ef31267
Reviewed-on: https://dart-review.googlesource.com/c/79340
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-11 18:05:37 +00:00
Danny Tuppeny 931202df27 Improve wrapping of lists and *notes* in LSP spec comments
Change-Id: I32d9056e56a76588f9f26e36ebe040b0457dcd4d
Reviewed-on: https://dart-review.googlesource.com/c/79320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-11 17:30:30 +00:00
Danny Tuppeny 23e7f9d1eb Handle references to other classes in comments
Change-Id: I0a29355e0bbcb2a441dff90bc2cfc3475e8c1cd3
Reviewed-on: https://dart-review.googlesource.com/c/79321
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-11 17:27:53 +00:00
Danny Tuppeny fc0decc262 Improvements to the Dart code generated from the LSP spec.
Working towards making it compile, free of lint errors, formatting correctly.

Change-Id: I61d5ed6e89fdf24c97079745a3816b1b303e2820
Reviewed-on: https://dart-review.googlesource.com/c/79201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-11 14:59:25 +00:00
Danny Tuppeny 6d9cc6fa03 Add skeleton for parsing LSP spec from Markdown/TypeScript to generate Dart data classes
- Fixes to generation from spec
- Add basic code-gen with (very incomplete) tests
- Add some basic parsing of TypeScript interfaces in the LSP spec
- Add a group to the test
- Add code for extracting TypeScript codeblocks from Markdown

Change-Id: I733756d43744d89307b77527bd083cfacf670f56
Reviewed-on: https://dart-review.googlesource.com/c/79046
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-10 16:33:50 +00:00