Commit Graph

7916 Commits

Author SHA1 Message Date
Paul Berry 527dd5a99f [messages] Change diagnostic codes to lower case in error_fix_status.yaml.
This paves the way for a follow-up CL that will standardize all
diagnostic names to `lower_snake_case` conventions.

For now, the case differences between the entries in
`error_fix_status.yaml` and the actual diagnostic code names are
accounted for by adding some calls to `.toLowerCase()` to
`verify_error_fix_status.dart`.

Change-Id: I6a6a6964b0eacf50b11f302ab511fba149b1ac07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465981
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-03 13:10:24 -08:00
Sam Rawlins 29b942c3f0 DAS plugins: Cache AOT snapshot
Fixes https://github.com/dart-lang/sdk/issues/61684

This caching is based largely on the `--depfile` feature offered by
`dart compile`, which is based on a Ninja depfile concept
(https://ninja-build.org/manual.html#_depfile), which spits out a file
(`depfile.txt` here) which lists all of the input files which were
required to build an AOT snapshot.

The process is essentially:

1. If an AOT snapshot is found, maybe use it as a cached snapshot!
  a. If the `pubspec.yaml` modification timestamp is newer, re-compile!
  b. If the `.dart_tool/package_config.json` modification timestamp is
     newer, re-compile!
  c. If the `bin/plugin.dart` modification timestamp is newer,
     re-compile!
  d. If the `bin/depfile.txt` file is missing or malformed, re-compile!
  e. If any files mentioned in `bin/depfile.txt` have a newer
     modification timestamp, or don't exist, or are an otherwise bad
     path, re-compile!
  f. Otherwise, save a dozen seconds and use the cached snapshot.

Change-Id: Icc747198f8af76d256ac915685473d6f529a3cef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-03 13:02:20 -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
Sam Rawlins 808f5acf21 DAS: Use ProcessRunner in PluginManager, for testability
Work towards https://github.com/dart-lang/sdk/issues/61684

PluginManager needs to be more testable before implementing the caching feature. This CL lays the groundwork.

We add ProcessManager.runSync, and a handler for that in MockProcessHandler. Then we can add tests which call `PluginManager.filesFor` with `isLegacy: false`, and `dart pub upgrade` will not be run on the real filesystem.

Change-Id: I7b8877d985296741e51543c10a7cb87c8a43c116
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465662
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-02 14:09:45 -08:00
Danny Tuppeny eaba16ce3b [analysis_server] Fix selection of Type Hierarchy node for comment references
Fixes https://github.com/dart-lang/sdk/issues/62119

Change-Id: I929ab73010686d6f454a478e4420c886754ef3af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-02 14:01:41 -08:00
Konstantin Shcheglov 21f12a914c DeCo. Add PropertyInducingElement.isOriginDeclaration, isOriginGetterSetter; FieldElement.isOriginDeclaringFormalParameter, isOriginEnumValues.
Change-Id: I92c756a7c74031222efca38a73224dfeff18598b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465481
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-02 11:24:17 -08:00
Konstantin Shcheglov fb0d56b81b DeCo. Use origin flags for constructors.
Introduce explicit origin flags on ConstructorElement and its fragment
(isOriginDeclaration, isOriginImplicitDefault, isOriginMixinApplication)
and deprecate isSynthetic in favor of these. Define isSynthetic as the
inverse of isOriginDeclaration to preserve the legacy meaning while
encouraging clients to use the more precise origin predicates.

Eventually `Element.isSynthetic` also will be deprecated and removed.
This CL is a step toward this goal, migrating what is possible with new
flags.

Update analyzer internals to rely on the new origin flags when checking
for non-factory generative constructors, building synthetic constructors
for mixin applications, and walking constructor chains in index/search
logic. Only constructors with an origin declaration are now treated as
declarations, and nonSynthetic is defined in terms of origin
declarations rather than synthetic-ness. Add corresponding origin
descriptors to the manifest enum and bump AnalysisDriver.DATA_VERSION.

Adjust analysis server refactorings and fixes to distinguish implicit
default constructors from other synthetic constructors. Code paths that
previously checked isSynthetic for default constructors now check
isOriginImplicitDefault, and mixin-application traversal uses
isOriginMixinApplication.

Overall, this change removes the overloaded semantics of isSynthetic,
makes constructor provenance explicit, and prepares the element model
for future DeCo and primary-constructor scenarios without relying on
brittle synthetic heuristics.

Change-Id: I8568bdfe478867af313a4d13afe1f2859394831b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465201
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-02 09:20:12 -08:00
FMorschel 087c08294f [DAS] Fixes part of Convert Getter to Method bug in pattern field references
Bug: https://github.com/dart-lang/sdk/issues/62139
Change-Id: If6927e3a421e190baaade79032d980f12692d676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465360
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-12-02 09:06:32 -08:00
Paul Berry 9c9ee03755 [messages] Stop including class name in uniqueName.
Modifies the code generation logic that populates the
`DiagnosticCode.uniqueName` field so that it doesn't include the
diagnostic's class name.

This paves the way for removing the last remenants of the diagnostic
classes from the analyzer.

Change-Id: I6a6a696453fe1f2bd8bd3cea00a9a496392fbf98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464240
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-01 15:23:55 -08:00
Konstantin Shcheglov e77329ca37 DeCo. Don't check for isSynthetic in getClassMembers.
The clients don't care, we need just to know if there is something or not.

Change-Id: Iaad9a4fb838a7776184e57ab165d160a8daf6105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465200
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-01 13:00:39 -08:00
Danny Tuppeny 4d455c1a8e [analysis_server] Use sdk.dart instead of Platform.resolvedExecutable
Sam noted that AOT snapshots might return `dartaotruntime` for `Platform.resolvedExecutable`. It doesn't seem to happen if you invoke server with `dart language_server` because `dart` is still the executable, but if you invoked the snapshot directly with `dartaotruntime` then this would fail.

To avoid any possibly issues, this changes it to use the same `sdk.dart` getter that some other code uses that handles this difference by constructed the path to the `dart` executable.

Change-Id: I099335a255a792b6754d8d2a1f0bde491c09699e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464681
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-28 07:59:47 -08:00
Robert Nystrom 85a7836435 [private-named-parameters] Report error if the public name collides with another parameter.
Bug: https://github.com/dart-lang/sdk/issues/61643

Change-Id: I219a5310a67459735c61ee9187abd24f4c8cc209
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464605
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-11-26 12:11:54 -08:00
Johnni Winther 17cfd12d31 [parser] Handle factory new() in constructor declaration
This adds error recovery for explicitly naming a factory constructor 'new' with the new constructor syntax. This is not allowed so an error is explicitly emitted while handling this.

Change-Id: I61db5e2abacaebe4f42e44b45a4c3d45faa23377
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-11-26 03:05:30 -08:00
Johnni Winther 85975b4f44 [parser] Handle new new() in constructor declaration
This adds error recovery for explicitly naming a constructor 'new' with the new constructor syntax. This is not allowed so an error is explicitly emitted while handling this.

Change-Id: Iac3045f04c9c75779ffb2d9e866817ac43ab5d26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463281
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-26 03:05:30 -08:00
Danny Tuppeny c8ab18f13e [analysis_server] Improve the display of unnamed extensions in LSP Outline, Document Symbols
We previously just showed "<unnamed extension>" for extensions without names, but in some files I noticed we have a lot of these, and the outline/symbols list looks awful (just "<unnamed extension>" repeated many times).

This changes it to instead show "extension on FooClass" instead (if there is a valid type name). I added a new field to the protocol to support this because the LSP classes convert from those classes (something we've discussed changing, but might be easier later).

Screenshots of before/after are in https://github.com/Dart-Code/Dart-Code/issues/5818

Fixes https://github.com/Dart-Code/Dart-Code/issues/5818

Change-Id: I3885a722443291bfa2419514841469c862b74450
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-25 13:49:55 -08:00
Danny Tuppeny 75fd0906fa [analysis_server] Support dot shorthands in colour picker
Adds support for detecting colours in dot shorthands so they get colour pickers, and also changes the colour presentations when using the colour picker to use dot shorthands in the replacements (though the label will still contain the color class name).

Fixes https://github.com/Dart-Code/Dart-Code/issues/5810

Change-Id: I6a7a16f6f613ed6b9a093e22c5665ccc009b320d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2025-11-25 10:02:51 -08:00
Danny Tuppeny b93488cd4c [analysis_server] Prevent server responding twice to refactor requests
If a refactor request failed with an error, the `request` field wasn't cleared, so the next refactor would cause a cancellation response to be sent for the previous (already-responded-with-an-error) request.

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

Change-Id: I36072556e91f92b50d493833532a81908bf4e6ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464440
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-25 10:00:59 -08:00
Danny Tuppeny e81bc5ea27 [analysis_server] Record unhandled exceptions in message handler zone
This `socketError` callback doesn't record exceptions to the instrumentation service because they were expected to be things like the socket closing. However it was also used for unhandled errors in the zone used for handling errors, which meant they also were not logged. This meant the user would see the error text, but the stack trace would never be logged anyway.

With this change, unhandled exceptions from the zone will be logged through the instrumentation service too.

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

Change-Id: I71d56a8b3c9241744eb614d74de46c190d61f2e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464381
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-11-25 08:55:04 -08:00
Paul Berry 3508315844 [analysis_server] Fix stacktrace handling when reporting exceptions.
Changes the null check in `if (stackTrace != null && exception is!
CaughtException)` from `!=` to `==`. The test was clearly intended to
supply a stack trace if (a) there isn't one already, and (b) one can't
be obtained from `CaughtException`. But with the accidental use of
`!=`, what it was actually doing was destroying the stack trace
supplied by the caller in the circumstance where `exception` was not a
`CaughtException`.

This should make it easier to debug some trybot failures that are
occurring in https://dart-review.googlesource.com/c/sdk/+/464245.

Change-Id: I6a6a6964072bf58db0bcddb22492b0a70203d43a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464460
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-25 08:29:29 -08:00
Konstantin Shcheglov ea9d3cc73e DeCo. Report nonRedirectingGenerativeConstructorWithPrimary
Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: Ie6f221be25b3029a60de4960be8307930358314c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464244
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-11-24 16:16:20 -08:00
Konstantin Shcheglov 6062fe8ae1 Fine. Collect statistics for RequirementFailure kinds.
Requires https://github.com/dart-lang/tools/pull/2250

Change-Id: I477b85d19edec7abdee6f9375a77a4e16dfab9ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463163
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-24 15:59:20 -08:00
Jake Macdonald 60de6c5dad Update analysis server diagnostics page to use relative links
This fixes the links when the diagnostics page is served under a subpath, which happens when proxied through vscode remote and other environments.

Change-Id: I390f4f55c14736051fe46ec67faea798e654efc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464260
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-11-24 09:34:00 -08:00
Paul Berry 7cd95f5f91 [linter] Introduce a new representation for removed lints.
Previously, the process for removing a lint from `pkg/linter` was the
following:

- Remove the lint class's override of
  `AbstractAnalysisRule.registerNodeProcessors` (effectively changing
  the rule into a no-op).

- Change its override of `AnalysisRule.diagnosticCode` to return the
  pseudo-diagnostic code `removedLint`.

- Modify its constructor to use `RuleState.removed`, so that the lint
  would be marked as being in the "removed" state.

This change introduces a new class, `RemovedAnalysisRule`, as the
standard way to represent an analysis rule that has been removed. So
the new process for removing a lint from `pkg/linter` will be to
remove its class entirely and instead register an instance of
`RemovedAnalysisRule`.

This avoids the need for the pseudo-diagnostic code `removedLint` to
exist at all, and also makes the representation of a removed lint much
more compact.

To help encourage clients to use the new `RemovedAnalysisRule` class,
the `RuleState.removed` constructor has been deprecated. It will be
removed in a future version of the analyzer.

Change-Id: I6a6a6964726595b7bb32664846cf4e4722bbb4f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463463
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-24 05:42:12 -08:00
Keerti Parthasarathy 27206451da Revert "Add a finite retry for creating contexts."
This reverts commit fef8cbf885.

Reason for revert: Not the right fix, as this affects all platforms. The issue is seen only on linux and should be addressed as such.

Original change's description:
> Add a finite retry for creating contexts.
>
> Fixes https://github.com/dart-lang/sdk/issues/61931.
>
> The exception we see when there are no file watchers available is a file path not found exception. This is not specific enough for us to exit on the exception, hence the finite retries.
>
> Change-Id: I8ba5081e1e916d3a1272821367806dc7d8391ec4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462780
> Commit-Queue: Keerti Parthasarathy <keertip@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I62b7336bd65234cf309053fffb19dccbaaadddae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-11-21 10:55:32 -08:00
FMorschel 4b7fea91b0 [DAS] Fixes rename for constructors and members with the same name
Fixes: https://github.com/dart-lang/sdk/issues/60916
Change-Id: I12a95c17f1f64cb2d0a2f5b551889804c08aab70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435520
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-11-21 09:42:00 -08:00
Paul Berry 01e0f8a84d Revert "Do not rebuild contexts on Linux if there is a error indicating the watcher limit has been reached. This prevents the hang for the cli."
This reverts commit 19b345cadc.

Reason for revert: Breaks analysis server / VSCode integration.

Original change's description:
> Do not rebuild contexts on Linux if there is a error indicating the watcher limit has been reached. This prevents the hang for the cli.
>
> In the IDE, tested on both VS Code and IntelliJ, a message is shown when there are no watchers.
>
> For the cli, there is no message shown now. To do so we would need to plumb through the messaging, as this exception happens when we set roots, and there is no exception handling there.
>
> Like to land this before looking into that.
>
> https://github.com/dart-lang/sdk/issues/61931.
>
> Change-Id: Iaae9a85e646dfed4015e130076265be39b932f1c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463062
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Keerti Parthasarathy <keertip@google.com>

Change-Id: Ief7cab1974535c526030803ab7624f6a9fc06844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463700
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-21 09:06:20 -08:00
Danny Tuppeny 0cdf92fdd7 [analysis_server] In super constructor invocations don't suggest names of super parameters
Fixes https://github.com/dart-lang/sdk/issues/61930

Change-Id: I3c3616cd40e706dd1dfba8db54e39d168ea5fc38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463620
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-11-21 08:24:13 -08:00
Danny Tuppeny d92bc1dddd [analysis_server] Handle Go-to-Type Definition for patterns
Fixes https://github.com/dart-lang/sdk/issues/62041

Change-Id: Ib7f84460c59d140fc9cc6ad9ed1012ef1c9c3a9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-11-21 08:05:09 -08:00
Konstantin Shcheglov e61aa1107d DeCo. Add ConstructorDeclaration.typeName, switch analysis_server/ to it.
Not actual migration, uses null asserts.
Should be made safe as part of implementation in the server.

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I792ca9d05f25d3819d83a6119586ef937f00d31f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463464
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-20 13:52:56 -08:00
Paul Berry 6f0972fc7d [messages] Remove no-longer used derived diagnostic classes.
Removes all the generated classes derived from `DiagnosticCode` that
are specific to a type of diagnostic, except for those associated with
lints (`LinterLintCode`, `LinterLintWithoutArguments`, and
`LinterLintTemplate`). These exceptions are needed because the base
class for lint codes, `LintCode`, is part of the anlyzer public API,
and so it's necessary for lint codes to all implement it.

The generated static constants in these classes are removed too
(including the ones in `LinterLintCode`), since they are no longer
used; the analyzer and related packages have all been transitioned
over to refer to top level diagnostic constants instead.

Note that the class `ParserErrorCode` could not be completely removed,
because it is dependend upon by `package:dart_style`. So a stub
version of it is added to
`package:analyzer/src/dart/scanner/scanner.dart` (the file that
`package:dart_style` imports it from) as a temporary workaround.

Change-Id: I6a6a69648acac350e4e2249efe50ae9c652772b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-20 12:22:00 -08:00
keertip 19b345cadc Do not rebuild contexts on Linux if there is a error indicating the watcher limit has been reached. This prevents the hang for the cli.
In the IDE, tested on both VS Code and IntelliJ, a message is shown when there are no watchers.

For the cli, there is no message shown now. To do so we would need to plumb through the messaging, as this exception happens when we set roots, and there is no exception handling there.

Like to land this before looking into that.

https://github.com/dart-lang/sdk/issues/61931.

Change-Id: Iaae9a85e646dfed4015e130076265be39b932f1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463062
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-11-20 09:04:49 -08:00
Johnni Winther abfbf952cb [parser] Handle qualified names in new constructor syntax
This improves the error recovery for syntax like `new C.named();`. Previously, the parser would derail with messages like "A method declaration needs an explicit list of parameters" and a cascade of other errors.

With this change the qualified name is recognized as an attemp to write the name of the constructor, reporting that qualified names are not allowed in this case.

Part of https://github.com/dart-lang/sdk/issues/61699

Change-Id: Id1062aac3b90db8d2346013cf8a0bd9a541b9a3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-11-20 00:30:11 -08:00
Konstantin Shcheglov ea84bc9df1 DeCo. Deprecate RepresentationDeclaration and RepresentationConstructorName.
Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I3ed4ccabdd466654585e14f674bb404cde466c1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-19 10:08:13 -08:00
Konstantin Shcheglov f807ca5729 DeCo. Improve Move Top-Level to File refactoring.
Tests and support for enum / mixin as subclasses of sealed classes.
Tests for multi top-level variable declarations.

Change-Id: I19697958c88010453238b632714c48f67456d2be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462781
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-18 13:30:19 -08:00
Sam Rawlins 6910a34b0a DAS: Correct calculations of whether an element is deprecated
I missed examining these use cases when I introduced the other
Deprecated constructors. But this leads to some UI bugs (like hover and
suggestions showing strikethrough) and relevance bugs in DAS.

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

Change-Id: Ief71c4d70d57f989aaf5c2d7159f418d706d6a03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462742
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 13:22:11 -08:00
Paul Berry f72f7d2b16 [messages] Remove diagnostic class names from error_fix_status.yaml.
This is part of a larger effort to remove the diagnostic classes
entirely.

Change-Id: I6a6a69646c8d604d29d8e62da886628c3c9613ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462501
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 11:56:21 -08:00
Paul Berry 29b291f812 [messages] Fix error_fix_status.yaml.
Adds missing `status` entries to the analysis server's
`error_fix_status.yaml` file.

The reason these were missing was because currently, the only
validation logic that checks that `status` entries are present is in
`pkg/linter/tool/machine.dart` (the `readFixStatusMap` function), and
it ignores entries that don't start with the class name prefix
`LintCode.`.

This paves the way for a follow-up CL that will remove the class name
prefixes from `error_fix_status.yaml` entirely (as part of a larger
effort to remove those classes from the codebase).

Note that the validation logic in `readFixStatusMap` is not really
very robust; it only checks that the `status` entries are strings. In
a follow-up CL I will add a more thorough check.

Change-Id: I6a6a69644f7cc07162f5614c87149d6e72b99d23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462700
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 11:40:50 -08:00
keertip fef8cbf885 Add a finite retry for creating contexts.
Fixes https://github.com/dart-lang/sdk/issues/61931.

The exception we see when there are no file watchers available is a file path not found exception. This is not specific enough for us to exit on the exception, hence the finite retries.

Change-Id: I8ba5081e1e916d3a1272821367806dc7d8391ec4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462780
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 11:24:05 -08:00
Konstantin Shcheglov 68058cf0b3 DeCo. Deprecate NamedCompilationUnitMember.
Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I6de6874d27423d466d8bb5a5a75a8c26518fa557
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462562
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 10:22:13 -08:00
Danny Tuppeny ef9a322196 [analysis_server] Fix hover ranges on operators
Fixes https://github.com/dart-lang/sdk/issues/62000

Change-Id: I35277f538903d54a9a0a74ee632d5cdc43c11080
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462445
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-17 10:01:22 -08:00
Konstantin Shcheglov 09804d2bac Fine. Enable by default in DAS, use '--no-with-fine-dependencies' to disable.
Change-Id: I6a0ad214ae3b0f12dec9922fedb07ab28654f019
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462540
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-17 09:25:28 -08:00
Konstantin Shcheglov 0349520b98 DeCo. Migrate everything to new AST.
No more flag, always parse into the new AST, always visit new AST nodes,
always return them as child entities, parent-child structure reflects
the new AST.

So, use `namePart` and `body` where possible. Deprecate previous
properties.

This is still de jure a breaking change, because `parent` of deprecated
properties changes. De facto this required very few changes in google3.

Once this CL lands, I will publish `analyzer 10.0.0`, migrate everything
to new properties, delete deprecated properties, and publish `analyzer
11.0.0`.

Maybe deprecate `NamedCompilationUnitMember.name` and migrate to
subclass specific `name` or `namePart` properties before publishing
`analyzer 10.0.0`. This part is not breaking per se.

* Deprecations in `ClassDeclaration`:
  * Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `EnumDeclaration`:
  * Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `ExtensionDeclaration`:
  * Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
* Deprecations in `ExtensionTypeDeclaration`:
  * Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `constKeyword`, `name`, `representation`, `typeParameters` are deprecated,
    use `primaryConstructor` instead.
* **Breaking Change:** While the deprecated members mentioned  above still exist in the AST,
  their parent nodes have changed. This means that code  relying on specific parent-child
  relationships for these nodes might break.

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: Ic48104da8b029c9b454bbd2336574b7823025565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461841
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-17 08:57:36 -08:00
Brian Wilkerson c0e01c82eb Add access to the session logger on the insights pages
This adds a page on which users can start and stop the collection of
log entries and then copy and paste those entries either to send to us
or to write a scenario.

I changed my mind about the interaction style I wanted on this new page,
so I had to modify the in-memory session log sink slightly.

I also changed one of the labels to reflect the rename to the insights
pages.

Change-Id: I460668047d777f2ee98764ecff7845ea2d2fda99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462244
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-11-17 07:47:33 -08:00
Konstantin Shcheglov e0d12a8d00 Fine. Use 'withFineDependencies: true' in analysis_server/.
Change-Id: I13fb9e2e8dfaca2e6eeca286e415c6df4bc10094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462240
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-14 15:07:31 -08:00
FMorschel c9f3e9a78e [DAS] Fixes Add missing parameter fix for super parameters
Fixes: https://github.com/dart-lang/sdk/issues/48359
Change-Id: Id7a286ad5757387a78a952c9367fc4cd071f7bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-14 13:32:01 -08:00
FMorschel 2a4c954f34 [DAS] Fixes Add field formal parameters for private named fields
Fixes: https://github.com/dart-lang/sdk/issues/61381
Change-Id: I02fd027e874325107c6b81663139cf6fd3189a38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459502
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-14 13:05:39 -08:00
Brian Wilkerson bc6b01e43b Add support for capturing a session log for a short time
Adds a new logging sink that supports an in-memory storage of events for
a subset of the whole server session. This is support for being able to
add 'start' and 'stop' buttons to the insight pages, which will allow
us and users to capture a smaller number of log entries.

Change-Id: Ia562e4da7b09c11ad9191c24cb85102970e1b116
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461901
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-11-14 11:39:09 -08:00
FMorschel dc7109e83b [DAS] Fixes renaming of dot shorthand constructor invocation
Bug: https://github.com/dart-lang/sdk/issues/61969
Change-Id: I96f8fd09d7fa788e9a55362fcc359b4dbadaa70d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461981
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-14 10:47:21 -08:00
Sam Rawlins 83b47a8333 DAS: rename constants to use lowerCamelCase
Change-Id: If3f23ffc275171c67d0dc9cab3ee4abb7c5bc117
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461181
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-14 10:26:10 -08:00
FMorschel e4cec87683 [DAS] Fixes argument completion for dot shorthands invocations
Bug: https://github.com/dart-lang/sdk/issues/61969
Change-Id: Ie109e6bdf657ccbc02510da912087d2babf3806e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462081
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-14 07:42:38 -08:00