Commit Graph

8214 Commits

Author SHA1 Message Date
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 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
Keerti Parthasarathy 3520930c67 Add fine grained timings for assists and refactor computations.
These are displayed in the Timings Insights page and sorted by elapsed time.

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

Change-Id: Ifc64680ef7b00eecf5e0a5c88e988ba28c6fe6e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499740
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-01 10:16:55 -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 800e6d4d5c CQ. Deprecate FormalParameterElement.isInitializingFormal and isSuperFormal.
Deprecate FormalParameterElement.isInitializingFormal and
FormalParameterElement.isSuperFormal in favor of checking whether the
element implements FieldFormalParameterElement or
SuperFormalParameterElement.

Update analyzer and linter callers to use the subtype checks directly.
This makes the declaration form explicit in the element model and avoids
duplicating information that is already encoded by the parameter element
subtype.

Record the formal parameter declaration form in fine-grained manifests
as a single enum value instead of two independent booleans. This
preserves the distinction between regular, field formal, and super
formal parameters while making the manifest representation impossible to
encode as conflicting forms.

Update summary serialization, manifest printing, API text, and changelog
entries for the deprecated API.

Change-Id: Icb620afb90f31dc6d8510e1a9f49f0d9a6785754
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499681
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-01 09:05:53 -07:00
Johnni Winther 01a26f9022 [parser][cfe][analyze][PrimaryConstructors] Error recovery for primary constructors on mixins and extensions
This adds error recovery for mixin and extension declarations with primary constructors. This avoids cascading errors when primary constructors are used with these declarations which do not support primary constructors.

Closes #63157

Change-Id: I17bfab4a7eabac1c75e7cfb580295dcf619c991d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-01 01:50:43 -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 c6f76847ae CQ. Use Set<LibraryElement> librariesToImport instead of Set<Source>.
Change-Id: Ic8c2f67b1aeaf078b8eec48962617ee32ba8919b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499424
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-30 14:38:13 -07:00
Konstantin Shcheglov ecaad047c9 CQ. Update AstNodeImpl.parent to return AstNodeImpl?.
Change-Id: I480e2cce95eebf6198341d7f5f9daa7af18f1129
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499660
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-30 12:57:11 -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
Brian Wilkerson fb8e1044ed Convert inline_local to use the ChangeBuilder
Change-Id: Ic0762972f7018d84edd5ab131a2eabf94fccd899
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499421
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-04-30 06:59:26 -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 7859c59810 Augment. Build parameter elements after linking fragments.
Delay creation of formal parameter elements until after executable
fragment chains have been linked. This lets the element class be chosen
from the complete parameter fragment chain, rather than from whichever
fragment is first reached.

A regular parameter fragment can later be linked with a field-formal or
super-formal fragment from an augmentation. Build the element after that
linking step so the chain receives a field-formal or super-formal
element when any fragment in the chain requires it.

Apply the same model to parameters nested in function-typed parameters
and generic function types. Store and read their resolution separately
from the AST shape so deserialization can bind fragments first and then
restore parameter types.

Update callers that previously assumed a field-formal or super-formal
fragment always had a correspondingly typed element. During recovery,
extra unmatched parameters may still have plain formal parameter
elements, so these paths now check the element type before using
field-formal or super-formal specific state.

Bump the analyzer summary data version because the serialized parameter
resolution layout changed.

Change-Id: I9dfc79e3b1ccfcbaeea6bbe5cec00d7bf20f5bb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498800
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-04-29 13:48:26 -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 5a6b815789 analyzer: Report a warning when a Future.then onError handler returns the wrong type.
Fixes https://github.com/dart-lang/sdk/issues/54927

Generally this warning reports these cases:

The function expression has an unassignable return type:

```
void f(Future<int> future) {
  future.then((_) => 0, onError: (e, st) => 'c');
}
```

The function has an unassignable return type

```
void f(Future<int> future, String Function(dynamic, StackTrace) cb) {
  future.then<int>((_) => 1, onError: cb);
}
```

The block function body has an unassignable return type or is missing a return type:

```
void f(Future<int> future) {
  future.then((_) => 0, onError: (e, st) {
    if (1 == 2) {
      return;
    } else {
      return 0.5;
    }
  });
}
```

Change-Id: I5d67ae35109a874543af01936f13256ff457b35b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498240
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-04-29 05:00:59 -07:00
Konstantin Shcheglov 560f44af01 CQ. Switch clients to default constructor of FunctionTypeImpl.
Also rename the public `FunctionTypeImpl` constructor formal parameter
from `parameters` to `formalParameters`, matching the API exposed by
`FunctionType`.

Change-Id: I6f9bbeed06cee708f78bb7127843222db08e1d52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499040
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-04-28 17:13:48 -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
Kallen Tu 77cf3047a3 Dot Shorthands: Const selector chains.
I changed the parsing of const dot shorthands to parse the entire selector chain in `parsePrecedenceExpression` rather than parsing them in `parseConstExpression`. We were originally parsing the initial expression before the `.` and only flagging that as a dot shorthand which prevented any chaining on const constructors. Const expressions with chained methods/property accesses were not being flagged as a dot shorthand so we weren’t saving the context type properly which led to producing the “unknown context type” error.

Before:
```
class C {
  const new someConstCtor();
  C method() => this;
}

C c = const .someConstCtor.method();
// (const .someConstCtor) is parsed and handled as a const constructor
// (const .someConstCtor) is handled as a dot shorthand, context is
// saved on only this AST and not the outer chain.
// Then we parse the rest of the selector chain (.method())
//
// Error: No context type for (const .someConstCtor.method())
```

After:
```
class C {
  const new someConstCtor();
  C method() => this;
}

C c = const .someConstCtor.method();
// (const .someConstCtor) is parsed and handled as a const constructor.
// Then we parse the rest of the selector chain (.method())
// (const .someConstCtor.method()) is handled as a dot shorthand, context is saved for this outer node.
//
// OK. No error because we are able to retrieve the type for the
// entire dot shorthand chain.
```

Fixes: https://github.com/dart-lang/sdk/issues/63119
Change-Id: I3308d8eb7ce101466be257aba6b5448921bff136
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-04-24 10:40:26 -07:00
Sam Rawlins 0706afa1ef Introduce an 'analysis options page' in the insights pages.
Work towards https://github.com/dart-lang/sdk/issues/61496

This adds some "debug information" types and a method on
AnalysisOptionsImpl, so that the data can be shared into different
debug systems. Another one I'd like to implement is a command-line
view, as per https://github.com/dart-lang/sdk/issues/61496.

There is much code shared between the Contexts page and the Analysis
options page, so that goes into diagnostics.dart.

Change-Id: I054bd19ed2ca54c4b3d7d6898eba3a968c8ca209
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-04-22 13:57:30 -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
Konstantin Shcheglov 18ab2664ca Augment. Report augmentationOfMixinApplicationClass.
Change-Id: I2649f4eb96fc232727fafa16129799ef3f207e20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-04-21 09:57:59 -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
Sam Rawlins 299dabac5f DAS: Enforce constant_identifier_names lint rule.
All we have to do is ignore it in some generated files, and then it
is enforced in all other lib, tool, test files.

Change-Id: I5822db725f9c632820323dd20f5d4b6554808c26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464624
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-20 11:09:49 -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
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
Sam Rawlins 93f0b191b1 linter: Report more use_super_parameters cases where named can be converted
https://github.com/dart-lang/sdk/issues/58729

Change-Id: I257b89580fb31fcd21f9a33d3094dc3cb25063d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-04-17 12:45:29 -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
Brian Wilkerson e049d78f97 Update more of the rename functionality to use ChangeBuilder
There's one class left to convert, as far as I know, and I have it
mostly converted, but adding `awaits` to the code causes an inconsistent
analysis exception and I don't want to wait until I've solved that
problem to land the rest.

Change-Id: Ic5f159f0703fc708119f8bfa249270cb8a853678
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495782
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-15 10:59:43 -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
Sam Rawlins ddefff3dd9 DAS: Fix contexts page list of analysis options
Fixes https://github.com/dart-lang/sdk/issues/63167

Change-Id: I6003f12a87bf35eb013fb001e2cf6c94dbdf3094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495462
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-14 15:18:29 -07:00
Konstantin Shcheglov 18d47a8650 CQ. Migrate all uses of SubstitutedExecutableElementImpl.from() to substitute().
Add `InterfaceType.interfaceMembers` and
`InterfaceType.inheritedConcreteMembers`, and implement them by applying
the type's substitution to the underlying element members.

This moves member instantiation to the `InterfaceType` API instead of
requiring callers to read raw element maps and wrap the results
manually. With this change, code that works with an instantiated type
can ask the type itself for the corresponding instantiated members.

Update completion, inheritance, extension resolution, and summary
reading code to use the new API and `ExecutableElement.substitute()`
instead of `SubstitutedExecutableElementImpl.from()`. This removes the
old helper, simplifies callers, and makes substitution behavior more
uniform across the analyzer.

Change-Id: I2349546d65e9745c2cdeda19ca6ff9283a5fd001
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-04-14 13:39:50 -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
Konstantin Shcheglov bec97e984e CQ. Use public types as inputs, cast inside on entry.
Refactor `applicable_extensions.dart` so its public entry points accept
`DartType` and `ExtensionElement`, and perform implementation casts
internally at the analyzer boundary.

Remove the `strictCasts` parameter as well. Extension applicability
always ignores casts, so the parameter only added noise to the API and
to every call site.

Update completion and fix code in analysis_server to pass public types
directly and drop imports of internal analyzer type classes. Also
centralize the cast from `ExtensionElement` to `ExtensionElementImpl`
inside the helper instead of repeating it in multiple loops.

This makes the API cleaner, keeps the public/internal split in one
place, and reduces accidental coupling to analyzer implementation types.

Change-Id: I770ee5d8788f4c4a7004a0ad18a00cc52552e3b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494802
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-04-13 13:48:24 -07:00
Brian Wilkerson e7136d4772 Update removeLeadingUnderscores for primary constructors
Closes https://github.com/dart-lang/sdk/issues/63077

Change-Id: Iee573f293edbaa011a1882b8b3cb110a643802fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494582
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-04-12 09:07:47 -07:00
Konstantin Shcheglov c6135cbeef CQ. Rename AnalysisOptionsFile to AnalysisOptionsFileKeys.
I'd like to free this name for `AnalysisOptionsFile` data object.

Change-Id: Ie553ef30e9bef1e312e398248d66550ed289018c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494567
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-10 13:44:00 -07:00
Brian Wilkerson f62d10f40c Update the removeConstructorName fix to handle primary constructors
Closes https://github.com/dart-lang/sdk/issues/63072

Change-Id: I3391484a2693b0ec9f520353ac231ee0d9a60c7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494623
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-10 13:04:19 -07:00
Danny Tuppeny 4b01d6b803 [analysis_server] In "Encapsulate Field", update references to renamed parameters in initializers
Fixes https://github.com/dart-lang/sdk/issues/63145

Change-Id: I6dd672e5ae189a023419d2c41157fa7cdc43e46b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494141
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-04-10 09:05:11 -07:00
Brian Wilkerson c075592ca1 Update addSuperParameter to support primary constructors
Closes https://github.com/dart-lang/sdk/issues/63032

Change-Id: Iab1be28ebfc3f206f82e5f8832b5e355b314f480
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494300
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-04-10 08:20:36 -07:00
Kallen Tu 064dd37c05 [analysis_server] Primary constructors: Update RemoveConst.
Added this as a fix for `constConstructorWithNonFinalField` and `constPrimaryConstructorWithBlockBody` who both can be fixed with the removal of the `const` keyword.

Other const removal fixes with primary constructors are covered by `RemoveLexeme`. I added tests for the relevant cases.

Bug: https://github.com/dart-lang/sdk/issues/63071
Change-Id: I0b7bb5f7976fb49e38499915999fe79465e4ae1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492880
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-09 15:09:15 -07:00
Konstantin Shcheglov e1404d8539 Split mixinClassDeclarationWithClause and mixinModifierMixinApplicationClassWithMultipleMixins from mixinClassDeclarationExtendsNotObject.
Report dedicated diagnostics for mixin classes that use a `with` clause
and for mixin application classes that use multiple mixins, instead of
folding both cases into `mixinClassDeclarationExtendsNotObject`.

This makes the reported error match the actual invalid construct. A
`mixin class` with a `with` clause does not have the same problem as a
`mixin class` that extends a non-`Object` superclass, and a mixin
application with multiple mixins is a separate restriction again.

Update the error verifier, diagnostic definitions, messages, and fix
status entries to use the new codes. Also guard `RemoveExtendsClause` so
it only offers a fix when an actual extends clause is present, avoiding
a bogus fix for diagnostics that are now reported on `with` clauses
instead.

Consolidate the diagnostic tests under a single mixin class declaration
test file and update expectations to use the more precise error codes.

The original impetus for this change was a crash in RemoveExtendsClause
quick fix.

Change-Id: I937276f37deb293ca1fecab3ff838ace45af2ec4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493865
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-09 15:01:11 -07:00
Danny Tuppeny e0e7580510 [analysis_server] Update Encapsulate Field to handle declaring parameters
Fixes https://github.com/dart-lang/sdk/issues/63145

Change-Id: I6a7857d62f50a5b27968fca120ee7337f22a551f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494121
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-09 14:52:11 -07:00
FMorschel 188cb9a598 [DAS] Fixes stack trace in create extension member
Fixes: https://github.com/dart-lang/sdk/issues/62736
Change-Id: I59c07165308cf6aff8029eabcdcbd901328970e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483060
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2026-04-09 14:28:22 -07:00