Commit Graph

8161 Commits

Author SHA1 Message Date
FMorschel ac0be94edd [analyzer] Adds lineNumberDifference and onSameLine methods to LineInfo
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib0584203b000103f8137901c258a86ec571ff74c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471061
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-07 10:15:29 -08:00
Brian Wilkerson c4ed22e204 Update the member sorter to handle primary constructor bodies
With these changes, primary constructor bodies will sort with
constructors (based on whether `sort_members_first` is enabled), but
will always be before other constructors.

Change-Id: If6719dedd5178c384712a5d08b4e74a38aaf54a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471280
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-07 09:29:04 -08:00
Jake Macdonald 1a0371034b Additional fixes for scenario replays
- Skip notifications from analyzer
- Hard code responses to certain startup logs if they are unexpected
- Use cli_util to show loading spinner and get sdk location
- Update normalize to substitute the sdk location
- Make id field optional on message (notifications don't have ids)

Change-Id: Ia5276eef554a3afefeae227fa7351f902d21131e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471060
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-06 13:34:56 -08:00
Sam Rawlins 92bebe661b DAS plugins: Begin storing analytics data
This data is collected on shutdown, the same as the legacy analytics data.

This is implementation for some of the analytics we want to collect,
specified at go/dart-analyzer-plugin-analytics.

* How many plugins are enabled for each context?
* How many lint rules are registered for each plugin?
* How many warning rules are registered for each plugin?
* How many fixes are registered for each plugin?
* How many assists are registered for each plugin?

Change-Id: I36c176737c194550e1947985576ed461fd8a1bf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452482
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-05 21:28:18 -08:00
Aman Gupta ebc9f84f50 chore: Fix typos in analysis_server error messages
Closes https://github.com/dart-lang/sdk/pull/62336

GitOrigin-RevId: 9871d040bbf7c85208e61962583b209a8418ffa5
Change-Id: I7b934e1df6a667c2f43ac4ff10552a3d5fae292b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-01-05 09:00:50 -08:00
FMorschel 20d8f8f166 [analyzer_plugin] Fixes writing recursive type parameter
Fixes: https://github.com/dart-lang/sdk/issues/62272
Change-Id: I2370adbf51b709e8860fcc12b6678cde504f1329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469201
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-02 11:26:48 -08:00
Fedor Shcheglov d36d50a95c Report primaryConstructorBodyWithoutDeclaration.
Change-Id: I14e76e514f1aeee2a171784b778d8f8747a3dada
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-01 12:14:25 -08:00
Fedor Shcheglov 884817d52d Fix case and default not appearing as suggestions inside a switch statement that contains elements
Change-Id: Ib9a2f6ec583efee33566e17cc54ce1484cf87dbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470080
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-30 13:01:50 -08:00
Fedor Shcheglov bf97a8dc1d Fix a crash resulting from attempting to access a null URI when running package_names lint during code actions.
Change-Id: I8ad16c5316ba08eb77109803d09b210135639be4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-29 18:05:10 -08:00
Fedor Shcheglov bf5cfaedd9 Renamed variables, formal parameters, and declared identifiers that were incorrectly named elements, when they had a fragment type.
Change-Id: Id201a1f319ee2ae1e328c1d551a98df97bdc2b5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-29 18:04:29 -08:00
Fedor Shcheglov c854455f62 Fix a bug where renaming a field formal parameter would not rename the field formal parameter in subclasses or superclasses.
Change-Id: I43a11195e08b66b561e7bb163a62d00bb5c3dc03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469520
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-22 14:58:19 -08:00
FMorschel 10147534f4 [DAS] Fixes go to imports for annotations constructors
Fixes: https://github.com/dart-lang/sdk/issues/62258
Change-Id: Ia9c068ff7ea731953c91125aba92dd3e2f796184
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468900
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-12-19 13:29:37 -08:00
FMorschel ae81c0fc05 [DAS] Fixes import with prefix to work with annotations
Fixes: https://github.com/dart-lang/sdk/issues/62259
Change-Id: I0dc38fbf16a3f88a4380c94d856c89fc5d8130df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468903
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-19 13:29:18 -08:00
Brian Wilkerson 7ed0d8d7b2 Fix a crash in the outline computer
This isn't the right implementation, but it no longer crashes when
experimenting with the primary_constructor feature.

While I don't expect this to impact users, it makes it easier for us to
play with the feature while developing the tooling for it.

Change-Id: I317eb03bfd4057adb39dd4352e43e41fdd28bd7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469101
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-18 13:01:59 -08:00
Sam Rawlins 971aa0b12a meta: Annotate visibleForOverriding and visibleForTesting with TargetKinds
In the analyzer, remove our custom warning for `visibleForOverriding`,
`invalid_visible_for_overriding_annotation` (replaced by the existing
`invalid_annotation_target` warning). The tests for that warning are
mostly covered by the existing `invalid_annotation_target` tests, but
I added a few to fill some gaps.

Work towards https://github.com/dart-lang/sdk/issues/62253

Change-Id: Ie960db6ebe007afde787f68e4b6b9f20a1835639
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468702
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-18 12:05:43 -08:00
Sam Rawlins f26bf0012d analyzer: Report unused fields with origin in a primary constructor
Work towards https://github.com/dart-lang/sdk/issues/62248

In this change, we exclude fields declared in a primary constructor
which is declared in an extension type. Since the representation field
is required, the corrective action is unclear. (I can't think of what
purpose an extension type would serve, if its representation field is
never referenced. But users are creative.)

Change-Id: I9556f5d28a16dc7114b30c77369281774bc7c2fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467924
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-18 11:26:20 -08:00
Keerti Parthasarathy 1f864a4633 [perf tesing]Add an option to write out a log with performance related data
This is mainly to exercise the performance test framework, for writing
a report for the test runs.

- adds a flag to specify a file
- logs context information and info from the message scheduler

Started with just these two as an example as I was not sure what performance data we do want to record.

Change-Id: I3e5ff4b77c62d36e47ba7bac8f656b19ba19c457
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-12-18 07:35:49 -08:00
FMorschel 850a760078 [DAS] Fixes dot-shorthand completion for annotations
Fixes: https://github.com/dart-lang/sdk/issues/62260
Change-Id: I3439237fd02c66600908190caeb07e1b0c4bfa7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468701
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-17 08:59:27 -08:00
FMorschel 275581bca1 [DAS] Fixes completion for switch expression pattern after when
Fixes: https://github.com/dart-lang/sdk/issues/62210
Change-Id: I42a3d6f3f93a8ecc8f4b866d89119a6cc49bd3e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467160
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-12-16 09:07:37 -08:00
Brian Wilkerson 4dd879a477 Stop suggesting final in parameter lists
This stops completion from suggesting `final` outisde a primary
constructor's parameter list when the feature is enabled. When the
feature is not enabled, it won't be suggested anywhere. I did that
because in the same release this CL is for we'll produce a warning if
`final` is used, and it seems unhelpful to suggest adding code that will
have a diagnostic associated with it.

Change-Id: I2f8ad2d92ea0641e2212c89d01aa23921b39b3e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468401
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-16 07:17:29 -08:00
Jake Macdonald 42e7de8f6c add the ability to run a single scenario, fix results getter
Change-Id: I74e0e0ddb20a2182d4dc4f5e37ffb6c1925ee4f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468360
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-15 13:51:30 -08:00
Brian Wilkerson ba35276ae2 Add completion support for primary constructors
This adds completion support in the class header. Support for completion
in the body will be added in a separate CL.

Please look carefully at the tests to ensure that there aren't holes in
the coverage.

Change-Id: I189f25fbb90f43b4d8993622d5eb025d3160bef1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467920
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-15 11:31:17 -08:00
Sam Rawlins 13119ed91c DAS plugins: Fix race condition between plugin startup and a change in overlays
Fixes https://github.com/dart-lang/sdk/issues/62214

Danny describes the problem at a high level in https://github.com/dart-lang/sdk/issues/62214.

At a lower level, the issue is that we add the new `PluginIsolate` to
the `_pluginMap` as soon as we instantiate it! Before we've even made
the request to start it up. The `_pluginMap` is how PluginManager sends
out various requests, like watch events, priority files, and update
content.

The fix is easy enough: we wait to add the PluginIsolate to the `_pluginMap` until after we've awaited `PluginIsolate.start`.

Change-Id: I05e6314fde10fbaf4cf25b38b526c5cf96bd65ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467923
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-15 10:33:38 -08:00
FMorschel 3de6f28a1e [linter, DAS] Adds simplify_variable_pattern lint and fix
Fixes: https://github.com/dart-lang/sdk/issues/60518
Change-Id: Id02cc06a68c14bda578058e34050947253a888ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450421
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-11 11:15:11 -08:00
FMorschel 06fb7f25de [DAS] Makes Convert to wildcard fix apply automatically for unnecessary_underscores
Fixes: https://github.com/dart-lang/sdk/issues/61431
Change-Id: I83c2048f4fc46b99f6da151547c6c7e8637d998d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464880
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-10 10:58:32 -08:00
FMorschel 2cbcc7f37c [DAS] Fixes Create (extension) method for unresolved closure return type
Fixes: https://github.com/dart-lang/sdk/issues/61898
Change-Id: I0b1e7ad208a54a04f0ff4147f27403845f9a379d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459521
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-10 10:40:00 -08:00
FMorschel 420ac4d329 [DAS] Fixes completion for != for dot-shorthand
Fixes: https://github.com/dart-lang/sdk/issues/62216
Change-Id: I35e4884dd0d0db9a27b824ead4ea0232de8171dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467320
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-10 08:12:28 -08:00
Jake Macdonald dadbd93260 change the log file format to be newline separated objects
Change-Id: I2257b2af5e28ac50b47b9a6cfe688abb7c9e8ac1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466401
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2025-12-09 14:51:16 -08:00
Danny Tuppeny 33d3b5fc21 [analysis_server] Prevent invalid snippets in constant contexts
This splits `SnippetContext.inExpression` to also have `SnippetContext.inConstantExpression` and introduced `inEnumConstants` and `inEnumMembers` to allow snippets to appear in only one or the other.

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

Change-Id: Iefecb88177de9e209ed19513e28230ce1f3a7dd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467022
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-12-09 10:50:26 -08:00
Paul Berry ca7780c402 [messages] Use lower case diagnostic names in analysis_server.
Changes the logic in `pkg/analysis_server` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.

This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` and `DiagnosticCode.uniqueName` getters.

Change-Id: I6a6a69643ef19385ab43d7a04809e58305ca4f0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466185
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 06:25:01 -08:00
Konstantin Shcheglov 86463ec2ed DeCo. Build extension type constructor from PrimaryConstructorDeclaration, as for classes.
Align extension type primary constructor handling for classes.

Previously, extension types had a dedicated builder path that
synthesized their representation field and primary constructor from the
PrimaryConstructorDeclaration. This special-case handling meant:
- The constructor fragments for extension types were built differently
  from class constructors.
- Representation fields carried name/offset metadata that did not match
  how other declaring-parameter fields are modeled.
- Informative data encoded a separate representation block for extension
  types, adding custom binary format and read/write logic.

This change reuses the standard primary-constructor builder for
extension types, so their constructors and fields are produced the same
way as for classes. The representation field is now derived from the
first formal parameter in the shared builder logic, instead of via a
separate extension-type-specific helper.

Key changes:
- Route ExtensionTypeDeclaration.primaryConstructor through the general
  visitor path (`primaryConstructor.accept(this)`) and remove the
  extension-type-specific `_buildExtensionTypePrimaryConstructor`.
- Initialize extension type constructor fragments and declaring
  field fragments using the same flags as class primary constructors
  (isAugmentation, isConst, isPrimary, isDeclaring, typeName, etc.).
- Treat the first formal parameter of an extension type primary
  constructor as the representation parameter, even when it does not
  have `final`/`var`, and model the corresponding field as non-synthetic
  in that case.
- Drop the dedicated `_InfoExtensionTypeRepresentation` structure from
  informative data; extension type fields and constructors now use the
  standard field/constructor informative records.
- Adjust informative offsets so that representation fields use the
  extension type’s offset instead of the parameter’s offset, and update
  golden tests to expect `<null>` name/first-token offsets where the
  representation field does not own a standalone name token.
- Update refactoring and diagnostics to be robust when certain fragments
  do not have a name range or name offset by:
  - Guarding `fragmentName` with a null check before creating edits.
  - Using `originalFragment.offset` and `nonSynthetic.firstFragment.offset`
    instead of nameOffset in diagnostic locations.
- Make `FieldElementImpl.nonSynthetic` delegate to the declaring formal
  parameter when the field originates from a declaring parameter, so
  clients consistently land on a non-synthetic element for navigation and
  error reporting.
- Allow rename-class-member refactoring to consider extension type
  constructors when renaming fields by removing the special-case
  exclusion for `ExtensionTypeElement` implementors.

Together, these changes remove special-case representation handling for
extension types, make their primary constructors behave like class
primary constructors, and simplify both element and informative data
models while improving robustness of diagnostics and refactoring.

Change-Id: I50b069ebe8a3afc54e70184d9c395f06c2afa331
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466441
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-08 11:07:44 -08:00
Jake Macdonald 307948681c match up actual analysis server request ids
Change-Id: I20b67c18c6d531cd378c27cc3b73a1bbf3e6908a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2025-12-08 10:48:45 -08:00
Danny Tuppeny 1683dafa5f [analysis_server] Prevent "Switch expression" snippet showing up in dot shorthands
This gives them their own snippet context (which no existing snippets will match).

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

Change-Id: I2a6e75ebb41cdbbad000c94166317ce768735811
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466721
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-12-08 09:11:55 -08:00
Brian Wilkerson 18b93ca82c Add a warning for methods named factory
The primary constructors language feature changes the interpretation of
members of the form `factory() {}`. Before the feature that code defines
a method named `factory`, but with the feature enabled that now defines
a factory constructor.

This CL adds a warning that applies when the feature is not enabled that
tells users that methods named `factory`, when there is nothing before
the name of the method such as a return type, will no longer be
supported after the feature is enabled.

In addition, it associates a fix with the diagnostic in order to make it
easier for users to update their code in a way that will preserve the
semantics of the code after the feature is enabled.

I added the check in the `BestPracticesVerifier`, but that might not be
the best place for it. Please let me know if it should be moved.

Change-Id: Iff51d36975a914a4b1e3d9c2497cc23a1485c0b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466180
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-05 16:31:19 -08:00
FMorschel 9f4c7e5d8b [DAS] Fixes Create setters, getters and fields for using type parameters
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-05 10:32:55 -08:00
FMorschel eaf3d32b7d [DAS] Fixes dot-shorthands completion for enum constant creation
Fixes: https://github.com/dart-lang/sdk/issues/62168
Change-Id: I435835016e5c213deab3f9979dd554d06cd40fa6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466140
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-12-04 14:22:49 -08:00
Sam Rawlins 11effd9414 DAS: Use collection elements and null-aware elements in TreeWriter
This is not a slam dunk, and I can abandon this if it is not deemed
_more_ readable. Having a Map collection literal with a collection-if
and a spread map literal inside (`if (foo) ...{ ... }`) isn't the
most readable code.

I change a programmatic filling of Maps to be declarative, with Map
literals, collection elements like collection-if and collection-for.
In particular, I think the null-aware elements nicely indicate
nullable values, which might not be included in the Map. If something
doesn't appear in the Insights pages from these property maps, it is
more clear from the code that a value might be `null`, and might not
appear.

This simplifies the code all the way through `writeProperties` and
`writeProperty`, which previously considered `null` values, but now
only need to handle Objects.

Change-Id: I64ab32cebbb3ed0b69d3e4005b9ad2c843030636
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465988
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-04 11:28:22 -08:00
FMorschel 5b10311309 [DAS] Fixes completion for core function and suggestions of true/false
Fixes: https://github.com/dart-lang/sdk/issues/40703
Change-Id: Ib4fe7e11c95c3d5c199241aded12a041631a6d88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-04 11:27:49 -08:00
Danny Tuppeny ff5706e6c8 [analysis_server] Exclude the enum body semicolon from format-on-type
`EnumBody.semicolon` is the semicolon between the constants and other members. Since the formatter removes this semicolon if there's nothing after it, we can't have it trigger formatting or it will just immediately delete the semicolon you typed.

Fixes https://github.com/dart-lang/sdk/issues/61909
Fixes https://github.com/dart-lang/dart_style/issues/1782
Fixes https://github.com/Dart-Code/Dart-Code/issues/5602

Change-Id: I52bf113b832446da1b672d949d0fc3c2f6d018bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466101
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-04 09:28:07 -08:00
Sam Rawlins 1da50ff2a8 DAS: Collapse the ServerIsolateChannel class hierarchy
We stopped referencing BuiltInServerIsolateChannel a while ago, so the
only concrete subclass of ServerIsolateChannel was
DiscoveredServerIsolateChannel. This change removes the former class
and collapses the latter class into the parent class.

We also make `pluginUri` and `sessionLogger` private.

Also, `packagesUri` was referencing the old `.packages` files, which
are replaced with package config files, so we rename that field to
`_packageConfigUri`.

Change-Id: I93e2f4f10e14d832d85ea63382188019716b5de0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465985
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-04 09:10:41 -08:00
Danny Tuppeny 8473a6e53d [analysis_server] Prevent LSP format-on-type from formatting in unwanted cases
We register `}` and `;` as trigger characters for format-on-type, but some instances of these characters should not trigger formatting (for example in strings and comments).

With this change, we'll look at the AST and only format for specific cases we've opted in to, instead of all.

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

Change-Id: I94d348520649ea2e072f13350863f27a2e07699d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-04 09:04:29 -08:00
Sam Rawlins 73d463ca46 DAS: Tidy uses of isOriginDeclaration
Just some switch expression opportunities.

Change-Id: Ida87e1e65773bb5b481c40549a7b13c5605eade2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465967
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-03 16:36:59 -08:00
Konstantin Shcheglov a135929050 DeCo. Stop using isSynthetic in analysis_server/, analyzer_plugin/, linter/.
Change-Id: I0764ad0bde41d97a98d9eb5b088b50b4eb69155f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465982
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-03 14:42:54 -08:00
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