Commit Graph

278 Commits

Author SHA1 Message Date
Danny Tuppeny f3f45a0e88 [analysis_server] Fix some typos in readme/spec
Change-Id: Ifb14293a886eedd0ee868ac43ef18b6224967ac8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-09 10:03:07 -07:00
Danny Tuppeny 9831fc4e98 [analysis_server] Rename "CodeAction" to CodeActionLiteral"
The term "CodeAction" is a bit overloaded. It could mean both an
individual result from the `textDocument/codeAction` request (which is a
`Command` or a `CodeAction`), or the `CodeAction` type defined in
the spec (which the spec refers to as a "Code Action literal").

To reduce confusion where we have similar APIs that operate on
"Code Actions" (CodeAction|Command), this renames the `CodeAction` class to
`CodeActionLiteral` and we will use the term `CodeAction` to mean either of
those types.

To make things simpler to review, this change _only_ renames the class, and also swaps the order of the types in some places that used `Either2<Command, CodeAction>` (which is opposite to the spec and some other code). Some further clean up will be done in a separate change.

Change-Id: Idcd8265f9229c3450004e68334e98a7b530330a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425300
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-29 20:54:58 -07:00
Danny Tuppeny 823947b857 [analysis_server] Always show type parameters in LSP type hierarchy, not type arguments
The change at 27ba8fce6c (to fix https://github.com/Dart-Code/Dart-Code/issues/4217) added type arguments to the LSP Type Hierarchy (before, neither type args or type params were shown).

Showing type arguments seemed reasonable when looking at supertypes, but behaves oddly for subtypes (and also when invoked on a type with arguments), so this partly reverts that and shows type parameters in all cases instead.

This simplified the code a bit and removed the `TypeHierarchyAnchor` class we were round-tripping in order to preserve the type arguments.

Fixes https://github.com/dart-lang/sdk/issues/60549

Change-Id: I4e0e92d4c73712fde7a9526c51699ecdae0f4ab1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-17 11:35:43 -07:00
Danny Tuppeny 5e62d29bf5 [analysis_server] Add 'range' to EditableArguments response
See https://github.com/flutter/devtools/issues/9035

Change-Id: Ia2cadea05f10f16e00d1dbf0240b16761c0c6b0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-01 10:50:07 -07:00
Danny Tuppeny 0476f21604 [analysis_server] Mark editableArguments / editArgument as not-experimental
This should not be landed until after https://github.com/flutter/devtools/pull/8990 lands and is included in the version of DevTools in the Dart SDK.

Fixes https://github.com/dart-lang/sdk/issues/55629

Change-Id: I19a72ef0e3680aa620d47f8f9556e38b90a98aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-01 10:08:56 -07:00
Danny Tuppeny 352c1d29c1 [analysis_server] Allow clients to provide diagnostic information to be included in the report
See https://github.com/dart-lang/sdk/issues/60259, though this still requires the related client changes.

Change-Id: I6a9419780b9d4c4b0c7a9518098c69e1609262b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418100
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-03-28 10:56:44 -07:00
Sam Rawlins 5d1f4876ee DAS: Fix many non_constant_identifier_names violations
This lint rule is a core lint rule; we have suppressed it only for
pre-existing code reasons.

There are a few individual files which simply have a consistent pattern
of including underscores in some names, so I add inline ignores there.

Change-Id: I89e6010203868fc10fda12b15353de41881d9b15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-20 09:00:06 -07:00
Danny Tuppeny dbfcf55762 [analysis_server] Add isDeprecated flag to editable arguments
See https://github.com/flutter/devtools/issues/8930

Change-Id: Ia23ff0659973971393e31bc6f00bd9104bd2c67c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411686
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-03 10:45:44 -08:00
Danny Tuppeny 2cc6b61867 [analysis_server] Support LSP inlineValues for variables and parameters
This adds support for LSP's "Inline Values" for variables and properties, allowing their values to be seen floating in the editor while stepping with a debugger without having to hover.

Including property access/getters may be useful too, but that can be added in a future CL (and perhaps initially behind a flag to get feedback, in case it turns out to bee too noisy).

Fixes https://github.com/dart-lang/sdk/issues/59891

Change-Id: I6305cfa9a7583c30500b90ee3b29852c82cc2494
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412080
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-02-26 12:12:01 -08:00
Danny Tuppeny af68c2d5ea [analysis_server] Add documentation to editable arguments that represent fields
If an argument is for a field parameter, this includes the documentation from that field, so that the property editor can show the same content you'd see by hovering over the argument name in the editor.

See https://github.com/flutter/devtools/issues/8938

Change-Id: Iebee757dd42fe9da2c8938c95febc99c0c96b609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411684
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
2025-02-24 11:30:28 -08:00
Danny Tuppeny b0566a5773 [analysis_server] Remove isDefault and don't set value when there's no argument for EditableArguments API
Now that we have `defaultValue` against each argument, there was some redundancy here.

`isDefault` is redundant because if `hasArgument=false` it's always default, and if `hasArgument=true`, then `value` and `defaultValue` can be compared
When `hasArgument=false`, there's no value in duplicating `defaultValue` into `value`

Change-Id: I5cba055e56175565842efef815e08dd46e9ed36a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406621
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-02-13 09:23:32 -08:00
Danny Tuppeny 204039cdf2 [analysis_server] Add "defaultValue" to EditableArguments API
This adds a new field "defaultValue" to the API response that contains the default value for a parameter.

Change-Id: Ief11da553d57871ad1e3fab54c731cbc98d674a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406000
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-29 08:00:26 -08:00
Danny Tuppeny ecf74c5c54 [analysis_server] Add widget name + documentation to EditableArguments
Change-Id: I8b8424b77ff1f9683934c64636a9f56097be870f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405123
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-22 15:48:23 -08:00
Mohamed Abdelaal 9b7bb9df90 Fix "the the" typo
Closes https://github.com/dart-lang/sdk/pull/59926

GitOrigin-RevId: cb37bca473b0c177b876a0f4e75858cd1862e699
Change-Id: I6827241b22e99db455945afcdfbaee0450999ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404923
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-01-21 14:08:20 -08:00
Danny Tuppeny 9b71817072 [analysis_server] Fix duplicate reporting of some LSP type parsing errors
Parse errors for spec types were being reported twice - once by the containing object (in canParse()), and once by the nested canParse() call for the nested type.

This skips reporting the error for nested calls to a canParse() method, which will always report the error itself.

Change-Id: I03e4a9638fd6a3fc77eac918f6fd16def93327d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404105
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-14 08:56:41 -08:00
Danny Tuppeny 76623a6541 [analysis_server] Extract TypeHierarchyItemLocation as ElementLocation2 and use for completion resolution
This moves completion resolution off `ElementLocation` onto the class recently created as `TypeHierarchyItemLocation`, which is now renamed to `ElementLocation2` and extracted to its own file.

Change-Id: I1f0b831ded7b08d6c09f97fcfd66f38f1dd4750e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401021
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-19 14:14:53 -08:00
Danny Tuppeny c8bf2914b7 [analysis_server] Revert to short-mode formatting for pkg:language_server_protocol
This code generation was previously formatting generated files using the latest version. In 76feb10829 I re-ran the formatter to get the new formatting style.

However recently, a pre-submit hook to verify formatting was enabled and revealed that pkg:language_server_protocol still has an older SDK constraint, so the presubmit fails (if you modify these files).

There are two options:

1. Restore formatting to the previous version for pkg:language_server_protocol
2. Increase the SDK constraint for pkg:language_server_protocol

I picked the first for now, since analyzer_server_plugin also depends on pkg:language_server_protocol and currently has a constraint of 3.3, and I don't want to mess with that just to fix the format presubmit.

Change-Id: I2347577561e659825b444ef6622d646c6e513aea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401001
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-12-16 08:54:40 -08:00
Danny Tuppeny 015f872e24 [analysis_server] Add an LSP handler for editing argument values
This adds basic editing for the argument types supported by `textDocument/editableArguments`. It doesn't currently attempt to format code currently (or use multiline/raw strings where they might be more appropriate), and does not allow arbitrary values that don't match the type for the parameter.

Change-Id: Ied95d95c0de39310aef0a1153864e902d56e1910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-12-04 20:09:30 +00:00
Danny Tuppeny dcb9ec10a1 [analysis_server] Add isEditable to editableArguments results and make false for non-editable strings
Change-Id: Iac020bfe0d495f3b634b95c8c32409433e9181bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396282
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-02 17:52:33 +00:00
Danny Tuppeny 04641dcc53 [analysis_server] Allow the client to control whether experimental handlers are registered with DTD
This will allow testing in-dev features with a real IDE without having to run/build the server from source.

Change-Id: I62cf732e7c4935c111f312eef25afd247759ae7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394502
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-11 18:57:22 +00:00
Danny Tuppeny 613bfa673f [analysis_server] Add a custom LSP handler to fetch editable arguments for the invocation at a position
This currently only supports int, double, boolean, string.

Change-Id: I236db8594907d28dc5901a384fbafdb34f243528
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394160
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
2024-11-11 15:38:42 +00:00
FMorschel 25c72bc9a6 [DAS] Go to Imports option
This change is to add a command that can be used to see which imports are contributing a symbol in the document. It'll work similar to things like "Go to Super", but when there are multiple results it will show them in a peek window, like Find References does.

Fixes: https://github.com/dart-lang/sdk/issues/56584
Change-Id: I70d369095a0500982818f0c8bea2651fe5f73431
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387387
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-07 18:09:35 +00:00
Sam Rawlins fbf331e0dd DAS: reformat source code with tall-style
Change-Id: I42b4a44fd6a2197e499e8623274b3cd1a4b5556f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394003
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-06 23:04:00 +00:00
Danny Tuppeny 6a94c6122f [analysis_server] Minor LSP refactors + fix
Some minor fixes/tweaks extracted from another CL

1. Fix tool/lsp_spec/codegen_dart to set `options` on `CodeStyleOptions` (a late field that needs to be set to the owning options file)
2. Fix a wrapped TODO to be indented so it's detected correctly
3. Move the custom `DartTextDocumentContentProviderHandler` handler into the `custom` folder
4. Merge `LspHandlerHelperMixin ` into `HandlerHelperMixin` since the APIs it uses are no longer LSP-specific and exist on the base server

Change-Id: Ie1b3a8057575346cf9bfb98465c0a3e330c28a82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392909
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-31 19:14:03 +00:00
Danny Tuppeny 97dafd74f5 [analysis_server] Consider sort_constructors_first lint when sorting
Fixes https://github.com/Dart-Code/Dart-Code/issues/4934

Change-Id: Ic6c739a2aaf6f62ecf0c2488a32f90c3f19738a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392141
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-29 20:04:49 +00:00
Danny Tuppeny 2bd91e8e58 [analysis_server] Rename some LSP types to match upcoming LSP 3.18
In the upcoming LSP 3.18 spec, many types that were previously inline literal types with no names (that resulted in us auto-generating names) have been made real types with names.

In order to reduce the size of the change when LSP 3.18 arrives, this change renames some of our existing types to match the new names that they will get with LSP 3.18.

There are no functional changes here, I simple added the names to the rename list (removing any redundant values that were previously being renamed differently), regenerated the code, and then updated any remaining references (in non-generated code) to those types to match.

Change-Id: Ic556ce6e52ba94a8d42099371be18288230cd5ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389160
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-10 15:08:41 +00:00
Danny Tuppeny 5d84439f5d [analyzer] Add support for "formatter" in analysis_options + use page_width in LSP
This adds support for validation + completion for `formatter/page_width` in analysis_options, and uses this value in preference to the client-supplied value in the LSP server.

It does not yet add support for the legacy protocol, and there are a few questions in https://github.com/dart-lang/sdk/issues/56864#issuecomment-2399289974.

See https://github.com/dart-lang/sdk/issues/56864

Change-Id: I7844e3abd1191beb9cc24197bbc8aa7c9e9ad4fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388822
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-08 16:37:54 +00:00
pq a6714ffdff a few new formatter migrations
See: https://github.com/dart-lang/sdk/issues/56685


Change-Id: Ifa7fbbc7aff7c5fd96b02cafe0da76b22a33b1e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386824
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 21:12:17 +00:00
Danny Tuppeny da414c2957 [analysis_server] Allow passing a DTD URI to the analysis server so it can provide LSP functionality to DTD clients
This adds a new request `dart/connectToDtd` that lets a client pass a DTD URI to the server. The server will connect to DTD and provide a subset of LSP methods (those that are currently available over LSP-Over-Legacy, minus the `connectToDtd` method itself) to DTD clients.

This works for both LSP and Legacy servers, and the shared tests run against both (where for legacy, the `dart/connectToDtd` request uses the LSP-over-Legacy support).

This is not currently behind a flag, however it won't do much on its own because no clients will make this request. Once we're happy the functioanlity is good we can either agree an SDK version number for IDEs to gate calling this method on, or we can expose a flag in server capabilities (and some equiv for legacy) so the client knows the functionality is available.

Change-Id: I911d37745a1b2685249dd88e4b152c3196ba627c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379303
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2024-08-22 20:43:41 +00:00
Danny Tuppeny 6411c07255 [analysis_server] Refactor initialization of LSP in both servers in preperation for DTD support
This change is just some refactoring and additional flags on handlers to reduce the size of a future CL that adds DTD support.

It:

- Slightly changes the meaning of `lspInitialized` in the server (to now mean the server is in the "initialized" state where it can handle the set of requests LSP allows after a server is initialized)
- Adds an additional future for `lspUninitialized` to track when the server moves _out_ of that state
- Removes an expando in LspOverLegacyHandler that tracked handlers against a server, because they're now available in the `lspInitialized` future (for DTD support, we need access to them without the LSP-over-Legacy handler, because we need to initialize DTD at startup regardless of whether a legacy client triggers LSP initialization)
- Adds a flag `requiresTrustedCaller` to handlers to indicate whether they can only be called by the native protocol clients. Tthis must be explicitly provided for shared handlers to ensure each choice is deliberate. The flag is unused in this CL but included here to reduce noise in the next (it touches many files)
- Changes the type of `toJson()` on generated enum clases to have the native type of the value that is returned

Change-Id: I0615cf4671b84887bf56c236d82d0fa3c26e6d87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379304
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2024-08-07 21:51:15 +00:00
Devon Carew cb64e64ccc [third_party/pkg] put package:dap and package:language_server_protocol under analysis
Change-Id: Ie1a48956055fa0f4ebcd85e5d2b762021fc074d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370101
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Sam Rawlins <srawlins@google.com>
2024-06-07 19:33:13 +00:00
Konstantin Shcheglov 5c07c89a35 Enable 'unnecessary_final' in analysis_server/.
Change-Id: I71ee934b915d4aff924cf5925f87bcc9adc6c015
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362901
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-16 20:04:15 +00:00
Danny Tuppeny 8e1751f4ce [analysis_server] Add LSP CodeLenses for "Go to Augmented" and "Go to Augmentation"
These are on by default but can be toggled in the client with the "dart.codeLens" setting, either by disabling entirely:

```
"dart.codeLens": false
```

Or individually

```
"dart.codeLens": {
  "augmented": false,
  "augmentation": false,
}
```

They require a client-provided command to handle the navigation, so this also adds a "commands" section to the client capabilities (in "experimental", because that's the extension point for non-standard LSP) that allows the client to inform the server that it handles such a command (which is documented in the readme and implemented in Dart-Code in https://github.com/Dart-Code/Dart-Code/commit/ebe029c3f9aca724d386b3da10f414f624bc705a).

Change-Id: I91791c9f4aa5957c4ab4b9c0c5bb4fcf8ebeb717
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359640
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-03-25 22:32:24 +00:00
Danny Tuppeny 4b85176d97 [analysis_server] Add a new LSP command for "Go to Augmentation"
This adds a custom command similar to `dart/textDocument/super` but for augmentations.

This won't show up anywhere on its own, but it will be added to the command palette in Dart-Code based on the server capabilities (and in the future, maybe CodeLens - although that will require some additional work in the server first since it will be the source of CodeLens even if they trigger client-side actions).

See https://github.com/dart-lang/sdk/issues/54742

Change-Id: Ib3a3fd08702e14b8bd251991035ef0b8d06ad996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358452
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-03-20 22:39:43 +00:00
Danny Tuppeny 2b8c2f6418 [analysis_server] Add a new LSP command for "Go to Augmented"
This adds a custom command similar to `dart/textDocument/super` but for augmentation targets ("augmented").

This won't show up anywhere on its own, but it will be added to the command palette in Dart-Code based on the server capabilities (and in the future, maybe CodeLens - although that will require some additional work in the server first since it will be the source of CodeLens even if they trigger client-side actions).

See https://github.com/dart-lang/sdk/issues/54742

Change-Id: I11ca115c61ade40bf51478f58b39b7caedac19c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358451
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-03-20 21:08:09 +00:00
Danny Tuppeny 2b713a9e4e [analysis_server] Add experimental TextDocumentContentProvider support for virtual documents
This adds support for serving the contents of virtual files to the client over a custom LSP protocol (based on the VS Code API of the same name). This is currently a custom Dart protocol but hopefully very close to something that could become standard LSP in future.

If the client advertises support for this feature (currently with an experimental flag "supportsDartTextDocumentContentProviderEXP1") we will return the set of URI schemes we can provide content for (currently "dart-macro-file"). Additionally, we will map internal analyzer macro paths (like `/foo/bar.macro.dart`) onto that scheme (`dart-macro-file://foo/bar.dart`) instead of standard `file://` URIs.

Overlays are not created for these kinds of files (because they would override the server-generated content).

Some language functionality "just works" because we can get resolved ASTs for the macro files (and many LSP features operate on these), but more testing (and tests) are required.

Included are tests for the virtual file methods (and events) and Go-to-Definition. Tests for other features are outstanding.

Change-Id: I2056699652873a12b730f565b823f187f883a1ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-18 17:34:43 +00:00
Danny Tuppeny da07f7a3e2 [analysis_server] Prepare server for handling multiple URI schemes
This is a slight refactor that should not change any behaviour extracted to make a future CL smaller. It:

1. replaces the previous `dartFiles` filter that was specifically for the `file://` scheme with a `List` that can be added to in future.
2. wraps calls to pathContext.fromUri() and pathContext.toUri() in all LSP server to go through a new class (`ClientUriConverter`) that will be extended to support mapping between to custom URI schemes (instead of `file:///`) for generated files.

Change-Id: Ie8eadcca3cfd708e4dfde07c22d411101cc9ca0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-01-16 21:28:29 +00:00
Danny Tuppeny 23e1437f6a [analysis_server] Update generated code to match latest spec
This should have been a small change to keep us in-sync with small changes so when there are bigger changes (LSP 3.18.0) the change is less noisy.

However, it turns out the meta model is built from the latest version always, so it includes 3.18.0 proposed features.

So this change not only regenerates the code with the latest spec, it also adds some handling to exclude any types (and methods) marked as proposed.

It also includes a few minor fixes to things like re-wrapping of comments where there are references.

So, it should still essentially be a non-functional change, but the CL isn't as small as planned because of the cleanup.

- The lsp_meta_model.json file is downloaded and not changes I've made
- The protocol_generated.dart file is the output of the code-gen
- All other files are changes I made manually

Change-Id: I6380f86848d2799cf94d58a419ace0bf0d5a35ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-05 19:58:47 +00:00
Danny Tuppeny a18a24c16c [analysis_server] Update + test for LSP readme being up-to-date with implemented methods
Change-Id: I4c25da38da937d76c4a1b1c9ba1e6318f16c1046
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333400
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-11-02 20:59:20 +00:00
Sam Rawlins f34ddb39f4 analyzer: Sort elements in generated LSP protocol files
Change-Id: Icddd53f8a5f858d49a2a00b853cd1f824e3783ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329583
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-10-10 17:39:49 +00:00
Alexander Thomas 49f4c5f94a [analysis_server] Move language server protocol to third_party
Bug: b/286184681
Change-Id: Iabb9070e354f85d29bb94dee4bdd52a0cf664c94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326643
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2023-10-10 07:48:30 +00:00
Sam Rawlins d48592f22a analysis_server: Indent pattern examples to be code blocks
As `{@link` is not a doc directive, it should not be written like it
is a doc directive.

Change-Id: Iebdc34175372ce1933b02c482499acf52ddd2324
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327285
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-09-24 18:01:22 +00:00
Sam Rawlins 283dad4ddc analysis_server: Enforce single quotes preference
Change-Id: I553befc2c45e66bfc569004d810b4e0a958d4baa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325544
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-09-13 17:48:22 +00:00
Konstantin Shcheglov 38546e90ab Pre-fix unreachable_from_main for instance members.
https://github.com/dart-lang/linter/pull/4441

Change-Id: I55afa6b7d78bc1114ce97c1b5bebcf7a8bca5b98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307975
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-09 22:39:27 +00:00
Danny Tuppeny d75a4e162e [analysis_server] Update LSP generated classes to latest published version of the spec
No functional changes here but there have been some refactors inside the meta model that required some minor tweaks (URI moved from a type alias to string to a spec-defined base type).

I also improved the handling of some type references in the comments we bring in so they're clickable in more places.

Change-Id: I7c725d01b6d7bc0925979b8118dbfd8952f78724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297482
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 15:09:20 +00:00
Danny Tuppeny 8696096afd [analysis_server] Prompt when there are issues that might be fixable by "dart fix"
Change-Id: Ibcc7a9b0b4258b0576e6f6e58bbb4b08987de0ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289601
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-03-21 17:05:39 +00:00
Josh Soref 9e4dc755cb Spelling pkg
Closes https://github.com/dart-lang/sdk/pull/50921

GitOrigin-RevId: 6b1ca502b6722b0a987f33ace66f65cbd2c24e23
Change-Id: I74e4ff3c8e759c576036d6b791bd7734ebd215d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278536
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-19 10:06:29 +00:00
Danny Tuppeny 41b5ba1629 [analysis_server/lsp] Allow user to configure whether Workspace Symbols includes all files or just their workspace
Fixes https://github.com/Dart-Code/Dart-Code/issues/1903.

Change-Id: I1b9221a1ebfa83e3089b4036e6d0d5446ac24461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-19 19:07:26 +00:00
Danny Tuppeny 699b42c8e3 [analysis_server] Support adding multiple imports for @overrides completions
Related to https://github.com/Dart-Code/Dart-Code/issues/4116.

Change-Id: I81b9e7bfbe4bbd093770925f9dcb640b72487142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270181
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-11-21 18:06:35 +00:00
Danny Tuppeny fc9581d758 [analysis_server] Use ElementLocation to properly resolve documentation in LSP completions
Fixes https://github.com/Dart-Code/Dart-Code/issues/3787.

Change-Id: Iffd83fbd96f2ff8dc136c2a3f5ec7824e7451ca2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-11-15 19:14:18 +00:00