Commit Graph

55 Commits

Author SHA1 Message Date
Robert Nystrom 442bafa30a Test that analysis_server handled private named parameters in argument edits.
It's already doing the right thing in the property editor, but this
ensures we don't break it.

Change-Id: Id57fad923dd2c5f4c1986122edca5aadd8544912
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479421
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2026-02-10 06:53:30 -08:00
Fedor Shcheglov bf97a8dc1d Fix a crash resulting from attempting to access a null URI when running package_names lint during code actions.
Change-Id: I8ad16c5316ba08eb77109803d09b210135639be4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-29 18:05:10 -08:00
Sam Rawlins d4f2fec655 analyzer: Tidy and document LintCode.new and interpolated args
Deprecate the `hasPublishedDocs` parameter, as it is unused and
unnecessary. This triggers dev package versions.

Document how args are interpolated into problemMessage and correctionMessage.

A breaking change landed in analyzer_plugin, requiring a bump to
0.14.0.

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

Change-Id: I8e8f7e6af1c20ca9247cccd53e1fe2e5fc3cf083
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461581
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-11-12 13:13:11 -08:00
Sam Rawlins be3237e3ec analyzer_testing: deprecate MockPackagesMixin.addPedantic
Change-Id: I377e054a9abb167f7208f27067c905ff5947897c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460481
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-07 14:38:12 -08:00
Paul Berry 0be8e95a22 [messages] Simplify uniqueName.
Removes nearly all of the special handling of `uniqueName` in
constructors in the `DiagnosticCode` class hierarchy.

With three exceptions, the value passed for the named parameter
`uniqueName` is the same as the value that will eventually be stored
in the `DiagnosticCode.uniqueName` field. The three exceptions are the
constructors for `LintCode` and `SecurityLintCode`, and the unnamed
constructor for `LinterLintCode`. These constructors allow
`uniqueName` to be `null`, and if `null` is supplied, they replace it
with `LintCode.$name`.

These exceptions are needed for analyzer API compatibility in the case
of `LintCode`, and for compatibility with google3 code in the case of
`SecurityLintCode` and `LinterLintCode`.

In follow-up CLs, I will be updating google3 code to make the
exceptions in `SecurityLintCode` and `LinterLintCode` unnecessary.

Change-Id: I6a6a6964d828c3a8db6563d47347d5ca8f550ac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459001
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-11-04 06:58:25 -08:00
Paul Berry 21ab9e1ac5 [messages] Add uniqueNameCheck constructor parameter.
Adds the constructor parameter `uniqueNameCheck` to `DiagnosticCode`
and derived classes. If a non-null value is supplied for this
parameter, an assertion checks that it's equal to
`uniqueName`. (Passing a `null` value disables the assertion; this is
necessary to preserve analyzer API compatibility).

The reason for this change is that the value supplied for `uniqueName`
when calling constructors in the `DiagnosticCode` class hierarchy is
not necessarily the same as the value that is eventually stored in the
`uniqueName` field; it goes through a sequence of manipulations while
being passed up the superclass chain that make its actual behavior
difficult to follow. The `uniqueNameCheck` field allows me to test the
theory that the actual values that wind up in `uniqueName` are simply
the analyzer codes, with the exception that `LinterLintCode.` is
replaced with `LintCode.`.

In a follow-up CL, I plan to eliminate nearly all the manipulations of
`uniqueName` that occur while being passed up the superclass chain,
which will simplify the code generation logic for computing
`uniqueName` values. Adding `uniqueNameCheck` now allows me to test
out the new, simpler logic, and verify that it will produce the same
result as today's more complex logic.

The `uniqueNameCheck` parameter is marked as `@deprecated` to prevent
clients from trying to use it; this ensures that when I remove it in a
follow-up CL, it won't be necessary to bump the analyzer major
version.

Change-Id: I6a6a696440bce62a31b988d12064244e54e37b6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458820
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-11-03 11:43:04 -08:00
Paul Berry b1c2b784d5 [linter] Stop using pkg/analyzer/lib/src/lint/linter.dart.
Replaces imports of `pkg/analyzer/lib/src/lint/linter.dart` with
direct imports of the files it re-exports:

- `package:analyzer/analysis_rule/analysis_rule.dart`
- `package:analyzer/analysis_rule/rule_context.dart`

Also inlines the typedefs `LintRule` = `AnalysisRule` and
`LinterContext` = `RuleContext`.

The rationale for this change is that implementers of lints inside of
google3 tend to use existing lint rules as a starting point; this has
resulted in a lot of internal code importing from
`package:analyzer/src`, which makes modifying analyzer internals more
difficult. Changing existing lint rules to use proper analyzer public
APIs should help curb this trend.

Change-Id: I6a6a6964136534b393c9504bea11d22eafb11c05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459180
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-03 06:21:01 -08:00
Sam Rawlins 8d35b4b546 DAS ServerErrorCodes: Make constant fields use lowerCamelCase names
Change-Id: Ied8cbf3a8b653b6deee30621f8a9e77f0377a707
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458700
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-31 10:17:55 -07:00
Sam Rawlins 33f664940a Bump DAS to use Dart SDK 3.9.0
Change-Id: I04bc285d822a657adb5573c6de3eb38655ab0fcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448232
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-09-03 12:56:29 -07:00
FMorschel 7c754d325d [DAS] Adds typeParametersInScope for DartEditBuilder.writeType and related methods
This change adds a new parameter `typeParametersInScope` to `DartEditBuilder.writeType`, and related methods to deprecate the previous `methodBeingCopied` parameter, which limited our ability to pass in some type parameters that are in scope.

Also fixes a TODO about testing if the `Record` feature is enabled or not.

And as a bonus, we now always write down type parameters by looking for the closest public type or falling back to `Object?` or `dynamic`.

Bug: https://github.com/dart-lang/sdk/issues/61186

Change-Id: I7a7b1c62adb81aecfdf61ebbaa0d95f1d33bced8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442282
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-08-29 10:32:10 -07:00
Sam Rawlins 438b560e44 analyzer: Dismantle legacy 'linter.dart' library
This library mostly exports _public_ API, and the to-be-deprecated
NodeLintRegistry class. So we just move private RuleContext classes
into a new library, and remove the exports.

The lint rules then are adjusted, mostly just renaming
NodeLintRegistry -> RuleVisitorRegistry. But also, this removes a lot
of implementation imports; most rules now have _no_ private imports!

Change-Id: I023f7efa979f94d208a6ae7421902145e8761c9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443364
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-08-11 13:59:53 -07:00
Danny Tuppeny f2c73a7a3f [analysis_server] Fix DTD test EOLs on Windows
Change-Id: I5ea76b7fd54ff52cb649925a0839addb2f1115e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443805
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-08-05 12:37:21 -07:00
Danny Tuppeny db743776d4 [analysis_server] Ensure LspChangeVerifier always normalizes source + expects normalised source files
This removes `useLineEndingsForPlatform = false` from a few more tests, and as part of fixing them, ensures that `LspChangeVerifier` always normalises the expected text, and asserts that all modifies files were modified.

This highlighted many more tests that were not normalizing their content (but didn't use `useLineEndingsForPlatform` because they didn't previously call any shared methods that required/asserting normalization. Those tests were also updated.

Change-Id: Ica914b6207b3c9fd440de4e0470e50a896dd976d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443561
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-08-05 10:06:01 -07:00
Elliott Brooks a1699ecfb0 [Property Editor] Use dot-shorthand syntax in enum edits when possible
Bug: https://github.com/dart-lang/sdk/issues/60727
Change-Id: I41388422b0c317e7500166d29ba4f9e7b656a24f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
2025-07-24 13:40:35 -07:00
Danny Tuppeny b0d4ab8ef9 [analysis_server] Move test/integration to integration_test
This was mostly a rename/move of the folder (and the analysis server updated all references), but I also had to:

- add `integration_test/analysis_options.yaml` to import from `../test` to get the same lint ignores
- update paths of exclusions in `verify_sorted_test.dart`

By moving all of the tests that start the server out-of-process out of test, we can:

1. Use "dart test" to just run the faster tests ("dart test test") and get functionality of the pkg:test runner (for example running tests concurrently and JSON output)
2. Allow VS Code to spawn different debug sessions for the "test" and "integration_test" folder, which means we can use a `preLaunchTask` to trigger compilation of the analysis server from source whenever running integration tests (avoiding having to compile manually, or run from source in a way that compiles a new server for each test suite)

Change-Id: I37cc03dc32d08c5b51a2eab79f6338bb079b32ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434801
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-17 12:54:41 -07:00
FMorschel bc4e201375 [DAS] Fixes missing case for create class
This also adds a new priority for mixins when the written type name starts with lowercase letters (to match the class existing ones) and tests the priority between it, create class and import fixes.

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

Change-Id: Ie451db6a273fe8eb52df21725276068b1980e7f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433500
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-09 15:10:50 -07:00
FMorschel fae7752e9e [DAS] Adds tests for fix priorities and new priority for Create class
The related issue asked for a new priority for the `Create class` fix
that would be lower if the undefined name was lowercase, giving the
`Create method` and `Create function` fixes a higher relative priority.

This change also adds a new abstract class to test the relative priority
between fix kinds. It is also used to test agains the merge combinators
fixes.

Fixes: https://github.com/dart-lang/sdk/issues/60523
Change-Id: I938f52a577ecf1b6bb8dd66c94fd45395a011ffa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422321
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-05 16:58:40 -07:00
Kenzie Davisson 10dd59c039 Add a DTD method to get all registered services.
This CL contains breaking changes for package:dtd and prepares both package:dart_service_protocol_shared and package:dtd for publish.

This CL also fixes https://github.com/dart-lang/sdk/issues/60757 so that DTD-registered services are sent over the `Service` stream upon initial subscription like what is done for client-registered services.

Change-Id: I619af816e64af01864c7ed9b98743c6691bf7e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429161
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2025-05-22 13:52:54 -07:00
Sam Rawlins fb03a18f63 DAS: switch ConfigurationFilesMixin to use package getters
Change-Id: I4931f2b7598ea96313fb00963e5e154101d51c24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429829
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-21 08:41:38 -07:00
Sam Rawlins 4ef189a513 linter: Rename State to RuleState, and sub-classes
Change-Id: Id74c1a34e0a3154e1720d323bf4002aceb092dd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 15:52:54 -07:00
Danny Tuppeny d6cc4c3901 [analysis_server] Don't return the Fix All code action for legacy server
Currently the commands for Fix All are only supported for a real LSP server, so we shouldn't return a Source CodeAction that would try to run the command when running in the legacy server.

Change-Id: I3256ef5e19c3a45e7fc3f3ec726a59da30d3a30c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429642
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 09:30:09 -07:00
Sam Rawlins 823908a435 Simplify ConfigurationFilesMixin
Work towards https://github.com/dart-lang/sdk/issues/55660

This mixin has some members that can be made private, and some that
can be removed.

Removing a `macro` parameter also simplifies things.

Change-Id: Id3b5d33ff66dde0c763499ff183943d72901d395
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429440
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-19 12:44:59 -07:00
Danny Tuppeny ee0a316495 [analysis_server] Suppress snippet support for Command CodeActions
We support a non-standard mechanism (https://github.com/rust-lang/rust-analyzer/blob/b35559a2460e7f0b2b79a7029db0c5d4e0acdb44/docs/dev/lsp-extensions.md#snippet-textedit) for having snippets on edits for Code Actions. This is only specified for edits returned from `codeAction` requests (and only implemented in Dart-Code for the same), so we should not return snippets when applying edits via `workspace/applyEdit` (eg. when code actions are returned as commands).

This prevents snippet markup being inserted literally into the editor if codeActions are executed over DTD (eg. from property editor).

Change-Id: I7882bffb8038671459e7487dc2e944020395f128
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-19 09:32:06 -07:00
Sam Rawlins 22453ba77f linter: deprecate AnalysisRule.lintCode
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: Iedf1127b9f04aec910647c7f35597f38c6bfe1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428846
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-15 16:20:11 -07:00
Danny Tuppeny fadf8a0959 [analysis_server] Support LSP executeCommand over DTD to support code actions
There are a few things in this CL that were difficult to separate testing of (because they're all part of the same feature):

1. sets `requiresTrustedCaller=false` on the `executeCommand` handler so that commands can be called over DTD. It adds the same flag to the command handlers themselves, so a command can control whether it can be called over DTD or not (right now we allow everything except `logAction` and `sendWorkspaceEdit` which are both commands used internally and not appropriate for DTD clients to call).

2. Removes the allow-list on DTD methods, allowing all LSP shared methods to be available over DTD

3. Extends the integration test classes to support reverse-requests so we can verify the edits being sent back to the editor when calling the code actions commands over DTD

4. It also fixes a few bugs where we read the callers capabilities instead of the editors capabilities (which until now would always be the same in those places, but with this change are not).

Change-Id: I6d271ddad6dc1b00a98b10b735763a368c91af7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428784
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-15 11:08:41 -07:00
Danny Tuppeny 49e7d4ac83 [analysis_server] Support "Fix" CodeActions via commands if client doesn't support CodeActionLiterals
This updates fixes to return either CodeActionLiterals or Commands based on the capabilities of the client (similar to was done previously for assists).

Change-Id: I688cb80aef415d329d65092edba247e5ec7a5a13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428783
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-15 10:54:48 -07:00
Danny Tuppeny d5b82a3ecd [analysis_server] Create a wrapper to allow LSP helpers to be used over DTD
A minor refactor towards supporting CodeActions over DTD.

The (existing) `LspRequestHelpersMixin` is a collection of helper methods like `getHover()` that allow sharing strongly-typed access to LSP methods across different kinds of tests (LSP, LSP-over-Legacy, and in-process vs out-of-process).

This adds a class (`DtdHelper`) that allows those same helpers to be used to call LSP over DTD (it has to be a separate instance because these helpers already exist on the base test classes to communicate with the server directly without DTD).

As part of this, the mixin was split up to separate request, reverse-requests and notifications, since only outbound requests apply over DTD and it cannot provide an implementation for the others.

This change also adds `textDocument/hover` to the allow-list so that some of these tests can be unskipped (since in an upcoming change the allow-list will be removed entirely anyway).

Change-Id: Id7bf40020cb5397e4cb8bbdefeed71745f58c4cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-14 12:03:30 -07:00
Danny Tuppeny 496c5ca907 [analysis_server] Minor CodeAction test cleanup
This is some more final (🙃) cleanup before having CodeActions work for LSP-over-Legacy and run all the same tests. Includes:

- Adding some additional signatures to the SharedTestInterface
- Moving some setup code (that uses those methods) into the shared test mixins
- Add a field for `testPackageName` to allow tests to handle differences between the test package name between LSP/Legacy (something that should probably consolidated but is probably not for this CL)
- Move plugin tests back out of the shared code action tests (these require some additional abstraction to work the same across both kinds of tests - TODO added)

Change-Id: Iad25f1ff1e141d3315e9b972a6d0850e71d4a4bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427443
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-13 11:42:48 -07:00
Danny Tuppeny 24f594a582 [analysis_server] Move CodeActions tests to shared mixins
The next CL will make CodeActions a shared handler (so it can run for both LSP and legacy servers). This moves the tests to a shared mixin (without any changes) to keep that change smaller and easier to review if the tests do end up requiring changes.

Not all tests are moved yet - plugins are not (because the plugin code is not the same across server types), not "Fix All" (because it will require some additional changes to not be LSP-specific compared to others).

Change-Id: Ib4727ef1b1cc5b96d98cdbd6e17bf4b7b2791e3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428003
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-12 11:35:53 -07:00
Danny Tuppeny 4db0bdb286 [analysis_server] Update remainder of CodeAction tests to use shared interfaces
Some further changes to CodeAction tests to use shared interfaces so that they will be able to run with both LSP and Legacy test base classes.

Change-Id: I3383e9aef9ea97d39f28dad42633c1fac74e4efa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-12 09:36:31 -07:00
Danny Tuppeny 036b5996fb [analysis_server] Allow the ApplyCodeAction command to be called via LSP-over-Legacy
This updates the `ApplyCodeActionCommandHandler` to be a "shared" command that can work for either kind of server (although it does not yet allow calling over DTD - the executeCommand handler still requires trusted callers).

It also moves all of the tests into a shared mixin so they will be run for both server kinds.

Change-Id: I831cc5a1a9feadc528e5b33b82e3469c60111dfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-08 17:31:12 -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 57cd03d400 [analysis_server] Immediately return null for getEditableArgs of non-Dart files
See https://github.com/flutter/devtools/issues/9048

Change-Id: I5edb446cbda6f9a4222f2aca8dfd72ccbf334287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-03-20 07:40:04 -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
pq 092728e8b5 [CQ] [server] anticipate strict_top_level_inference
Related to https://dart-review.googlesource.com/c/sdk/+/412383

(Note: presubmit required some re-formatting 🤷)


Change-Id: Ib18c7c1c1fceaa0007d804fbcb6397055242fa42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412362
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
2025-02-26 17:55:13 -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 bc7feacec6 [analysis_server] Fix missing trailing comma when inserting arguments before solo child/children
The logic here was bad, assuming we didn't need a trailing comma when inserting an arg before a solo argument (which can happen for child/children).

Fixes https://github.com/flutter/devtools/issues/8921

Change-Id: I38f9003cdc8b499d6417cac7989c65a4760416a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-02-20 15:07:32 -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 ca2119e0a6 [anlaysis_server] Improve the error text/codes for property editor APIs
Change-Id: If3ad0fd11cc661e88104444afd14a5d79374cc1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-28 13:00:18 -08:00
Danny Tuppeny 8eb9bcd7f0 [analysis_server] Verify with/without documentChanges for EditArguments tests
The tests by default run with documentChanges (set in `setUp`), but it's possible LSP-over-Legacy clients won't support it.

Change-Id: I40c65f05127c88e15a43f16669f64675285955dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406002
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-27 12:54:48 -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
Danny Tuppeny 1165528f9f [analysis_server] Improve the formatting of inserted arguments
This improves the formatting of inserted arguments by including newlines and indentation if an invocation spans multiple lines.

Change-Id: Idef4602ee9ac9f145879a4628190ec44f87a0018
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405122
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
2025-01-22 15:15:31 -08:00
Danny Tuppeny 199d50aab1 [analysis_server] Check for applyEdit support before handling EditArguments
If we get an editArgument request (usually via DDS), we should verify the connected editor supports edits and return an explicit message if not.

Also adds a `setUp()` declaration to `SharedTestInterface` so shared tests can set client capabilities instead of them being duplicated in each test class (and moves the same for ApplyEdit tests to this).

Change-Id: Ie6a85620b3b53663ce92e55d93e3aefcaf4dc980
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405342
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-22 15:15:19 -08:00
Danny Tuppeny dd9a061f4e [analysis_server] Enable "EditArgument" request to work over the legacy protocol
+ move all related tests to a shared mixin so they run for both servers.

Change-Id: I853e8f24948c07fdde2a5d6a64ddc65962357b6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404841
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-01-18 10:59:08 -08:00
Danny Tuppeny b908274b8c [analysis_server] Minor refactors to enable running EditArgument through legacy server
This is some minor refactoring to support the next CL that will enable the EditArgument request (the one that actually edits arguments, not the one that gets the list of arguments) over legacy.

It moves some code for sending LSP reverse-requests through the legacy server from test code into the actual server (and fixes that they weren't correctly wrapped in the 'lsp.handle' protocol classes) and updates the tests to use the shared interface ready.

Change-Id: I06492138645538072fb12f2fc2d424e214f8055b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404824
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-18 10:06:46 -08:00
Danny Tuppeny 95f0052267 [analysis_server] Add tests for unversioned documents for EditableArguments
The legacy protocol does not currently version documents, so this adds some additional tests for that.

The tests are in the Legacy class and not the shared class because in LSP versions are not optional for opening/changing documents (they are optional in some of the other APIs, but not for open/change).

Change-Id: I7e75b813025b3f67ed143e1b3a8b717224bfa80f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404820
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-01-17 11:50:22 -08:00
Danny Tuppeny 93621ccfc1 [analysis_server] Move all EditableArgument tests to a shared mixin and run for legacy
This moves all tests (without any changes) to a shared mixin, and then applies that mixin to the original test class. It also adds a new test class for LSP-over-Legacy, meaning the tests will now run for both protocols.

There are two failing tests when using LSP-over-Legacy so they are overridden with `@FailingTest()` temporarily.

Change-Id: I8c7efcf8f5d85d874b3483f4f3953d4d8b68a31a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404621
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-01-15 12:30:26 -08:00
Danny Tuppeny 549a78500a [analysis_server] Add a shared test interface to simplify sharing tests between LSP, LSP-over-Legacy
This is refactor extracted from an upcoming change (to make property editor tests run against both servers) to make that change smaller and easier to review.

There are some existing shared tests that run for both LSP and Legacy servers, but they currently do not touch much server API (one is for DTD and one tests reverse-requests). Migrating other tests (such as EditableArguments) requires some additional API be the same between the different test/server base classes.

This change adds an `abstract interface class SharedTestInterface` to serve as a common interface for methods that shared tests need to use that have different implementations between LSP and Legacy. For example, updating the overlays in an LSP-over-Legacy test needs to use the Legacy APIs for updating the overlay and not the LSP ones (so we can't just use the LSP methods like we would for calling something like getHover for LSP-over-Legacy).

It also:

- adds some new futures to the LSP test base to match the behaviour of the legacy one (wait for in-progress analysis)
- replaces the shared mixins with real base classes that implement the shared interface (for ex. `abstract class SharedLspOverLegacyTest extends LspOverLegacyTest implements SharedTestInterface`) to make it easier to create shared tests
- renames `sendLspRequest` to `sendLspRequestToClient` to make it clearer what direction this method is for

Change-Id: I070c2c005b11b9afd8a87aa22b04972a9dde2320
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404680
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-01-15 12:28:45 -08:00
Danny Tuppeny fb3255dd9e [analysis_server] Add support/tests for reverse-requests for LSP-over-Legacy
This adds shared tests for sending workspace/applyEdit reverse-requests that run for both the LSP and Legacy servers.

It involved moving some code out of the base LSP test onto mixins to be used by LSP-over-Legacy tests and I extracted some mixins that can be used in tests to provide a common interface to both servers for writing shared tests.

Change-Id: I8c6d09f220b2593680547311a4fce66013f86e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404420
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-15 07:33:38 -08:00