Commit Graph

10625 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 5a9ea6d9ed DAS: Fix broken test on windows
Test introduced by https://dart-review.googlesource.com/c/sdk/+/465662

Change-Id: Ibe66b836c69bfee2665499c010249019a5f7d8d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465820
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-02 18:27:02 -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
Jake Macdonald d58a6ee53c Start on a log normalization tool
For now this just takes the workspace root and replaces all occurrences of it with {{workspaceRoot}}.

Change-Id: I14af057ddd4e20f002499670effb6f9e7101fce6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2025-12-02 13:47:26 -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
Brian Wilkerson 47c4c4f60e Make corrections to the language fidelity page
Change-Id: I250f02e1db2c78344936d9b6d3102019bf97d7f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465460
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-02 07:20:19 -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
Kallen Tu 2110e90d68 Rename 'declaring-constructors' to 'primary-constructors' experiment flag.
Changed the flag to `primary-constructors` to align with the rest of
the feature's public naming.

Renamed tests and existing usages of the flag.

Bug: https://github.com/dart-lang/sdk/issues/61526
Change-Id: Id649447a50917ba5bcddb49661555889dc81ba14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464761
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2025-12-01 13:54:52 -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
FMorschel eb1a814681 [DAS] Fixes create fixes type resolving in for-in loops.
This makes the create fixes correctly suggest `Iterable`, `Future<Iterable>`, or `Future<Stream>` when the awaited expression is used in a for-in loop. It also takes into account the type of the loop variable for the type argument of `Iterable` or `Stream`.

Fixes: https://github.com/dart-lang/sdk/issues/62092
Change-Id: I055af13ee12ceb141f5d75c340c607ae803d0b07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464782
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-30 15:19:55 -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
Brian Wilkerson b262f60227 Code cleanup in log player and server driver
Setting the command-line arguments separately from the protocol used to
be necessary, but it no long is, so it's cleaner to just set the command
line arguments when creating the server and moving the handling of the
protocol option into the server. This resulted in a cleaner API and
implementation.

Change-Id: I9456e2a43310bb855b54c010af64ce0328a08ff7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464785
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-11-27 07:29:41 -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
Brian Wilkerson 11230466e7 Fix the handling of LSP headers
The invalid handling of LSP headers caused the analysis server, in LSP
mode, to not recognize any of the messages being sent to it.

Change-Id: I03b3c8e22216f3451401823dd62a49a984edc550
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464626
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-11-26 11:31:58 -08:00
Brian Wilkerson a27682c68e Enhance the docs for language fidelity
This fills in places that were previously left TBD, adds a new section,
re-organizes a bit for consistency, and cleans up some of the text.

Change-Id: I06eb32b6d2d8fe14c0bcf8b37ac8147cd08cafa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464622
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-11-26 09:23:50 -08:00
Brian Wilkerson 7bbf6f9a7a Add the ability to generate export directives
This was used to test the timing of export cycles.

Change-Id: Ib7ddb6b46639f196e8db30039d25e64e8dc5f662
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464462
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-11-26 07:29:09 -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 cb03b3ca2c [analysis_server] Ensure context messages have an integration test for legacy
Fixes https://github.com/dart-lang/sdk/issues/44907

Change-Id: I2535f7ebf24da4abea21e32eff58087925d45345
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-11-25 10:34:56 -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
Paul Berry 7b1361cf69 [messages] add types to messages.yaml files.
Adds `type:` entries to the analyzer-style `messages.yaml` files.

Currently the only function of these entries is that they are checked
against the diagnostic types implied by the diagnostic's class name
(diagnostics under the heading `CompileTimeErrorCode` must have type
`compileTimeError`, those under `StaticWarningCode` must have type
`staticWarning`, etc).

In a follow-up CL I will change the code generation logic to these
`type:` entries instead of inferring the type from the diagnostic
code's class. This will pave the way for removing the notion of
diagnostic code class entirely.

This change was produced automatically by running the script
`pkg/analyzer_utilities/tool/messages/add_types_to_yaml.dart`.

Change-Id: I6a6a69646958a34e24ccbf69cb96ead9d7e7865b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464282
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-25 09:40:03 -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
Sam Rawlins b65b23650e analyzer_testing: Add deprecation to required annotations
When generating the mock packages from the real packages, I found this
discrepancy; we're missing this deprecation. To keep things aligned as
close as possible, we should add it.

Change-Id: Ibbfd9164be5b344c358a4546542723f7deaff73d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463162
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-20 13:46:18 -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
Parker Lougheed 83be6421b2 [linter] Disable prefer_final_parameters if primary constructors are enabled
Bug: https://github.com/dart-lang/sdk/issues/61675
Change-Id: I6fcc4b889d20e270c64d00c2c796935a045055a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463064
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-20 08:57:45 -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
Paul Berry 9bef3225fb [messages] Better validation for error_fix_status.
Adds logic to `verify_error_fix_status.dart` to validate that every
entry is a YAML map and contains a valid status code.

The error reporting logic is rewritten to make use of the
`LocatedError` class so that if validation fails, it's not necessary
to describe where to find the erroneous entry; instead, the offending
path, line number, and column is printed as part of the exception
message.

Change-Id: I6a6a6964c8cc3094f81ad2b28dd444bfcb6c15c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463084
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 15:17:50 -08:00
Paul Berry 26c90ed46b [messages] Clean up unignorable error handling.
Prior to this CL, the analyzer's set of unignorable diagnostic code
names (`AnalysisOptionsImpl.unignorableDiagnosticCodeNames`) was
constructed in the following way:

- For each entry in the `cannot-ignore` section of the
  `analysis_options.yaml` file that matches the name of a severity
  code, the names of all diagnostic codes with matching severities
  were added (1).

- All other entries in the `cannot-ignore` section were converted to
  upper case and then added (2).

However, diagnostic codes associated with lints are named using
`lower_snake_case`, while analyzer diagnonstic codes are named using
`UPPER_SNAKE_CASE`.

Some of the logic that consumed
`AnalysisOptionsImpl.unignorableDiagnosticCodeNames` didn't account
for this, resulting in some subtle bugs:

- When the resolved correction producer base class
  `_BaseIgnoreDiagnostic` attempted to figure out if a diagnostic was
  unignorable, it compared elements of
  `unignorableDiagnosticCodeNames` to `DiagnosticCode.name`, which
  meant that it would successfully recognize non-lint codes as
  unignorable, but it would only recognize that a lint code was
  unignorable if it was included in `unignorableDiagnosticCodeNames`
  by putting the name of a severity in the `cannot-ignore` section of
  the `analysis_options.yaml` file.

- When `LibraryAnalyzer._filterIgnoredDiagnostics` attempted to block
  unignorable diagnostics from being ignored, it compared elements of
  `unignorableDiagnosticCodeNames` to `DiagnosticCode.name`,
  `DiagnosticCode.uniqueName`, and
  `DiagnosticCode.name.toUpperCase()`. This worked, however the
  comparison to `DiagnosticCode.uniqueName` had no effect. Note that
  values of `DiagnosticCode.uniqueName` always take the form
  `ClassName.snake_case_diagnostic_code` or
  `ClassName.SNAKE_CASE_DIAGNOSTIC_CODE`. It's impossible for any of
  the values added to
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` to ever match
  this, because (1) always adds values of `DiagnosticCode.name` (which
  never contains a `.`), and (2) always adds strings that have been
  converted to upper case.

- When `IgnoreValidator.reportErrors` attempted to report unignorable
  and duplicate entries, it compared elements of
  `unignorableDiagnosticCodeNames` to `IgnoredDiagnosticName.name`,
  which is always lower case. That meant that it would only recognize
  that a diagnostic code was unignorable if the diagnostic code was
  associated with a lint and was included in
  `unignorableDiagnosticCodeNames` by putting the name of a severity
  in the `cannot-ignore` section of the `analysis_options.yaml`
  file. (Note, however, that this bug was unobservable because the
  reporting of the `unignorable_ignore` diagnostic is currently
  disabled; I will address this in a follow-up CL.)

- Additionally, the logic to populate
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` based on a
  severity code had a bug in its handling of error processors: if one
  or more error processors were used to change the severity of a
  diagnostic, then entries would be added to
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` corresponding
  to both the original and the new severity.

These buggy behaviors have been fixed by:

- Streamlining and simplifying the logic that builds
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames`, and ensuring
  that all strings added to it are all lower case.

- Changing all logic that checks whether a string is contained in
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` so that it
  first converts that string to lower case.

- Removing the ineffective logic in
  `LibraryAnalyzer._filterIgnoredDiagnostics` that attempted to
  compare elements of `unignorableDiagnosticCodeNames` to
  `DiagnosticCode.uniqueName`.

Change-Id: I6a6a6964d89c139492dbb11d8ba3b2d33c0e2ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462864
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 13:46:10 -08:00
FMorschel 37c81bf131 [DAS] Fixes renaming parameters in Dot-Shorthands constructor invocations
Fixes: https://github.com/dart-lang/sdk/issues/62036
Change-Id: I4db61acd6bad5dd25f3963c32aa0352110258013
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463082
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-11-19 12:39:15 -08:00
Paul Berry e4868ca176 [messages] Clean up ErrorProcessor behavior.
Currently, diagnostic codes associated with lints are named using
`lower_snake_case`, while analyzer diagnonstic codes are named using
`UPPER_SNAKE_CASE`.

However, when the analyzer builds instances of the `ErrorProcessor`
class, it always uses `UPPER_SNAKE_CASE` names.

Some pieces of logic that matched up `ErrorProcessor`s to diagnostic
codes accounted for this difference; others didn't.

This led to a some buggy behaviors:

- If an instance of `ErrorProcessor` got constructed outside of the
  analyzer (by an analyzer client using the analyzer public API), and
  it supplied a `lower_snake_case` name, then
  `ErrorProcessor.appliesTo` would only successfully match if the name
  referred to a lint.

- The resolved correction producer base class `_BaseIgnoreDiagnostic`
  (which forms the basis for the quick fixes "Ignore '...' in
  `analysis_options.yaml`", "Ignore '...' for this line", and "Ignore
  '...' for the whole file") would only notice that a diagnostic was
  unignorable if the case matched exactly. In practice, this meant
  that when operating on instances of `ErrorProcessor` created by the
  analyzer, it wouldn't properly handle lints.

These buggy behaviors have been fixed by:

- Changing the `ErrorProcessor` constructor to always convert the
  `code` to lower case.

- Changing all references to `ErrorProcessor.code` to assume lower
  case.

Change-Id: I6a6a69645284f646e0c070fc2b55c4a90203d74a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462863
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 11:31:21 -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