Commit Graph

7509 Commits

Author SHA1 Message Date
Helin Shiah 405b6c5614 Send IDE and plugin info to analytics
Bug: https://github.com/dart-lang/sdk/issues/62996
Change-Id: Id2bd122acf4a40a01a7dc760e44f164b04f204ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497123
Commit-Queue: Helin Shiah <helinx@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-05-12 12:39:44 -07:00
Danny Tuppeny 26c646642d [analysis_server] Add kinds to LSP document highlights
Populates the `kind` on the Document Highlights we return. This allows colouring reads and writes differently (which it turns out VS Code does by default).

The options are a bit limited (Read/Write/Text) and using Read/Write for things like type names feels slightly odd, but the spec does seem to encourage this and it's what TypeScript is doing.

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

Change-Id: I6a53450038cde31b399b5b1aca5f964083106763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503060
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-05-12 12:04:29 -07:00
Brian Wilkerson 2b1ed6614e Add a fix for use_declaring_parameters
This is another step toward being able to maximally convert a body of
code to using the primary_constructors features.

This CL does two things:

- Changes `convert_to_declaring_parameter` to also be a fix and applies
  that fix to the `use_declaring_parameters` lint.

- Updated the `use_declaring_parameters` lint to also flag field formal
  parameters.

Change-Id: I8b584186658abc73c025b166c145efbab95acd8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502740
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-12 11:56:25 -07:00
Kallen Tu 509caefa07 [migrate] Update error message when failing to parse pubspec.
Danny mentioned that the error message is missing the file name because
we're using the directory path. Updated the message and added a small
test.
https://dart-review.googlesource.com/c/sdk/+/496801/comment/d1e2d8cf_83c52831/

Bug: https://github.com/dart-lang/sdk/issues/63247
Change-Id: I6bc7cbd18a70328cd0c549672459944c220b177a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-05-12 11:49:26 -07:00
Paul Berry 836ae16c9b [analysis_server] Expand on doc comment for BulkFixProcessorTest.
Recording Brian's answer to my code review question
(https://dart-review.googlesource.com/c/sdk/+/502740/comment/72581051_c4bd020e/)
for posterity.

Change-Id: I25a06504c80b0189ba11b35a7bc713aa6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-12 11:39:23 -07:00
Konstantin Shcheglov eae9edeb2e Augment. Fix pre-existing cases when already complete declaration is augmented with a complete declaration.
Change-Id: Ie2ff45ec5801dee2bfbc115719ba1a6f85f8cbe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502187
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 07:42:33 -07:00
Brian Wilkerson d60a248196 Add a fix for empty_container_bodies
The fix replaces the empty braces with a semicolon.

Change-Id: Iadf423c1a3c08be2e67556ed9a33203238eb19a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502802
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-12 00:24:48 -07:00
Danny Tuppeny 3d339f3955 [analysis_server] Update normalizer benchmark test
We now have `:filePath` suffixes on the replacements when the input contained a file path (as opposed to a file URI).

Change-Id: I8b4a37aed669293169b8e8d148dab7f806506996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-05-12 00:08:41 -07:00
Brian Wilkerson 157baccaa5 Add a fix for use_primary_constructors
The use_primary_constructors lint is a temporary lint being used (along
with others) for testing the primary constructors feature. I don't
expect that it will ship to users in its current form, so these fixes
might be removed.

With that in mind, I updated the existing assist that can convert a
secondary constructor to a primary constructor so that it can be used
as a fix. (The assist will remain, even if the lint is removed.) I then
added a second fix to add a primary constructor when there are no
explicit constructors. I did this for two reasons:

1. I expect the fix to be removed before the feature is shipped because
   it seems unlikely that users would want to have an explicit primary
   constructor rather than the implicit default constructor.

2. Making it a separate lint allows it to have a better label on the
   context menu in case users actually see it during the beta period
   (or in the stable version if I'm wrong about #1.

The effect is that the lint can now be bulk fixed in order to maximally
convert a body of code.

Change-Id: I7c6dddd8735e67bbd1d398e4035ca578725d044f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502180
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-08 12:51:13 -07:00
Sam Rawlins 9bcf11f97e DAS: Do not lose comments in sort_child_property_last
Work towards https://github.com/dart-lang/sdk/issues/55662

There are several issues reported there. This CL fixes an issue of
comments being deleted, if they follow the comma of the `child` argument
and the `child` argument is the first argument.

Change-Id: Ic7cc0c653e9303ba7dbd2bf31dbdc50268f6a1c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-05-08 08:08:00 -07:00
Keerti Parthasarathy 18c1a3f7fb [data-driven]Add a transform to replace a library import.
Closes https://github.com/dart-lang/sdk/issues/62849

Change-Id: Iffdf3aeb2c764a1c0227e82ca2517b5a56be206a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501660
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-07 12:23:47 -07:00
Danny Tuppeny 2f7951190b [analysis_server] Prevent session log being overwritten on every message
This changes the SessionLogFileSink from using `writeAsStringSync` and overwriting the whole file on each message. It does this by using `openWrite()` and keeping the `IOSink` instead.

This means:

- it uses `dart:io` (we don't have `openWrite`/sink support in the abstraction)
- we need to call `close()` to flush the file during shutdown (there was already a shutdown method on the session logger, but it wasn't used or called, so now it is)

This does mean the tests for this class write to the physical disk, but there are only two of them - most other tests use the in-memory sink (or are just testing the normalizer).

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

Change-Id: I7ef347fc46d8ce3daf30ed2f9965e8921c5c4856
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-05-07 11:53:58 -07:00
Danny Tuppeny 11b1da577f [analysis_server] Handle URIs/filePaths separately in log normalization/replay
For posix paths, replacing the file path during normalization and then swapping it back later works for both paths and URIs, because a file URI just contains the file path verbatim:

file:///foo/bar/baz

However that's not the case for Windows:

C:\foo\bar\baz
file:///c:/foo/bar/baz

So when normalizing, we need to know if we normalized a URI or a file path, so that we can reverse it later.

With this change, we'll use `{{workspaceFolder-0}}` for the URI, and `{{workspaceFolder-0:filePath}}` for the file path. Then when reversing, we can easily put the correct one back.

This also updates the log replace/scenarios to use the LogNormalizer to perform the denormalization so they don't have to have duplicated logic about what to restore.

I've also updated the existing committed scenarios (EDIT: moved this to a separate CL because Gerrit is falling over) - although even with those changes, they all fail for different reasons (invalid git hashes, mismatches in expected vs actual requests) so I think there is still more work to do here.

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

Change-Id: Ib4c4aabe2c7c0d089bd620bdf00de37acde25f52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501600
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-07 10:03:24 -07:00
FMorschel d29da25302 [DAS] Fixes occurrences for declaring parameters
Fixes: https://github.com/dart-lang/sdk/issues/63124
Change-Id: Ie94f23da1c47d393124491c37a6098ac66c581b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497103
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: FMorschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-07 08:03:26 -07:00
Sam Rawlins c0cbb31d01 DAS: Add tests on add_type_annotation for dynamic
Closes https://github.com/dart-lang/sdk/issues/56730

This bug is fixed already; this change introduces unit tests.

Change-Id: I85fdbe2cb1ab46667e6c265576abb774a5dafda6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-06 16:18:01 -07:00
Danny Tuppeny eed5d692ab [analysis_server] Only replace full paths or start of paths followed by separators during normalization
It's possible that there are nested paths in LSP workspace folders, such as:

/foo
/fooBar
/bar/foo

We shouldn't just replace each path we were given, as it might replace the wrong parts of other parts. Instead, require the path to be surrounded by quotes, or prefixed by a quote and followed by the appropriate path separator.


I also tweaked the benchmark test a little to report the time for the first call separately from the others, since that one triggers the regex build.

On my machine, timings currently are:

```
Replacing 250 paths in payload of 2097152 bytes
Iteration #1, First: 43ms, Rest: 30ms
Iteration #2, First: 38ms, Rest: 30ms
Iteration #3, First: 33ms, Rest: 30ms
Iteration #4, First: 37ms, Rest: 30ms
Iteration #5, First: 31ms, Rest: 29ms
```

Change-Id: I75de1fb36a16636e0f50099cced1d5386318d589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-05-06 10:40:57 -07:00
Danny Tuppeny 8b29e93bea [analysis_server] Include count of additional errors in "Rename anyway?" prompt
Follow up from https://dart-review.googlesource.com/c/sdk/+/499600

+ fix typo
+ fix bug that inline_method treated required named arguments as optional instead of required

Change-Id: I1c088138d990a27ed74ff51993bbe4032b245693
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-05-06 07:30:09 -07:00
Paul Berry 27ed75b7bc [analysis server] Fix extra space when switching to new constructor syntax.
Adds logic to the `RemoveTypeName` correction producer to ensure that
after the correction is applied, the spacing matches what `dart
format` would do. For example, `C()` is changed to `new()` rather than
`new ()`, and `factory C()` is changed to `factory()` rather than
`factory ()`.

This will make it easier for me to visually inspect intermediate
results when transitioning the SDK and google3 to language version
3.13. It also should provide a (marginally) nicer user experience.

Change-Id: I30babde38e58438ea39279ed0d5859ce6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-05 14:50:40 -07:00
Konstantin Shcheglov 921ec7f507 CQ. Simplify Scanner constructors.
Replace the positional Scanner constructors with a single constructor
that takes the input text and error reporting callback as named required
arguments.

Remove the unused fasta forwarding constructor, reader offset handling,
and stored first token. The scanner now keeps only the input text and
returns the token stream directly from tokenize.

Update analyzer, analysis server, plugin, CLI, scrape, and scanner test
call sites to use the named constructor arguments.

Change-Id: Ieabb7b28570d4a963563fb2d1c5ef5ac0c89032a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-05 14:04:00 -07:00
Danny Tuppeny ac8b7adbaf [analysis_server] Add refactors for Add/Remove import prefixes
Fixes https://github.com/Dart-Code/Dart-Code/issues/4289

Change-Id: I875cbab9f36111cbbdd2b9723c1da80a0de72034
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-05 12:53:41 -07:00
Brian Wilkerson e1cacdc23a Add a fix when an extension or mixin has a primary constructor
Neither is allowed to have a primary constructor, This adds a fix to
remove the primary constructor.

Closes https://github.com/dart-lang/sdk/issues/63073

Change-Id: I363d2fa02d18e2a63a2bfc8c64a57256f861195d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500584
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-05 09:18:55 -07:00
Kallen Tu 8bfb683892 Enable 'primary-constructors' feature flag.
This CL enables the primary constructors feature by default in Dart 3.13.

The primary constructors feature is a brevity feature. There are no new semantics, but it allows us to express declarations in a less verbose way.

This feature allows one constructor and a set of instance variables to be specified in the header of a declaration.

Currently a declaration with a constructor and some fields is written as:

```dart
// Current syntax.
class Point {
  int x;
  int y;
  Point(this.x, this.y);
}
```

With a primary constructor, we would write the above as:

```
class Point(var int x, var int y);
```

If a primary constructor needs an initializer list or a body, they can be
specified inside the class using the `this` body syntax:

```dart
class Point(var int x, var int y) {
  this : assert(x >= 0) {
    print('Point created at $x, $y');
  }
}
```

As part of this feature, you can also use the `new` and `factory` keywords to
declare constructors in the class body without repeating the class name:
```dart
class Point {
  int x, y;

  // Equivalent to Point(this.x, this.y)
  new(this.x, this.y);

  // Equivalent to Point.origin()
  new origin() : x = 0, y = 0;

  // Equivalent to factory Point.clone(Point other)
  factory clone(Point other) => Point(other.x, other.y);
}
```

To learn more about the feature, check out the feature specification located here: https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md

Tested: Has existing language, CFE, analyzer, analysis server tests.
Bug: https://github.com/dart-lang/sdk/issues/61524
Change-Id: I296f2fcd918b87bf2a1dd00256340759866c2423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489241
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-04 15:09:49 -07:00
Kallen Tu 049dcc2c4c [migrate] Fix failures due to Windows file paths.
The tests were matching on file paths that don't match Windows file paths. I changed the tests to only check the descriptive message it expects.

Change-Id: I77de312cdf2a3a45384cde355e0b3f27fecdd3ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-05-01 14:05:07 -07:00
Kallen Tu 81a14586a9 [migrate][analysis_server] LSP Protocol for migrate tool.
This some basic scaffolding for the migrate tool. We'll add a protocol to the analysis server with the following parameters and result:

Parameters
- `uris`: Workspaces/packages to be migrated

Result
- `summary`: Information about fixes that could not be applied automatically. (e.g. if there was a conflict) or information about what fixes were applied and what SDK version the pubspec has been changed to.
- `edit`: A list of edits to be applied.

There are no interesting tests yet, but I hope to have a suite of tests for the next change.

Fixes: https://github.com/dart-lang/sdk/issues/63247
Change-Id: I77508720acb17af5ec86675fd3f3045e2a610bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496801
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-05-01 12:13:41 -07:00
Konstantin Shcheglov 245f876407 CQ. Abstract Scanner away from DiagnosticReporter, so that we don't need Source to scan.
Change-Id: I377a49a7997f416acdfde3a05616715abaa84ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2026-05-01 09:17:00 -07:00
Konstantin Shcheglov aa1ebb4eae CQ. Stop using mock Source in LinterRuleOptionsValidatorTest.
Change-Id: I89bd2665963b44dae971bab593df956766ca9919
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499781
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-04-30 22:31:29 -07:00
Ben Konyi 521b102563 [DAS] Fix widget preview detection crash when running in legacy mode
In WorkspaceFlutterWidgetPreviewsHandler.handle() and FlutterWidgetPreviewsHandler.handle(), an explicit cast of the server instance to LspAnalysisServer was used. When the analysis server is running in legacy mode, the server is a LegacyAnalysisServer, which caused a TypeError. This change removes the unnecessary cast and uses the base server instead.

Fixes https://github.com/flutter/flutter/issues/185657

Change-Id: If331de5ff2b7e987c07e49dd3a9cd8a03fc75853
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499720
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
2026-04-30 17:03:56 -07:00
Konstantin Shcheglov ceb815b30f CQ. Stop using Source mock in DAS.
Change-Id: I561ab239d336b7733a1d68e36f4baf0c68197af1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-30 13:58:29 -07:00
Danny Tuppeny f540b06ac3 [analysis_server] Add support for "Refactor Anyway"
This changes the "refactor.perform" command to prompt the user with an option to "Refactor anyway" if the refactor has non-fatal errors or warnings (matching existing Rename functionality).

This change is currently only for the non-self-describing refactors (inline/extract method/variable etc.). The self-describing refactors currently don't report errors in a way that can be ignored/continued and will need some additional changes, and may be better doing later if there will be protocol changes (I've filed https://github.com/dart-lang/sdk/issues/63294).

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

Change-Id: I0674f7b67c86fe1cf9f6bd57b2d6cee08b4066b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-30 11:32:52 -07:00
Konstantin Shcheglov 3e73e2fed4 CQ. Fixes to make analyzer/ and analysis_server/ pass with TEST_ANALYZER_WINDOWS_PATHS=true on Mac.
Avoid constructing file URIs and paths directly from the host platform
when analyzer code is operating on an injected ResourceProvider. Those
direct conversions use the process path context, which is wrong when the
provider is using a Windows path context on another host platform.

Route file URI conversions through ResourceProvider, FileSource, File,
and PathContext APIs instead. This keeps file names, document links,
analysis options includes, navigation targets, and relative paths
aligned with the active provider.

Update affected tests and shared test utilities to use provider-backed
URIs and paths, so they exercise the same path semantics as production
code.

Change-Id: Iaf7751d028273a5fa72a04d8ca60e51aee700594
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499481
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-30 08:20:28 -07:00
Brian Wilkerson 7d3b23b84e Update extract_method to use the ChangeBuilder
This impacted the placement of the imports, but I think the new results
are better. If nothing else, it's more consistent.

I thought it might be easier to review as two separate changes.

- The first patchset includes the basic transformation.

- The second patchset removes the old code to add the imports.

Change-Id: Ia0a3745152a14ce32fb757e797d0848b9f8d47cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499320
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-30 07:37:12 -07:00
Danny Tuppeny c5fb640747 [analysis_server] Handle request cancellation when a request is waiting for an outbound user prompt
This updates the `showUserPrompt` method to accept a cancellation token so that if requests are cancelled (by the client, or something like a second refactor cancelling the first), the prompt is also cancelled (and when the response arrives, it can be ignored).

Note: Unfortunately the protocol (and VS Code) don't actually allow for the prompt to be cancelled/hidden from the user, this is mainly to avoid us keeping the request "alive" on the server if the user ignores a prompt and we know the parent request was cancelled anyway.

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

Change-Id: Ia77880a749b284a2ff31c8cf560307ad908d2175
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499360
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-29 13:57:38 -07:00
Konstantin Shcheglov e20704c3b0 CQ. Move PackageConfigFileBuilder to analyzer_testing.
Move PackageConfigFileBuilder into the analyzer_testing public API and
deprecate the copy exposed from package:analyzer. The builder is only
used by test infrastructure, so keeping it in analyzer_testing makes the
ownership clearer and avoids exposing test-only utilities from analyzer.

Update the builder API to accept a rootFolder instead of a rootPath.
This lets callers pass the resource-provider folder directly, so the
generated rootUri is derived from the same file-system abstraction that
created the test files. This avoids accidentally passing POSIX paths
where resource provider paths are required, such as on Windows.

Update existing test utilities and callers to import the new library and
pass Folder objects. Remove the production analysis server dependency on
the builder by emitting the temporary plugin package config JSON
directly.

Change-Id: I46b14710626e0d6d5884afcdc5a05b23077acfc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499081
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-29 13:18:35 -07:00
Brian Wilkerson 18c3034f20 Convert two more refactors to use ChangeBuilder
This continues the effort to move all of the legacy refactors over to
using the ChangeBuilder rather than creating legacy edit objects
directly. This should make it easier to atomically convert all of the
refactors to produce a protocol-agnostic representation as part of the
move to remove the legacy protocol.

Change-Id: I659c14966b543f21ecc94248a2c0dda5692473fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499045
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-29 13:15:21 -07:00
Sam Rawlins 2e413148cb DAS: Add some completion support for plugins in analysis options yaml
Fixes https://github.com/dart-lang/sdk/issues/61936

Change-Id: I557f7820eb5a3e6274208b28354071d4e7e67ac2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-04-28 14:59:08 -07:00
Sam Rawlins a66b93ac4e DAS: Support links to plugins in analysis options
Fixes https://github.com/dart-lang/sdk/issues/62387

Change-Id: Iab9351552bf44936ca1582656e3edc7dbd276c1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498761
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-27 16:14:40 -07:00
Konstantin Shcheglov ba666c8082 CQ. Refactor references by role.
Replace the generic mutable reference tree with typed reference classes
for roots, libraries, top-level declarations, member containers,
members, and built-in elements.

The previous API was shallow. It offered a small primitive,
`getChild(String)`, but pushed too much knowledge to every caller: which
sentinel names exist, which paths are valid for each declaration kind,
which references may contain members, and which references are not real
declarations at all. That kept the reference implementation simple by
spreading its complexity across the analyzer.

Make the reference model deeper instead. Callers now ask for the
semantic role they need, such as a library, constructor, method, field,
or top-level declaration. The reference layer owns the representation,
lookup, creation, and serialization details. This concentrates the
complexity behind a narrower interface, makes the common cases clearer,
and makes invalid reference shapes harder to construct.

This is a strategic cleanup rather than a local simplification. The
reference graph is used by element construction, summary reading and
writing, scopes, exports, and fine-grained dependency manifests. Giving
it explicit concepts reduces the amount of convention each subsystem
must remember and preserves a simpler mental model at the call sites.

Update summary serialization to write semantic reference rows with a
tag, enclosing reference, kind, key, and URI payload. Bump the analyzer
data version because this changes the linked summary format.

Represent exported declarations as export entries that carry the
exported name, reference, and export locations. Use those entries when
building scopes, filtering deprecated exports, and updating fine-grained
library manifests.

Keep import prefixes out of the declaration reference tree. Bind prefix
fragments through fragment-local ids so prefixes can be restored and
merged without fabricating declaration references.

Bug: https://github.com/dart-lang/sdk/issues/63227
Change-Id: If28f8b779faa78bdf023bc69b714555fae57ccb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497621
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-27 10:07:25 -07:00
Sam Rawlins 95613f5d07 linter: Report unnecessary_async for dynamic- and Object-returning functions
Fixes https://github.com/dart-lang/sdk/issues/60416

There was discussion about expanding the purview of this lint rule, and
`Object`- or `dynamic`-returning functions do not need their return
type changed, so the fix does not change that behavior.

Change-Id: I835732d6ab25dd85142f8763624eda2d9293e003
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497840
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-04-24 11:50:21 -07:00
Sam Rawlins 33648b761d DAS: Remove more unnecessary "async" keywords
Work towards https://github.com/dart-lang/sdk/issues/60416

Change-Id: I90d93b371698bd7703f6049dcdfeb994d6228729
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497841
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-04-24 10:45:17 -07:00
Brian Wilkerson 463b751717 Add new unnecessary_type_name_in_constructor lint
This adds a new lint to recommend removing the type name from secondary
constructors.

It also adds a new fix that can automate the removal.

Change-Id: Ib6bc46b4455c360732553eadea3451d7dfb874a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497120
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-04-21 15:12:35 -07:00
Keerti Parthasarathy a53d974caa [primary constructor]Add tests for property editor
Change-Id: I4b7592cf7a11943fa74352ab95bdce5099cf8692
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496663
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-04-21 14:20:06 -07:00
Brian Wilkerson 78412eaeb8 Add new unnecessary_const_in_enum_constructor lint
This adds a new lint that was requested in order to support the primary
constructors feature.

This also enables the existing fix to remove the keyword and adds some
tests for the new use of the fix.

Change-Id: Iae3c86ca87a2af6abb82488e218d839a06699778
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496741
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-21 09:27:51 -07:00
Konstantin Shcheglov 6cd3938741 Breaking changes for analyzer 13.0.0
https://github.com/dart-lang/sdk/issues/62799
https://github.com/dart-lang/sdk/issues/62944
https://github.com/dart-lang/sdk/issues/63002
https://github.com/dart-lang/sdk/issues/62970

Looks mostly green in google3: https://fusion2.corp.google.com/presubmit/901021300/OCL:901021300:BASE:901308428:1776439417713:37cd1695

Change-Id: I44754a48f66a0b58851d7c20fcfa61f7fb1b555a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488624
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-17 23:06:25 -07:00
Brian Wilkerson b5da407918 Add tests of the property editor protocols using primary constructors
Change-Id: I6ec57b240da39ba925665dba5d1ec17fe4bef691
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496380
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-17 17:24:20 -07:00
FMorschel bda52677b5 [DAS] Adds assist to "Add type name" on dot-shorthands
Fixes: https://github.com/dart-lang/sdk/issues/61984
Change-Id: I2e2599a4ef67fa0d25f28d3e7ff60f1519f00815
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472260
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-17 15:21:29 -07:00
Keerti Parthasarathy a043789a6b [primary constructors] Add tests for data driven fixes
Change-Id: I31d8e782400ddac5b65c484dd5eb4fef9d86d88e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-04-17 09:02:20 -07:00
Brian Wilkerson d75661c6d8 Update convertToSuperParameters to support primary constructors
This CL is a bit different from many previous CLs in a couple of ways.

The smallest difference is that I realized that some of the logic could
be shared and that we have a utility method that just need to be
enhanced a bit to support primary constructors. At some point we should
go back to the previous implementations and update them to use the
utility method.

The larger difference is the use of a pair of wrapper classes to
encapsulate some of the differences between primary and secondary
constructors. I'm not sure how I feel about the two approaches. On the
one hand, the wrapper classes feel a bit heavy-handed, but on the other
hand they could make a lot of code more DRY.

Your thoughts would be appreciated.

Closes https://github.com/dart-lang/sdk/issues/63047

Change-Id: I93af6d2a529bbc0491cf64ff03f7a58e6b874d81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495461
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-04-16 09:33:18 -07:00
Konstantin Shcheglov e7c6654312 Augment. Allow abstract top-level variables.
Permit `abstract` on top-level variable declarations when the
augmentations feature is enabled. Previously the parser always reported
`abstract` as extraneous at the top level, which rejected valid syntax
and dropped the modifier before later stages could see it.

Thread the abstract token through top-level field parsing, record it on
`TopLevelVariableDeclaration`, and pass it through the front-end
builders. Reorder the field callback arguments so `augment` precedes
`abstract`, matching the augmentation grammar for incomplete top-level
variables and keeping the parser, listener, and outline plumbing
consistent.

Change-Id: I680414a746b707d483e485702685c95f28a9c9ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494564
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-14 16:12:24 -07:00
Danny Tuppeny 4f99b5b870 [analyzer_plugin] Default parameter name for setters to value
Change-Id: Id20717cba30f85486bd3ed41278efea222fd8b4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495400
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-04-14 10:58:43 -07:00
Brian Wilkerson fd8527f4dc Update convertToInitializingFormal to handle promary constructors
Closes https://github.com/dart-lang/sdk/issues/63045

Change-Id: I642115ef872b72756dd584f3c820f3ae6a5cbe4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495080
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-14 10:28:21 -07:00