This change adds a new, experimental completion domain request
`completion.listTokenDetails`. Its purpose is to allow
other programs to observe and make smarter decisions contingent
upon analyzer's internal knowledge of a Dart program.
Bug: 36083
Change-Id: I5ab477221efeac076eccc873a29cf6feae91052e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95100
Commit-Queue: Ari Aye <ariaye@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This paves the way for replacing these data structures with
ForStatement2Impl, by making them expose the same set of child nodes
that ForStatement2Impl would.
This required some fixes in the implementations of completion and
refactoring, since they make assumptions about the relationships
between nodes and their children.
Change-Id: I35e2873fcee2c88215c51c5caa5318934fc2a1a8
Reviewed-on: https://dart-review.googlesource.com/c/94401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This method is (accidentally) not currently being called, but it will be soon. The codegen wasn't using the resolved base-type for the enum when writing the type check.
Change-Id: I025ed5109c70d8916f800295350a3f4eaf8f16f2
Reviewed-on: https://dart-review.googlesource.com/c/94294
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
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>
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>
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>
We only provide fixes/refactors/assists to clients that support returning literal CodeActions (not just Commands). CodeActions allow us to return a WorkspaceEdit directly without having to encode the action into a command/argument set that is tround-tripped to the client. Supporting CodeActions on the client is relatively straight forward (since it just removes a round-trip and applies the edit directly).
Change-Id: I7f5a8c22e66ac23bcde6d5782bc2eaa6aeb283da
Reviewed-on: https://dart-review.googlesource.com/c/94221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
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>
Otherwise we'll need to increase the timeout to account for server startup (which will mask if the exit really is taking a longer time than it should).
Change-Id: I5c770efa62dc2a66946fd7a6c07665d3f1b80ee4
Reviewed-on: https://dart-review.googlesource.com/c/94260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
Previously we assumed enum classes could only be the values specified in the spec, but this was not correct - newer clients may know about values that we did not know about at the time we shipped(/last regenerated).
This makes the default for an enum class to support any class (avoiding deserialisation failures when new clients send newer values), and opts-out for those where the spec is explicit that the value set is fixed.
Also opened https://github.com/Microsoft/language-server-protocol/issues/686 for clarification that these "fixed set" values are explicitly intended to never be extended, or whether this is accidental.
Change-Id: I6243fc91c14ec0fa5622d3f6f29bf77cadf7da64
Reviewed-on: https://dart-review.googlesource.com/c/94220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
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>