Commit Graph

52221 Commits

Author SHA1 Message Date
Brian Wilkerson edce10b761 Add an assist to convert from a field formal parameter to a normal parameter
Fixes https://github.com/dart-lang/sdk/issues/60852

Change-Id: Iffc674e61b4df16e80ca71cfd18e12c548770b54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433220
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 12:33:34 -07:00
FMorschel 9d6c5d40d0 [DAS] Fixes "Go to declaration" for undefined new constructor
Fixes: https://github.com/dart-lang/sdk/issues/60773
Change-Id: I7ee7cec371fbf0d0f9de1a4fe2b946929ba80d61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-06-05 12:08:44 -07:00
Brian Wilkerson 45722db629 Add documentation for dot shorthand diagnostics
Please let me know if there are other diagnostics that I missed.

Change-Id: I87d29f62bcd1dad519c34212a2aa41d4422f1002
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431949
Reviewed-by: Kallen Tu <kallentu@google.com>
Reviewed-by: Amanda Fitch <afitch@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 10:58:09 -07:00
Danny Tuppeny 9df000075a [analysis_server] Exclude blocks/switch cases from Inline Values unless execution is within them
This prevents inline values showing up alongside code that didn't execute in conditional blocks. It does also mean they don't know up in conditional blocks that _did_ execute one execution has fallen out of them, but I believe this is the best we can do with the current LSP APIs (unless we try to track execution across requests, but that would probably be complete and not entirely reliable).

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

Change-Id: Ia1cf2437b76844ff0a6aeeb958d769c9523dc5dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433200
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 10:53:12 -07:00
Nicholas Shahan 60d418034a [ddc] Bump language version to 3.8
* Reformat pkg/dev_compiler.
* Re-flow some comments to keep them within 80 characters.

Change-Id: I0849ce113ecf3dce4a2b4405c2b09a17dee4df76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433081
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-06-05 10:40:57 -07:00
Nicholas Shahan 6697075645 [ddc] Fix spelling typos
Change-Id: Iafcf14be1fd3032381b4ced2610230538100ce52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433080
Reviewed-by: Mark Zhou <markzipan@google.com>
2025-06-05 10:40:57 -07:00
Sam Rawlins e76fcdad1a analyzer: Remove TODO that is DONE
Change-Id: I15a85d31b797d99d68c94b3c0fe433c18d9effbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432905
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-05 09:43:32 -07:00
Danny Tuppeny b8daa53fef [analysis_server] Don't rebuild contexts on deletion of an analysis root
This is a partial revert of ca9523058e (it removes the behaviour change and the test that verifies this, but leaves two additional tests that were added relating to roots that are created later).

If we rebuild contexts when a root is deleted, we may get stuck in a loop because we will again try to recreate the same (deleted) root, and then the watcher will close in a way that looks like a deleted folder, and we will repeat.

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

Change-Id: I10289160b341d273e8e409184a1c013c7fb9439d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 09:24:41 -07:00
Nate Biggs 26e9c8201a [dart2js] Don't emit deferred loading logs in part files when flag is disabled.
Change-Id: I70a3a3a3c7bd56d8fd994e766f0ab2ab8c1f9ec4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432820
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-06-05 09:17:11 -07:00
Derek Xu c9c8929099 [package:vm_service] Add kTimerSignificantlyOverdue field to EventKind
I overlooked making this additon earlier. This CL also prepares
`package:vm_service 15.0.2` to be published.

TEST=CI

Change-Id: I4d28d87c027d27c4e532e5608f57b62eaa290e44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433082
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-06-05 07:34:51 -07:00
Danny Tuppeny e891cac045 [dds/dap] Handle some additional kinds of errors when the VM Service connection shuts down
This handles an RPC Error -32000 with text "Service connection disposed" as reported in https://github.com/dart-lang/sdk/issues/60851. It extracts some of this logic into an extension on RPCError to simplify checking in multiple places.

Unfortunately I can't reproduce the specific conditions that produce this error in a test (it probably requires terminated the VM Service at just the right time during startup or an isolate starting?).

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

Change-Id: Iae945f60290766164d04b91d851fbb8b58f178c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432944
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-06-05 07:26:16 -07:00
Jake Macdonald bf9acedc73 Adds a new helper resolveTestRelativePath for resolving paths relative to the test dir, which works using the package config instead of Platform.script. This allows it to work via dart test as well as the test runner, or when manually invoked.
Replaced usages of Platform.script.resolve with this utility.

Change-Id: I904d281934c3eb42516e891f27a8f3dbe714e7f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432740
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-06-05 07:23:15 -07:00
Kenzie Davisson 495a2bb694 Update to latest DevTools hash
Change-Id: I3ecb7e661b606907186c0a81b16eecefe4d63a4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432803
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
2025-06-05 04:13:34 -07:00
Sam Rawlins b2beba242d analyzer: Convert callers of InheritanceManager3 to use InterfaceElement API
This includes all callers in analysis_server and analyzer_plugin. And
callers of `getOverridden4`.

Change-Id: Ia744f6c7260b445c6b1e02d3cf5515aaa9c7feeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432962
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-04 16:30:22 -07:00
Sam Rawlins c4c3a72bd4 analyzer: Move error_supporession_test.dart
Work towards https://github.com/dart-lang/sdk/issues/60635

Also rename the test methods to use camelCase and to read more like
sentences.

Change-Id: If4ef85aeeefc5f1364ffbcba2e73df36981fc951
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432961
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-04 16:06:14 -07:00
Brian Wilkerson 1a7617e015 Improve the message for non_exhaustive_switch diagnostics
Fixes https://github.com/dart-lang/sdk/issues/60690

Change-Id: I1431d646a53c39b738369493b6a234df440dc2f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-04 15:17:19 -07:00
Brian Wilkerson 0404c6cd08 Add some message scheduler data to the collected report
Change-Id: I086b741a90955a2753efbabdf1c3cb321de98ee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432903
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-06-04 15:08:20 -07:00
Danny Tuppeny 8d36178a43 [analysis_server] Move support for locking requests to the scheduler
This removes the original `lockRequestsWhile` functionality of the LSP server which worked by pausing reading from stdin to instead pause the processing of messages in the scheduler.

Change-Id: I737e977adee11fe6fc70f44185cfaa22c22805da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432342
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-04 15:06:12 -07:00
Sam Rawlins 47f7c4fb87 analyzer: expose canBeConst and computeConstantValue as public API
Work towards https://github.com/dart-lang/sdk/issues/50986

These utilities are used by a handful of lint rules, and the analysis
server, which makes me think they could be offered as public API.

Change-Id: I12415c2b86ca6fb96b03def4a304da73c6fb4cae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430300
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-04 11:02:17 -07:00
Sam Rawlins 508c35b6f0 linter: unawaited_futures: narrow the reported range, matching discarded_futures
Change-Id: Id8a361a352e409df0a8c9cc9fa73a9f7b5e52c3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431365
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-04 09:26:31 -07:00
Kenzie Davisson 0010cc416f Use constants instead of raw strings throughout package:dtd
Change-Id: Ie4b0dfb115a820fb3f0741ce193c70f6b7d560cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432725
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2025-06-04 08:52:33 -07:00
Danny Tuppeny b1751e6871 [analysis_server] Update some tests to not required useLineEndingsForPlatform=false
Change-Id: I5eafe194465e20942ebea6989a75679d1a9bb866
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432980
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-04 08:45:59 -07:00
Danny Tuppeny 9756ab92db [dds/dap] Include paging data for variables returned as top-level results to evaluateRequest
This reuses the existing code for child variables for building responses to `evaluate` so that we compute lengths for paging data. We have to copy them over from the variable to the EvaluateResponse because these are two unrelated types that happen to have the same fields for this data.

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

Change-Id: I7ca4c522cdb27ce8dce3f7c3a78189417eb93bf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432941
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-06-04 08:35:03 -07:00
Keerti Parthasarathy 25b99786d1 [Completion] Fix for adding duplicate keywords like 'dynamic' when in a declaration.
Change-Id: If8e35edd5ee136b0d272f1ea43a705cf04540bbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432821
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-04 08:31:37 -07:00
Danny Tuppeny 0f161e3ebe [analysis_server] Allow documentation preferences to be different between completion/hovers
For https://github.com/Dart-Code/Dart-Code/issues/4729 we added a configuration setting to let you control how much documentation was included in responses. The motivation here was to reduce the completion payload sizes when running in remote workspaces (Dart-Code would adjust the default setting if not explicitly set by the user based on the workspace kind).

However in hindsight, forcing no docs on Hovers just because we didn't want them in Completion requests was a bad choice, because these are individual requests where the payload size is less important and seeing the docs is useful.

So this alters the setting to accept a `Map` to allow you to have different preferences for each request that returns docs. Dart-Code will be updated to adjust the defaults accordingly (after this lands) so that Hover/SignatureHelp can default to `"full"` even in remote workspaces.

Work towards https://github.com/Dart-Code/Dart-Code/issues/5499

Change-Id: Ib64f762a0559c7afc7653fad9749fc208beee8b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431280
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-04 07:51:45 -07:00
Chloe Stefantsova c542a1e82f [model] Remove support for subtype checks ignoring nullability
Change-Id: I4a43e09094d79c7b5e59eb03cbe7eb676808a5f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426121
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-06-04 06:52:57 -07:00
Paul Berry eec56c088e [flow analysis] Mark false branches of trivial is tests unreachable.
When an `is` test is trivially satisfied (i.e. `expr is T`, when the
static type of `expr` is a subtype of `T`), the `is` test is
guaranteed by soundness to evaluate to `true`, so any code path that
follows from the `is` test evaluating to `false` is unreachable.

This reasoning wasn't valid prior to sound null safety, because in
mixed mode programs, it was possible for an expression to evaluate to
`null` even if its static type wasn't nullable, and hence `expr is T`
might evaluate to `false` even if the static type of `expr` was a
subtype of `T`. So this change is gated on the `sound-flow-analysis`
language flag (which is enabled in Dart 3.9).

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

Change-Id: I66a65580b738162f23b6fb468b71fcac66bfbb95
Bug: https://github.com/dart-lang/sdk/issues/60718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431740
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-04 05:17:21 -07:00
Johnni Winther 27952c5368 [cfe] Remove ConstructorDeclarationBuilder
This interface is no longer needed since SourceConstructorBuilder is the
only implementation.

Change-Id: Ic6426d4c0dbc3820e460a1e4fdc69f323c763885
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432942
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-06-04 04:21:24 -07:00
Chloe Stefantsova 4e9d539c0d [cfe] Mark super initializing parameters erroneous due initializers
Change-Id: I7cf43027a9058f64f41331c9f0b9f9529651d48d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432341
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-06-04 01:18:21 -07:00
Paul Berry b0e488fcb2 [flow analysis] In tests, stop rewriting ordinary variable declarations.
During the implementation of flow analysis for patterns, I added a
hack to the flow analysis tests so that all variable declarations were
desugared into the equivalent pattern variable declaration. This had
the advantage of getting some extra testing "for free" during early
development of the patterns feature, but it had a few disadvantages:

- It the caused the shared flow analysis and type inference tests to
  stop exercising flow analysis code paths for ordinary variable
  declarations.

- It forced the testing logic to "support" pattern variable
  declarations that are late or lack an initializer; these are things
  that regular Dart doesn't support, and they made the implementation
  of `PatternVariableDeclaration.visit` much more complicated than it
  needed to be.

The language team is currently contemplating some changes to how
promotions work in ordinary variable declarations and pattern variable
declarations (see, for example,
https://github.com/dart-lang/language/issues/4347#issuecomment-2861859329). So
in order to be able to experiment with these possibilities, I want to
get rid of this hack.

This CL adds a `VariableDeclaration` class, to represent ordinary
variable declarations, and modifies the `declare` function (which is
used by tests for creating an ordinary variable declaration) so that
it creates a `VariableDeclaration`, rather than rewriting it into a
`PatternVariableDeclaration` containing a `VariablePattern`. It
removes "support" for testing pattern variable declarations that are
late or lack an initializer, simplifying
`PatternVariableDeclaration.visit`.

A few test cases in `type_inference_test.dart` were checking the
generated IR for ordinary variable declarations, verifying that it was
properly desugared into a pattern variable declaration; these
expectations have accordingly changed to no longer expect desugaring.

There is no functional change to the compiler or analyzer
toolchain. These changes only affect tests in
`pkg/_fe_analyzer_shared/test`.

Change-Id: I90f074cd6e7a6ed5ed11afadeadb6131ce1d282f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432122
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-03 17:10:44 -07:00
Paul Berry 69428c35cf [flow analysis] Rename code for testing pattern variable declarations.
The following renames are performed:

- The class `Declare` (which is the "mini-AST" representation of a
  pattern variable declaration), is renamed to
  `PatternVariableDeclaration`.

- The top level function `match` (which is used in tests to construct
  a "mini-AST" representation of a pattern variable declaration), is
  renamed to `patternVariableDeclaration`.

The new names should help avoid confusion in a follow-up CL I intend
to create, which will introduce a new `VariableDeclaration` class to
represent ordinary variable declarations.

There is no functional change. These renames only affect tests in
`pkg/_fe_analyzer_shared`.

Change-Id: Ic6b6f75cbb312180273a08f2c3926f83da254bc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-03 15:21:20 -07:00
Konstantin Shcheglov 8af392c657 Elements. Print FieldElementImpl references in text expectations.
Change-Id: I1f4aefbf0e1f24a5f7ffe1a7e44b83e78f186b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432822
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-03 14:45:08 -07:00
Paul Berry 9602464304 [flow analysis] Don't clear types of interest on full demotion.
Previously, when assiging to a local variable that was promoted, if
the newly assigned value was not compatible with any of the promotions
(i.e., the variable was fully demoted back to its declared type), then
the set of types of interest was cleared.

This behavior was not documented anywhere in the spec, and it seems
oddly inconsistent to me; as far as I can tell, flow analysis doesn't
clear types of interest in any other circumstances. I've looked
through git history as well as my personal notes, and I've been unable
to find any justification for this behavior. So, with the agreement of
the language team, I'm removing it when sound-flow-analysis is
enabled.

Fixes https://github.com/dart-lang/language/issues/4380.

Bug: https://github.com/dart-lang/language/issues/4380
Change-Id: Ic1ca80a61e21482e659afa8796b08fce707db3c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429227
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-03 14:19:53 -07:00
Sam Rawlins cb61cfa8fe linter: Use RuleContext over the deprecated alias, LinterContext
Change-Id: I3df38b96a0cb7756a9dbfbffc80d50c4c73337ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432723
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 14:11:02 -07:00
Konstantin Shcheglov 147ba501d7 Elements. Print ConstructorElementImpl references in text expectations.
Change-Id: I090dc6f9471dae969480caeba0204401dbf280e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432724
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-03 14:08:39 -07:00
Konstantin Shcheglov d116d50416 Elements. Add reference to FieldElementImpl2, write it.
Change-Id: Ia5f4c01aa46571c0a835f7e6408cd1af17fd75e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432781
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-03 13:26:29 -07:00
pq d150bcb97c [das] legacy server support for analytics checking
Fixes: https://github.com/dart-lang/sdk/issues/60853

Change-Id: I3a14c209482b47dc8228c678793e23cf91295fd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432780
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 12:56:12 -07:00
Nate Biggs f7068a415e [ddc] Relax conditions on allowed defineLibrary calls during hot reload.
The current conditions make it so that every library transitively reachable from a reload target (and therefore included in the DDC output) must be known in the client when `dartDevEmbedder.hotReload` is called.

While this is the case for pages running with DWDS, it's an unnecessary constraint. Some users may only care about reloading a specific subset of known libraries. As is the case in dart-pad when we only need to reload the main library as we know this is the only code that can have changed.

Any new libraries must also registered and initialized as this is new code not yet in the page. This would happen if a new import was added to the code.

Change-Id: I164f59a6931fd809867716c164cb467880806f8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432440
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-06-03 12:02:03 -07:00
Sam Rawlins a9ecdf3dc8 linter: Remove more private exports
These exports make it too easy to accidentally rely on private
analyzer impl. Where it is necessary, calling out the individual
imports helps to understand where private impl is used.

Change-Id: I2968610d8285812087b3f716159003d12561eb30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-03 11:59:39 -07:00
Sam Rawlins 31f8f4b522 analyzer: Make various AnalysisRule classes and their dependencies public
This is a big CL; no code is really "changed." We basically move 3
components into the public API, which can all be reviewed concisely
in the `api.txt` file.

* The AnalysisRule classes: `AbstractAnalysisRule` (which is good to
  make public as a lot of the public API is specified and documented
  here), `AnalysisRule`, `MultiAnalysisRule`.
* The Pubspec classes, available for linting pubspec files:
  `PubspecDependency`, `PubspecDependencyList`, `PubspecEntry`,
  `PubspecEnvironment`, `PubspecGitRepo`, `PubspecHost`, `PubspecNode`,
  `PubspecNodeList`, `PubspecVisitor`.
* The `RuleVisitorRegistry` class. This class is needed by analysis
  rule authors, and is part of the public API of AnalysisRule.

Change-Id: Ib1803180de9469f4ff39cf1778f96787f5f74b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-03 11:09:32 -07:00
Danny Tuppeny ca9523058e [analysis_server] Rebuild context roots if an analysis root folder is deleted
Change-Id: I79ada9184686f6f413ed7d732feea22cf39865bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 09:27:10 -07:00
Konstantin Shcheglov a10ce29c08 Elements. Add reference to ConstructorElementImpl2, write it.
Change-Id: I40ff802e9c78b2d74c19769da8339a947d23d7f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432540
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 08:57:59 -07:00
Kenzie Davisson ad34b0e2bb Register the VM service on DTD from DDS
Bug: https://github.com/dart-lang/sdk/issues/60540

Change-Id: Ib646f3bfc0aff079b0cd57dca71e9c3646919eca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429760
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2025-06-03 08:35:51 -07:00
Chloe Stefantsova 8a4b95fae9 [cfe] Copy default values into redirecting factory parameters
Change-Id: Icae02993d15452ae8db8e9905ad77a2e5dfeae29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-06-03 07:44:41 -07:00
Jens Johansen 47bc250896 [analyzer] Add benchmark that calls getFixes on an actual error
This CL adds a benchmark for getFixes calls on an actual error case.
The time it takes is nowhere near the times we're seeing in
http://b/407797012 but it's better than nothing.

The benchmark does 5 requests for `getFixes`.
The first one is always much slower because it has to "discover files".

Comparing old dart releases and CLs
https://dart-review.googlesource.com/c/sdk/+/420323 and
https://dart-review.googlesource.com/c/sdk/+/421220:

3.7.2 was quite a bit slower than 3.6.2.
Both CL 420323 and CL 421220 improve things - both separately and combined.
With both we're faster than 3.6.2 for all but the first getFixes call
(which has to "discover files").

Details:

```
Comparing 3.5.4 with 3.6.2
no change.

Comparing 3.6.2 with 3.7.2
Fixes (1): 16.4789% +/- 8.3240% (0.23 +/- 0.12) (1.39 -> 1.62)
Fixes (2): 300.2940% +/- 21.5781% (0.06 +/- 0.00) (0.02 -> 0.08)
Fixes (3): 220.0321% +/- 23.8171% (0.05 +/- 0.01) (0.02 -> 0.07)
Fixes (4): 89.0472% +/- 86.0948% (0.03 +/- 0.03) (0.04 -> 0.07)
Fixes (5): 202.9467% +/- 22.5906% (0.04 +/- 0.00) (0.02 -> 0.07)

Comparing 3.7.2 with HEAD-ish without the two CLs
Fixes (1): 9.2103% +/- 6.7559% (0.15 +/- 0.11) (1.62 -> 1.77)
Fixes (2): -32.2017% +/- 7.2433% (-0.03 +/- 0.01) (0.08 -> 0.06)
Fixes (3): -39.1903% +/- 7.4656% (-0.03 +/- 0.01) (0.07 -> 0.04)
Fixes (4): -41.5019% +/- 8.2911% (-0.03 +/- 0.01) (0.07 -> 0.04)
Fixes (5): -38.7623% +/- 4.4327% (-0.03 +/- 0.00) (0.07 -> 0.04)

Comparing HEAD-ish without the two CLs with CL 420323 (cache) only
Fixes (1): -5.9976% +/- 4.4944% (-0.11 +/- 0.08) (1.77 -> 1.66)
Fixes (4): -39.3839% +/- 13.3201% (-0.02 +/- 0.01) (0.04 -> 0.02)
Fixes (5): -49.0495% +/- 4.2557% (-0.02 +/- 0.00) (0.04 -> 0.02)

Comparing CL 420323 (cache) only with CL 421220 (element2) only
Fixes (2): -63.4332% +/- 42.9828% (-0.02 +/- 0.02) (0.04 -> 0.01)
Fixes (3): -79.6318% +/- 17.5009% (-0.04 +/- 0.01) (0.05 -> 0.01)
Fixes (4): -68.4995% +/- 11.7414% (-0.02 +/- 0.00) (0.02 -> 0.01)
Fixes (5): -54.6697% +/- 11.1116% (-0.01 +/- 0.00) (0.02 -> 0.01)

Comparing CL 421220 (element2) only with both
Fixes (2): -21.3437% +/- 7.8302% (-0.00 +/- 0.00) (0.01 -> 0.01)
Fixes (3): -17.7975% +/- 10.4789% (-0.00 +/- 0.00) (0.01 -> 0.01)
Fixes (5): -30.5353% +/- 20.5827% (-0.00 +/- 0.00) (0.01 -> 0.01)
```

Change-Id: I477c7a73c669099e2d7bc9d64000cfb78ced2ea4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421601
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-03 07:24:41 -07:00
Johnni Winther 6e8e0f8151 [cfe] Implement synthetic constructors through ConstructorDeclaration
This implements the synthesized constructors for default constructors
and forwarding constructors, avoiding the need for
SyntheticSourceConstructorBuilder.

Change-Id: Iaf7234aab658122a29c644226bf82a63f7895246
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432700
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-06-03 06:45:22 -07:00
Tess Strickland f8e21c5c94 [pkg/test_runner] Only use .dll for assembled snapshots on Windows.
Use "out.aotsnapshot" as the name for all non-assembled snapshots and
names with the appropriate shared object extension for the host OS for
assembled snapshots.

This ensures the test checks for .dll extensions added in
https://dart-review.googlesource.com/c/sdk/+/428200 only trigger
for assembled snapshots as expected, and not for other formats
(e.g., Windows trybots using sanitizers, which still use direct
to ELF snapshots).

Also fixes incorrect line numbers in dwarf_stack_trace_test.dart.

TEST=vm/dart/build_id_test
     standalone/dwarf_stack_trace_test

Cq-Include-Trybots: luci.dart.try:vm-asan-win-release-x64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try
Bug: https://github.com/dart-lang/sdk/issues/60846
Change-Id: Ife06613d86874d76adeb99dcbc50fc3723aae584
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432660
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-06-03 06:23:04 -07:00
Jens Johansen b246cad216 [parser] Change NullValue usage
This gets rid of (what is described in commented code as)
InstantiatedTypeWithArgumentsTest, Subtype1TestCacheLookup, BoolTest.

Running this through the benchmarker like this:

```
out/ReleaseX64/dart-sdk/bin/dart pkg/front_end/tool/benchmarker.dart \
  --snapshot=pkg/analysis_server/bin/server.aot.1 \
  --snapshot=pkg/analysis_server/bin/server.aot.2 \
  --arguments="--disable-file-byte-store" \
  --arguments="--train-using" \
  --arguments="pkg/front_end/lib/"
```

(there `server.aot.1` is without this CL and `server.aot.2` is with)
I get:

```
msec task-clock:u: -0.9614% +/- 0.3557% (-78.23 +/- 28.95) (8136.80 -> 8058.57)
cycles:u: -1.0257% +/- 0.3626% (-348283560.66 +/- 123129577.69) (33955507948.94 -> 33607224388.28)
instructions:u: -1.0595% +/- 0.0662% (-479117043.74 +/- 29935955.93) (45220681554.68 -> 44741564510.94)
seconds time elapsed: -0.9548% +/- 0.3540% (-0.08 +/- 0.03) (8.15 -> 8.07)
seconds user: -1.0649% +/- 0.4031% (-0.08 +/- 0.03) (7.80 -> 7.72)
Scavenge(   new space) goes from 130 to 129
Notice combined GC time goes from 2613 ms to 2608 ms (notice only 1 run each).
```

`StackImpl.pop` as reported by `perf report --no-children` goes from
0.81% to 0.34% (and I'm unsure why the apparent change seen as a whole
is quite a bit bigger).

Change-Id: Ife36da11215e0c8aa706d945f0ee5018ad03ab91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-03 04:58:51 -07:00
Johnni Winther 877fd9a779 [cfe] Refactor _FragmentName
This refactors the _FragmentName class to a more encapsulated approach
in preparation for creating synthetic declarations together with the
user defined declarations.

_FragmentName is renamed to _Declaration and a subhierarchy is created
to handle the various kinds of declarations and let them control how
the corresponding _PreBuilder objects are created.

Change-Id: I5ba3f238112caeb28f8ce6938f15905e512cab6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432620
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-06-03 04:24:32 -07:00
Daco Harkes da5ae4786c [deps] Roll dart-lang/native
Adds support for dev dependencies with build hooks in `dart test`.

TEST=pkg/dartdev/test/native_assets/test_test.dart

Change-Id: Ia05497ef5e1ec2bf11454fde8660b6626dcc524e
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432621
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Commit-Queue: Michael Goderbauer <goderbauer@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2025-06-03 02:47:25 -07:00