Commit Graph

328 Commits

Author SHA1 Message Date
Konstantin Shcheglov 8779d4e9a7 Breaking changes for analyzer version 14.0.0
Change-Id: I3bd6b1bbf60bb1b45f46e62ebf448f27f103f98e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509561
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-06-11 11:59:47 -07:00
Kallen Tu 0f9e6da044 API - Deprecate the excludedPaths parameter in AnalysisContextCollection.
Path exclusions should ideally be defined inside a project's
`analysis_options.yaml` file, rather than being added programatically.

Plus, there's a bug with the constructor that causes this parameter to
be completely ignored anyways, so it's been obsolete and non-functional
for a while now. `getExcludedGlobs` in the `_ContextLocator` handles
parsing and adding excluded paths from the analysis server already, so
we should look into deprecating and removing this parameter.

Change-Id: I6c023041c7bb5fa4cb9dedc629afa4ea6ecb63d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511160
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-06-11 11:15:16 -07:00
Konstantin Shcheglov be4df1a869 API. Add Folder.getFile/Folder, deprecate getChildAssumingFile/Folder
This aligns names with ResourceProvider.getFile/Folder.

Change-Id: I30383ef1fa6f7cbe60b187338e25b8ca75806730
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511120
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-06-11 07:46:21 -07:00
Konstantin Shcheglov fa78f9f947 Augment. Deprecate MethodDeclaration.isAbstract, add isComplete to ConstructorDeclaration, FunctionDeclaration, MethodDeclaration.
Change-Id: I3d5c884870ef183f54e59cd0a5c735373cbe71a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509900
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-06-09 11:28:23 -07:00
Konstantin Shcheglov ea50ec6486 API. Deprecate FormalParameterElement.formalParameters and typeParameters.
For clients outside the library the useful property in
`FormalParameterElement.type`, not *how* this type was specified
syntactically: `void f(int a<T>())` vs. `void f(int Function<T>() a)`.
This way, we have to think about these type parameters and formal
parameters only locally, like for example about local variables - they
exist, enclosed in a fragment, but don't leak outside into the element
model of a method.

I found this while working on the augmentations: that formal parameters
have to have the same types in the introductory declaration, and in
augmentations.

Change-Id: Ie4e92ebd0cd0204c4ba80200a9497e95859cc3e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509522
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-06-09 09:51:14 -07:00
Konstantin Shcheglov 778a860a2a Add ElementAnnotation.isValidAtElement()
Bug: https://github.com/dart-lang/sdk/issues/63503
Change-Id: Iadc096c244607edcb773d70338f1b5b769c25128
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-06-05 18:02:28 -07:00
Konstantin Shcheglov 8c6366e66e Augment. Deprecate ExtensionTypeDeclaration.primaryConstructor, use namePart instead.
Extension type augmentations do not have representation declarations, so
an `ExtensionTypeDeclaration` can no longer always expose its name
through a primary constructor. Add `ExtensionTypeDeclaration.namePart`
as the canonical API for the declared name and type parameters, and keep
`primaryConstructor` as a deprecated compatibility API for introductory
declarations.

Report `extensionTypeAugmentationHasRepresentation` when an augmentation
writes representation syntax. This keeps the parser recovery explicit:
the augmentation still gets a plain `namePart`, while the invalid
representation is diagnosed instead of being modeled as the
declaration's primary constructor.

Synthesize recovery representation and primary constructor fragments
only for the element model when an extension type has no introductory
declaration.

Migrate analyzer, analysis server, analyzer plugin, and linter clients
to read extension type names and type parameters from `namePart`.

Change-Id: I59dd957ac38f087c861b993caf246986dcdac713
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505067
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-26 10:05:28 -07:00
kevmoo 1e8a9d5d45 [api_summary] Include mixins in textual API summaries
Fixes an issue where with mixin clauses were omitted when generating textual API summaries for class and interface declarations.

Regenerates api.txt for analyzer and analyzer_plugin.

Change-Id: Ic33d76955cefb31709e265ec4ea9d5df9a065f7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503701
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-22 11:35:09 -07:00
Konstantin Shcheglov 948e52a768 Augment. Build accessors induced by variable augmentations.
Property-inducing augmentations were linked to the existing field or
top-level variable element before creating the getter and setter
fragments that the augmentation itself induces. This left augmentation
fragments without their corresponding accessor fragments.

Create induced getter and setter fragments for every field and top-level
variable fragment, including augmentations. When an accessor element
already exists, append the new fragment to it; otherwise, create the
accessor element independently so that augmenting getter-only and
setter-only properties works correctly.

Track the relationship at the fragment level in both directions, from
each property-inducing fragment to its induced accessors and from each
accessor fragment back to its inducing variable. Serialize these links
in summaries, expose them through the analyzer element API, and bump the
summary data version for the format change.

Change-Id: Iede43515564326182d8195bd872abf83345bbd72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-18 08:20:07 -07:00
Sam Rawlins 5b07d332e7 analyzer: Move errorRange utilities to public API
Change-Id: Idb886a2e4b333fb1a75195da3072cba91e53ebfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483360
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-05-12 19:44:27 -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
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
Konstantin Shcheglov fffd7cf17b Issue 56118. Add DartObject.toTypeValueNotExtensionTypeErased() as experimental.
Bug: https://github.com/dart-lang/sdk/issues/56118
Change-Id: Iab31aec4737267e03fff7435bd92c3226c9f1744
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488060
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-26 11:29:19 -07:00
Konstantin Shcheglov 40dc31eed9 Elements. Remove MixinFragment.superclassConstraints
This is a breaking change, fortunately we are in the state when
analyzer 13.0.0 is not published yet.

Change-Id: Iaef69a3c6051f6d3cfe84cd66287d26a11baba2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-21 12:42:19 -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
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
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 08f8d4fc7f [analysis_server] Use writeFunctionDeclaration in a few more places
Change-Id: I11f1750281693ee12e7eec6b8fa54cb62dd41cc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492820
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-04-07 09:02:13 -07:00
Konstantin Shcheglov e655e9fd6c DeCo. Add ClassBody.members, EnumBody.constants, EnumBody.members
Add `ClassBody.members` and `EnumBody.constants`/`members` so callers
can access class and enum contents through the common body interfaces
instead of pattern matching on `BlockClassBody` and `BlockEnumBody`.

Implement empty node lists for empty class and enum bodies, update the
public API, and migrate analyzer, analysis_server, analyzer_plugin, and
linter code to use the new accessors directly. This removes the ad hoc
`members2` helper extensions and a large amount of repeated `tryCast`
and `switch` logic, making body traversal more uniform.

Change-Id: I51d75f2253c7e6f75efecae84bf0443ff5eb6788
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-16 19:29:20 -07:00
Konstantin Shcheglov e9d8109258 DeCo. Support empty bodies in membered declarations
Allow enums, extensions, and mixins to use `;` as their body and
represent that form explicitly in the AST. The parser now produces
`EmptyEnumBody` or `EmptyClassBody` for the empty form.

Also replace `LibraryIdentifier` with token-based `DottedName` and store
the full token sequence for dotted names. This preserves periods and
source offsets directly in the AST, which keeps printing, selection, and
directive name handling working with the new shape. See
https://github.com/dart-lang/sdk/issues/62819

See https://github.com/dart-lang/language/issues/4645

Google3 presubmit looks green:
https://fusion2.corp.google.com/presubmit/884063020/OCL:884063020:BASE:884079610:1773618867493:b2110d76

Change-Id: I2d023cd03b6423da634c3e14742e02a61dc3b403
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-16 08:56:11 -07:00
Konstantin Shcheglov fdc447839e Revert "CQ. Use List<Token> tokens in DottedName, using it for LibraryDirective and PartOfDirective."
This reverts commit 44993f7570.

I still would like to do this refactoring, but as in-place breaking
change.

Change-Id: I40c355720fc5ffa423fecb90007dc771e46a10cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487884
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-03-13 11:27:31 -07:00
Erik Ernst 9d2e96b25f Take steps to support anonymous block bodies
This CL adds support for anonymous block bodies (as in `e.{...}`) by
generalizing the flow analysis to handle begin/end of anonymous block
bodies and treating them similarly to labeled statements (and treating
`return` statements using `handleBreak`). It generalizes `handleBreak`
and the internal make `_StatementToContext` to handle `Node` keys rather
than just `Statement` keys, such that an anonymous block body can be the
context. It adds a `bodyContext` instance variable to
`AnonymousBodyImpl` to be used during flow analysis of anonymous block
bodies. `BodyInferenceContext` gets a new factory constructor in order
to allow an anonymous block body to be the context. Finally,
`ErrorVerifier` is generalized to handle the case where a return
statement is returning from an anonymous block body.

Change-Id: I04bc3c852611dbefb885afce655dc00054709fb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482786
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-03-13 08:54:16 -07:00
Konstantin Shcheglov 44993f7570 CQ. Use List<Token> tokens in DottedName, using it for LibraryDirective and PartOfDirective.
DottedName previously exposed only a list of identifier components, so
the resulting string had to be reconstructed (e.g. by inserting periods)
and could lose the original token stream produced by the parser and
recovery.

Introduce an opt-in, token-based representation:

- Add `DottedName.tokens` containing the full token sequence (including '.').
- Add `useDottedNameInLibraryDirective` to let clients opt into the new shape.
- When the flag is enabled, route `library` / `part of` names through
  `DottedName` (`name2` / `libraryName2`) instead of `LibraryIdentifier`.
- Update unlinked/summary serialization and builders to derive names from the
  token stream when opted in, keeping offsets and lengths consistent.
- Extend the AST generator to support flag-guarded properties so the migration
  can be staged without breaking existing clients.

Fixes: dart-lang/sdk#62819
Bug: https://github.com/dart-lang/sdk/issues/62819
Change-Id: Ibd9eab8919313765b321f464726ffd4c84dd6cb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485360
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-06 11:16:40 -08:00
Konstantin Shcheglov 39f7eaa0b9 API. Issue 54346. Add InstantiatedTypeAliasElement.nullabilitySuffix
Bug: https://github.com/dart-lang/sdk/issues/54346
Change-Id: I546387682c8f1606dfc93088b3f9ded90030121d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485583
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-06 10:31:27 -08:00
Konstantin Shcheglov 19895724dd Breaking changes for analyzer version 11.0.0
Change-Id: I75c4dca69a99c0129cc8ae6934d5925382228a00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481542
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-24 14:36:29 -08:00
Paul Berry c6a9c9536e [api_summary] Add class modifier support.
Adds the modifiers `abstract`, `base`, `final`, and `interface` to the
API summary output.

This information is an important part of the public API of a package,
because it determines whether a client can:

- Construct an instance of the class,
- Extend the class, or
- Implement the class.

Change-Id: I6a6a6964ba07db1714bc2fcb549cc15230e87058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482362
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-02-20 10:49:45 -08:00
Paul Berry 02ced6c1a5 [api_summary] Fix member sort order.
Fixes two minor bugs with the sorting of members in the API summary
tool:

- The technique for placing getters next to their corresponding
  setters was to sort them lexicographically based on
  `Element.apiName`, which in the case of setters appends `=`. This
  mostly worked, but due to the fact that `=` is between `9` and `A`
  in ASCII, it was wrong in a few corner cases. For example, it would
  sort `x`, `x=`, `x1`, and `x1=` in the order `x`, `x1`, `x1=`,
  `x=`. Fixing this didn't affect any `api.txt` files in practice.

- The technique for sorting constructors also used `Element.apiName`,
  which in the case of an unnamed constructor is `new`. This meant
  that if a class had both named and unnamed constructors, the unnamed
  constructor would not always be sorted before the other
  constructors.

The fix for both bugs is to sort by `Element.name` (which does not add
`=` for setters and is the empty string for unnamed constructors), and
then to break ties by explicitly checking whether the element is a
setter.

Change-Id: I6a6a69648fb5915266a9111c5d884531bba4405d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482361
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-02-20 10:43:16 -08:00
Konstantin Shcheglov 78435baf28 CQ. Update AST visitor generator to add @Deprecated on RuleVisitorRegistry methods.
Change-Id: Id2f958844f79a29b379dc8794b2a258491d47a11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481982
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-20 09:21:32 -08:00
Sam Rawlins 7d1e512a4a Add AnalysisRule.reportAtSourceRange
Simplifies many reporting cases in the linter package. It also
effectively maps more completely the current DiagnosticReporter API.

Change-Id: Ie4a2ca6aa28d9fefd6c90f6bf8d20553ad19732a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481163
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-18 13:54:37 -08:00
Konstantin Shcheglov 42e6dbd9d4 CQ. Add LibraryFragment.isOriginNotExistingFile, to replace isSynthetic
`isSynthetic` was already deprecated, but now we have a replacement.

Change-Id: I187207557e9ee2de5d819500f2b377886044fb9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479180
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-09 10:28:08 -08:00
Erik Ernst 5d38f82c5f Add a few elements of the anonymous method implementation
This CL adds some elements of the implementation of anonymous methods:
- _fe.../messages.yaml: Add error message about wrong parameter list.
- analysis_server/.../error_fix_status.yaml: Add status of above error.
- analyzer/.../src/.../ast.dart: Add new AST classes AnonymousArrowBody
  AnonymousBlockBody, AnonymousMethodBody, AnonymousMethodInvocation.
- analyzer/.../to_source_visitor.dart: Add new `visit` methods.
- analyzer/.../ast_builder.dart: add `endAnonymousMethodInvocation`.
- analyzer/.../resolver.dart: add new `visit` methods.

Change-Id: Ifa562c653f608884319ad9a1d87e169d9fac4b75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475043
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-06 00:27:02 -08:00
Konstantin Shcheglov 362d3ce032 API. Add TypeSystem.futureValueType
https://github.com/dart-lang/sdk/issues/62583

Change-Id: I7d2ab37c4690a55039b5a7f4accd12c598b3544a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478481
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-05 09:05:51 -08:00
Konstantin Shcheglov e8ae183bde DeCo. Stabilize properties in Element model.
Remove @experimental annotation from:
- ConstructorElement.isPrimary
- FieldElement.declaringFormalParameter
- FieldFormalParameterElement.isDeclaring
- FieldFormalParameterElement.privateName
- FieldFormalParameterFragment.privateName

Change-Id: I65447deef69e40c17f544d4e659e419d10738ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478243
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-04 11:57:29 -08:00
Konstantin Shcheglov 36c29158ab DeCo. Remove ConstructorElement.isDeclaring
The language feature was reduced to just primary constructors.

Change-Id: Ifcf27194912fc91a03ccc05755ba9456e476e27e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478262
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-04 08:52:19 -08:00
Konstantin Shcheglov 4b6664fea7 Issue 62382. Fixes for reporting member conflicts in extension types.
Bug: https://github.com/dart-lang/sdk/issues/62382
Change-Id: I7989b4172d135cea06c0d52aca58162ffc03cdcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475540
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-01-27 07:23:01 -08:00
Konstantin Shcheglov d9b88bd48c DeCo. Add PrimaryConstructorDeclaration.body and PrimaryConstructorBody.declaration to API.
Change-Id: I1164941486002ab79df70d1baf0121b3593b12b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472441
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-01-12 16:14:23 -08:00
Konstantin Shcheglov 9a2bc9327f DeCo. Use primary initializer scope for field initializers.
Change-Id: If035464a318262270b05774c2945ce5b073e486d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471406
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-01-08 19:23:07 -08:00
FMorschel ac0be94edd [analyzer] Adds lineNumberDifference and onSameLine methods to LineInfo
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib0584203b000103f8137901c258a86ec571ff74c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471061
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-07 10:15:29 -08:00
Fedor Shcheglov 09dcc24207 Test that primary constructors can initilaize fields
Change-Id: Ia43d8c44c9b695f823fd80087dfd08efd47367e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470480
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-05 10:46:02 -08:00
Konstantin Shcheglov 6caef97f21 DeCo. Support for PrimaryConstructorBodyImpl.
- Add `PrimaryParameterScope`.
- Add `thisKeywordOffset`.
- Store body metadata and initializers into `ConstructorElement`.
- Resolve.

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: Ifc7b408cfddb1d83e325ab654fa25f072459e3c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469960
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-30 12:14:24 -08:00
Sam Rawlins fa782d8832 analyzer: Remove some deprecated items related to analysis options
These were deprecated in analyzer 9.0.0. They can now be removed.

Change-Id: Ic14b17595c73a690fe693022d8cc3a2581fc048e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469082
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-21 18:57:47 -08:00
Konstantin Shcheglov 23a903e9ae DeCo. Build extension type primary constructors like regular ones.
Previously, the AST builder enforced strict constraints on extension
type primary constructors during parsing, often discarding or
transforming invalid parameters (e.g., multiple, optional, or named
parameters) to force a valid representation field structure. This
limited recovery and resulted in inaccurate element models for invalid
code.

This change updates the AST builder to parse and build elements for the
primary constructor's formal parameters exactly as written. The
validation logic ensuring a single, positional representation field has
been moved to `ErrorVerifier`.

To maintain the invariant that an extension type has a representation, a
synthetic "recovery" representation field is now added to the element
model if the parsed parameters do not provide a valid one.

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I37b7eaf2c085db6317b2c2b0bf35ff31423f9738
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465180
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-19 07:38:31 -08:00
Paul Berry 2c142686c4 [messages] deprecate diagnosticCode.name and diagnosticCode.uniqueName.
Deprecates `DiagnosticCode.name` and
`diagnosticCode.uniqueName`. Clients should use
`DiagnosticCode.lowerCaseName` and
`DiagnosticCode.lowerCaseUniqueName` instead. This will ensure that
clients will compare diagnostic codes in case-insensitive fashion, as
the analyzer itself does.

In a future breaking change release of the analyzer, I will remove the
deprecated getters.

Change-Id: I6a6a69642f2d386546406d4af734808afec13e5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-17 08:33:11 -08:00
Paul Berry 8600df906e [messages] Add SyntacticEntity.sourceRange getter.
This will allow diagnostic reporting code in the analyzer to be more
easily converted to the new literate diagnostic reporting API, because
it will make it possible to use `SourceRange` as the common
denominator for situations where the location where a diagnostic needs
to be reported might come from either a `SyntacticEntity` or a
`SourceRange`.

Change-Id: I6a6a6964f3ec2ea33e8900d93b5abe714c9e1dcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-15 09:02:26 -08:00
Paul Berry 46f62c8f69 [messages] Add lowerCaseName and lowerCaseUniqueName to DiagnosticCode.
Adds the getters `lowerCaseName` and `lowerCaseUniqueName` to the
`DiagnosticCode` class. These getters behave the same as the `name`
and `uniqueName` getters, except that they convert the string to lower
case before returning. These getters should help make it easier for
the analyzer and related packages (as well as analyzer clients) to
treat diagnostic codes in a case-insensitive fashion.

In follow-up CLs, I plan to switch the analyzer and related packages
over to using the new getters, and then I'll deprecate and eventually
remove `name` and `uniqueName` from the analyzer public API.

Change-Id: I6a6a6964e8891fc6f74a9777eae375f1a553c2f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466182
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-08 09:57:56 -08:00
Konstantin Shcheglov d55f142727 DeCo. Add MethodElement.isOriginDeclaration, isOriginInterface; TopLevelFunctionElement.isOriginDeclaration, isOriginLoadLibrary.
Change-Id: If092183a480c066e53ac361f5c8d24042705097f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-05 13:03:13 -08:00
Konstantin Shcheglov d5862675b6 DeCo. Deprecate LibraryElement.isSynthetic, use 'isOriginNotExistingFile' instead.
Change-Id: I9a9be00e1db59ea8dbb92f392604f4ffca636135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466126
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-05 09:13:00 -08:00
Konstantin Shcheglov c4fcd14b6b DeCo. Deprecate Element.isSynthetic, migrate analyzer/ to more specific flags.
Change-Id: I4975083e7ad64b4ec790f49da70e2060e86722ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465984
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-04 09:34:10 -08:00
Erik Ernst 02641c88d0 Transfer parser updates of CL449821 into this CL
Specification proposal:
https://github.com/dart-lang/language/blob/main/working/0260-anonymous-methods/feature-specification.md.

Change-Id: I57743ec663633a148087c1be36e492e1e45e406e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464704
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2025-12-04 08:03:41 -08:00
Konstantin Shcheglov 342a0a7422 DeCo. Add PropertyAccessorElement.isOriginDeclaration, isOriginInterface, isOriginVariable. Same element text writer.
Change-Id: I4a80530e7fe8e971bb5ee3f1138d4e2756b3ff19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465742
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-02 20:59:00 -08:00