Commit Graph

7587 Commits

Author SHA1 Message Date
Brian Wilkerson 5b7fb2e8e8 Move and split the message scheduler
This CL makes three changes:
- moves the message scheduler into a new directory,
- splits the implementation into two files,
- and renames `MessageObject` to `ScheduledMessage`.

It does not make any semantic changes to the code.

The expectation is that we will need to make the message scheduler more
complex as part of improving the performance of the server, and that it
will be easier to do this if the code is structured differently.

Change-Id: I3f8741cadceb34c69fd45c1bf21f331d15824565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420500
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-04 10:39:51 -07:00
Sam Rawlins 6838dabc15 DAS: make add_null_check fixKind final
A few statements around the package read:

> Producers used in bulk fixes must not modify the FixKind during
> computation.

In fact, this `add_null_check` correction producer seems to be the
_only_ remaining producer that violates this statement. In order to
fix it, such that `fixKind` is set during constructor initialization,
we must do some poking around the AST.

So we convert `_computeTarget` to be static (and change it to also
compute and return any possible null-aware token, renaming it to
`_computeTargetAndNullAwareToken`). We also convert `_isNullAware` to
be static. Then the two public constructors are converted into
factory constructors that determine the fix kind, and store the
`_target` and `_nullAwareToken` in fields, so as to avoid re-computing
them during `compute()`.

Change-Id: Ic66319ef764dd9bd69f0e1059347acf174debb25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-03 23:51:44 -07:00
Brian Wilkerson 3cabc9a44f Minor cleanup in the message scheduler
Rename a couple of fields so that their purpose is more clear.

Enhance a few comments to record information I had to work to discover.

Change-Id: I9f9daa623ee4d2885d9831b59c40cccb7ab50ff7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420183
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-03 13:35:33 -07:00
FMorschel cc4c1ac367 [DAS] Go to Super handles field declarations
Fixes: https://github.com/dart-lang/sdk/issues/60465
Change-Id: I8b9e0231d3e7f6e7d9b75fdcf6b16311d470a7fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420120
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-04-03 09:46:58 -07:00
FMorschel 5d27e4f5bf [DAS] Fixes occurrences for extension and type parameters
Fixes: https://github.com/dart-lang/sdk/issues/60449
Change-Id: Ie862deea3d3d37890f1f610c7c83509fe82b2a40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419423
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-04-02 11:28:40 -07:00
Sam Rawlins 6253555a2c DAS: Only yield libraries that provide an extension member with a given name
The `DartFixContext.librariesWithExtensions` utility function accepts
a `memberName` parameter but never did anything with it. This change
adds filtering in that function based on the member name.

This code depends on the set of exported extensions, which is provided
in an extension (`LibraryElementExtensions.exportedExtensions`) in the
analysis_server package, which must be moved to the analyzer package.

Change-Id: I06c8a9a0e11ceb70e75517b30c0b048321d6b024
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418641
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-02 08:06:25 -07:00
FMorschel 42394e5874 [DAS] Better docs auto-complete with extensions and typedefs
Fixes: https://github.com/dart-lang/sdk/issues/60423
Change-Id: I0907a52a0c7787adc3de21c82bb60aced8263d2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419422
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-04-01 16:29:10 -07:00
Sam Rawlins e054ac0410 DAS: enforce non_constant_identifier_names
Change-Id: I83463db8edd76886edc635018f03e14880bb0607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417965
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-04-01 14:15:09 -07:00
pq fee42357d1 [diagnostics] track scheduler allowOverlappingHandlers
Follow-up from https://dart-review.googlesource.com/c/sdk/+/419340.

Adds `allowOverlappingHandlers` tracking to server diagnostics.

Change-Id: Ia7a909ae03754b8e3e98e76d232f1cc4f16d7bd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419481
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-01 11:27:40 -07:00
Danny Tuppeny 5e62d29bf5 [analysis_server] Add 'range' to EditableArguments response
See https://github.com/flutter/devtools/issues/9035

Change-Id: Ia2cadea05f10f16e00d1dbf0240b16761c0c6b0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-01 10:50:07 -07:00
Danny Tuppeny 21c0584631 [analysis_server] Allow allowOverlappingHandlers to be controlled via initializationOptions
For troubleshooting, this allows the client to override this flag.

I'd originally planned to use ClientConfiguration for this and allow it to be changed on-the-fly, however this can result in a mix of requests and therefore I decided it best to only support setting once during startup (which is part of initialization, and therefore before general requests start being sent).

This will require some Dart-Code work to provide a value here (and without a value, it will always be the servers default).

See https://github.com/dart-lang/sdk/issues/60440

Change-Id: Ie9843543d6d491afb046f3d1106211b7db852605
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419541
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-04-01 10:15:49 -07:00
Danny Tuppeny 0476f21604 [analysis_server] Mark editableArguments / editArgument as not-experimental
This should not be landed until after https://github.com/flutter/devtools/pull/8990 lands and is included in the version of DevTools in the Dart SDK.

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

Change-Id: I19a72ef0e3680aa620d47f8f9556e38b90a98aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-01 10:08:56 -07:00
pq 46699a91d0 [das] allow interleaved requests in the message scheduler
Includes a new `allowOverlappingHandlers` flag to support re-disablement as discussed w/ Danny.

Bug: https://github.com/dart-lang/sdk/issues/60440
Change-Id: I007f0276bf8cdbfd418ea5dacb251db3eef8dd3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-04-01 09:11:43 -07:00
Jens Johansen 9f42ef774e [analyzer] Add "interactive" option to "getResolvedUnit"; "setSubscriptions" are not; non-interactive ones have less priority
The legacy_many_files_in_flutter_set_subscriptions benchmark shows how
"flutter.setSubscriptions" calls can make the analyzer slower to
respond.

What happens is this:

* The user opens a new file in the IDE.
* The IDE sends the `flutter.setSubscriptions` request which equates to
  a call to `getResolvedUnit` for each file in the request. If this is,
  say, 300 files it's 300 calls to `getResolvedUnit`.
* The IDE sends a `edit.getAssists` request for the newly opened file.
  This request starts processing, reaches `getResolvedLibrary(file)`
  which calls `getUnitElement` ultimately adding the path to
  `_unitElementRequestedFiles` which in `performWork` is done _after_
  `_requestedFiles`, meaning it has to do all the flutter requested
  files first.
* The user might then request completion for instance, but because the
  analyzer only processes one request at a time it has to wait for the
  `edit.getAssists` request to finish first, which had to wait for the
  files from the `flutter.setSubscriptions` request to process.

All in all it's a lot of waiting for the user.

This CL adds a `interactive` option to the `getResolvedUnit` call. It
defaults to true in which case files are still added to
`_requestedFiles` and processed the same. If it's false it will instead
be added to a newly introduced list instead and processed at a lower
priority. Subscription requests are changed to pass `false` to
`interactive`, avoiding the scenario above.

Comparing before this CL with this CL on the
"legacy_many_files_in_flutter_set_subscriptions" benchmark with 100
files / CodeType.ImportChain these are the statistics on the changes
based on 5 runs each:

```
Completion after open of new file: -81.6652% +/- 7.7564% (-3.70 +/- 0.35) (4.53 -> 0.83)
getAssists call: -96.6315% +/- 0.9307% (-3.61 +/- 0.03) (3.74 -> 0.13)
peak virtual memory size: -5.6786% +/- 3.2964% (-139.00 +/- 80.69) (2447.80 -> 2308.80)
total program size (virtual): -4.6387% +/- 3.8146% (-110.80 +/- 91.11) (2388.60 -> 2277.80)
```

Even when https://github.com/flutter/flutter-intellij/issues/7980 is
hopefully fixed I think it is a fair change to de-prioritize a
non-interactive request.

Change-Id: Icba2faebf12f9913cf24db7cb90fdc6f4c74164e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-04-01 00:56:39 -07:00
Sam Rawlins 59fee86145 DAS: Rearrange code to promote variables better
The motivation here was to remove the local duplicate variables like
`final_foo` or `foo_final`. These variables only existed because the
variables they duplicate lose their promoted types inside the
`builder.addDartFileEdit` closure. They lose their promoted type
because they are multiply assigned in loops or not always promoted to
be non-null.

Often the fix is to replace a `if (x == null) return` with
`} else { return; }`. I think this code more directly represents the
flow of code, rather than relying on the nullity of a variable, like
"is this variable still null? Oh then we must not have entered any
of the situations above, so we should return."

Change-Id: I9dd6686b7f4d9c6caf59c171179b129a5a957ba8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418160
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-31 09:23:29 -07:00
Sam Rawlins b0c3f4ef1f DAS plugins: Move two files to be in the public API
Change-Id: I7230dead69b8c82ea758e48a0a3fbc56902cb05d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417945
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-28 13:09:21 -07:00
Sam Rawlins 440c93ae64 DAS: Rearrange code to promote variables better
The motivation here was to remove the local duplicate variables,
`isEmptyIdentifier_final`, `context_final`, and `returnType_final`.
These variables only existed because the variables they
duplicate lose their promoted types inside the `builder.addDartFileEdit`
closure. They lose their promoted type because they are multiply
assigned.

This CL simplifies each method by taking advantage of early returns
and implicit late assignment.

Change-Id: I81ff248d97e875a5b75c7d20b8e95f1b0c08ea24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417701
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-28 12:15:07 -07:00
Danny Tuppeny 352c1d29c1 [analysis_server] Allow clients to provide diagnostic information to be included in the report
See https://github.com/dart-lang/sdk/issues/60259, though this still requires the related client changes.

Change-Id: I6a9419780b9d4c4b0c7a9518098c69e1609262b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418100
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-03-28 10:56:44 -07:00
pq 6acab30e25 [analytics] validate lintUsage reporting for multiple options files
Change-Id: I6d6bbcc14d80fc670e134a8fa84f0ef42d17b3f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418440
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-28 10:16:20 -07:00
Sam Rawlins ba093a079d DAS: Rearrange code to promote variables better
The motivation here was to remove the local duplicate variable,
`final_propertiesBuilderName`. This variable only existed because the
variable it duplicates loses its promoted type inside the `builder.addDartFileEdit` closure. It loses its promoted type because
it is multiply assigned in a for loop.

This CL extracts a portion of the `compute()` method, which is solely
concerned with computing the real "target". The diff looks large
because of how that portion is moved into a helper method that is
_below_ `compute()`.

I think each of these changes then improves readability: extracting
part of a 180-line long method into one helper, and avoiding a local
duplicate variable.

Change-Id: I96b6ccdbd627d3cf3cc4b7f7bbcba7ee5dd9a561
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417700
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-27 13:56:07 -07:00
Danny Tuppeny f9bf821043 [analysis_server] Don't include expressions/getters in inline values for the current line
For convenience, we usually include Inline Values for the "current" line so that when stopped at an `if` statement, you can see their values:

```
if (foo == 1) {      // [foo = 2]
```

We have an experiment that includes inline values for getters (since although they can have side-effects, users tend to expect to see them in debug views, especially when the getter/setter are implicit), but triggering them before the code ever would have may be more unexpected.

This change uses two different ranges so that only variables are included for the current line.

Change-Id: I19a129a28f7b5296281dbee139855c738cd37194
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418340
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-27 11:17:12 -07:00
FMorschel 8bf801f8f7 [DAS] Fixes pattern variable with multiple declarations highlight
Bug: https://github.com/dart-lang/sdk/issues/60398
Change-Id: Ifd7c29db38bb2ee048d2b7d0de1e050e1e3e9bc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417964
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-27 11:09:09 -07:00
pq cbe2793d3a [analytics] stop collecting context creation style data
Bug: https://github.com/dart-lang/sdk/issues/60411
Change-Id: I987557393cfc1b92b5d00467f5aedc9674eba07c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417946
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-27 10:37:15 -07:00
Sam Rawlins b3e725c54d DAS: Rearrange code to promote variables better
The motivation here was to remove the local duplicate variable,
`node_final`. This variable only existed because the variable it
duplicates loses its promoted type inside the `builder.addDartFileEdit`
closure. It lose its promoted type because they are multiply assigned
in a while loop.

This CL extracts the first portion of the `compute()` method, which
is solely concerned with computing the real "target". The diff looks
large because of how that portion is moved into a helper method that
is _below_ the second half of `compute()`.

I think each of these changes then improves readability: extracting
part of a 140-line long method into one helper, and avoiding a local
duplicate variable.

Change-Id: Ic209e4be49863657f969eadf909ab05d13e9a254
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417680
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-25 15:36:02 -07:00
Sam Rawlins ff75aeb6af DAS plugins: Support assists in plugins
To support this feature:

* Remove `DartAssistContextImpl` as it has no differences from
  `DartAssistContext`. Thus the getters `DartAssistContext` are made
  into fields, and all callers now call `DartAssistContext()`.
* Add a top level `computeAssists` function, similar to the top-level
  `computeFixes` function.

Change-Id: I3ef5fd9ee9430150004b29c11ab972939b85b214
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-25 15:27:59 -07:00
FMorschel dc2b368732 [DAS] Fixes refactor rename wrong conflict error
Fixes: https://github.com/dart-lang/sdk/issues/60315
Change-Id: I1974580be8805dd83c9d2895860fb6eed825ccca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415941
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-25 13:50:32 -07:00
Konstantin Shcheglov 92c29f447a Elements. Remove VariableDeclarationImpl.type
Change-Id: I9b184b6ff2ff18500693e5f8edc82a013b7ba37a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417860
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-25 10:12:09 -07:00
FMorschel 0a2ef5c54a [DAS] Reviews both fixes for discaded_futures
Bug: https://github.com/dart-lang/sdk/issues/59887
Change-Id: I04fe23275435249be3533649d1c276c7afe8ee4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-25 10:07:09 -07:00
Sam Rawlins ab909226e3 analyzer: simplify updateAnalysisOptions parameter signature
Currently, the `AnalysisContextCollectionImpl` constructor has a
callback parameter, `updateAnalysisOptions2`, which has 3 required
parameters. The caller can then pass in a closure which accepts those
parameters, and updates analysis options.

I find this to be a bit of an awkward API, and a little bit complex, so
it would be good if we can simplify it. It is all private impl, but it
is used in a few codebases, I believe. Dartdoc is one.

So, it looked to me like none of the callers _use_ the `ContextRoot`
parameter, so it would be good to simplify here, and remove it from
the callback signature.

This is _not_ the final API I'm looking for. Just an incremental step,
and since it is private API, it doesn't need to be in a major release
of analyzer.

Change-Id: Iad9da9f36e817add0bd8c49975ecd14311588661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392204
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-03-24 10:31:23 -07:00
Sam Rawlins 8e874a30fc DAS: Rearrange code to promote variables better
The motivation here was to remove the local duplicate variables,
`isExpression_final` and `binary_final`. This variables only existed
because the variables they duplicate lose their promoted types inside
the `builder.addDartFileEdit` closure. They lose their promoted types
because they are multiply assigned.

This CL extracts the first portion of each `compute()` method, which
is solely concerned with computing the real "target". The diff looks
large because of how that portion is moved into a helper method that
is _below_ the second half of `compute()`.

I think each of these changes then improves readability: extracting
part of a long method into one helper, and avoiding a local duplicate
variable.

Change-Id: I6919b04a39dfc02f3b2f7b74727d3f576c71d37b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417022
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-24 09:18:54 -07:00
Sam Rawlins 4499427b60 DAS: convert_add_all_to_spread - Rearrange code to promote variables better
In this one, we can extract out the `elementText` computation so that
it is assigned once, and we can avoid duplication with the
`elementText_final` variable.

Change-Id: I62e54835e36d1a896589e4e9b69ce6ea1fea4370
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416885
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-21 10:50:30 -07:00
pq ae6da8b926 [analytics] performance tracking for getRefactorings (LSP)
Bug: https://github.com/dart-lang/sdk/issues/60258
Change-Id: I3e2f07f2ea7f02f247fac62768a45a247296ebd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417082
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-20 19:32:51 -07:00
Sam Rawlins b03e7c75f1 DAS: add_null_check - Rearrange code to promote variables better
The motivation here was to remove the local duplicate variable,
`target_final`. This variable only existed because the variable it
duplicates, `target`, loses its promoted type inside the
`builder.addDartFileEdit` closure. It loses it's promoted type because
it is assigned late.

This CL extracts the first ~60 lines of the `compute()` method, which
is solely concerned with computing the real "target". The diff looks
large because of how the first ~60 lines of `compute()` is moved into
a helper method that is _below_ the second half of `compute()`.

I think each of these changes then improves readability: extracting
part of a 170-line long method into one helper, and avoiding a local
duplicate variable.

Change-Id: I20e2eb3479f53810d4dfcab9b88ebacb446e0f62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416884
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-20 09:25:02 -07:00
Sam Rawlins d3adf41b9a DAS: reformat
Recently a bug was fixed in the formatter, regarding how declarations
preceded by an end-of-line comment are formatted. Good to just bundle
the formatting changes into one CL.

Change-Id: Ieab8ec3263932505f8b8da77fbe637dffc61b46d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-20 09:18:54 -07:00
Sam Rawlins 5d1f4876ee DAS: Fix many non_constant_identifier_names violations
This lint rule is a core lint rule; we have suppressed it only for
pre-existing code reasons.

There are a few individual files which simply have a consistent pattern
of including underscores in some names, so I add inline ignores there.

Change-Id: I89e6010203868fc10fda12b15353de41881d9b15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-20 09:00:06 -07:00
Sam Rawlins 3a709844b2 DAS: In the 'add cast' fix, tidy and take better advantage of promotion
The motivation here was to remove the local duplicate variable,
`target_final`. This variable only existed because the variable it
duplicates, `target`, loses its promoted type inside the
`builder.addDartFileEdit` closure. It loses it's promoted type because
it is multiply assigned.

This CL extracts the first half of the `compute()` method, which is
solely concerned with computing the real "target" and "from type" and
"to type" into a separate method. The diff looks large because of how
the first half of `compute()` is moved into a helper method that is
_below_ the second half of `compute()`.

I think each of these changes then improves readability: extracting
part of a 140-line long method into one helper, and avoiding a local
duplicate variable.

Change-Id: I543bf39e17f0e44011da8741b5f12380e1425f3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416883
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-20 07:58:52 -07:00
Danny Tuppeny 57cd03d400 [analysis_server] Immediately return null for getEditableArgs of non-Dart files
See https://github.com/flutter/devtools/issues/9048

Change-Id: I5edb446cbda6f9a4222f2aca8dfd72ccbf334287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-03-20 07:40:04 -07:00
Danny Tuppeny f6cf08b898 [analysis_server] Use a static identifier for plugin-supplied fixes/assists
Change-Id: Ifc6310aabe60a8c5671203b66b11fe98e0c5cbbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416800
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-19 16:17:56 -07:00
FMorschel 77961aec08 [DAS] Adds fix for multiple_combinators warning
Bug: https://github.com/dart-lang/sdk/issues/56879
Fixes: https://github.com/dart-lang/sdk/issues/60309

Change-Id: Ifac77bbcb0d22c96cc01ea12fba1af86721809e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414800
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-19 14:17:01 -07:00
Sam Rawlins 331c700f33 DAS plugins: Move Assist code to analysis_server_plugin package
The PluginServer class needs access to AssistProcessor in order to
compute assists. That class needs access to a few other classes, which
then must also be moved:

* assist_core.dart - the Assist class
* assist_dart.dart - the DartAssistContext class
* assist_generators.dart - the registeredAssistGenerators variable
* assist_performance.dart - the AssistPerformance and
  GetAssistsPerformance classes
* assist_processor.dart - the AssistProcessor class with it's
  singular API, `compute()`
* performance.dart - the ProducerRequestPerformance class
* the `addCaretAtOffset` helper function, refactored into a
  `withCaretAt` extension method

This change is functionally a no-op.

Change-Id: Ic883d21e9cc8c3db1f6093f830f01ec6eb9a0976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416680
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-19 13:44:51 -07:00
Konstantin Shcheglov ba7314467d Elements. Migrate src/error/inheritance_override.dart
Change-Id: I8080c6dd961ad92c983c3b53cd048bbbe31f822b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-03-18 10:06:32 -07:00
Sam Rawlins 641ec4c515 DAS: report exceptions caught in plugin isolate as plugin exceptions
This change means that during `dart analyze`, an exception caught in a plugin isolate will be printed to the terminal, and the process will
exit (similar to the support for when the isolate has static errors).

Change-Id: I31b1ebe7a71a331274d4f1dc1ea1b94f33e2329b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415981
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-18 10:03:22 -07:00
FMorschel 3369bebde2 [DAS] Refactors all wrap with builders to the same implementation
R=pquitslund@google.com

Fixes: https://github.com/dart-lang/sdk/issues/60075
Change-Id: I177830361f080e11321f8bd0c85929ab9b3871ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408860
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-03-18 09:31:33 -07:00
Danny Tuppeny d0c9fcb2b6 [analysis_server] Exclude obvious Enum value access from Inline Values
Fixes https://github.com/Dart-Code/Dart-Code/issues/5444

Change-Id: I92bf301236e97682269e2284f2602ceb5f83619f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415861
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-17 14:54:06 -07:00
Konstantin Shcheglov bb676ba1f5 Elements. ElementImpl is not Element2.
Change-Id: Ia8885018d3e23875e53dfa0d3cf470bdd28eef29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-03-17 08:46:49 -07:00
Konstantin Shcheglov dc3ecf2dec Elements. Finish remaining analyzer_use_new_elements in DAS.
Change-Id: I37847bebf81da99d30c006f4d4dfd95805eada11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415820
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-03-17 08:30:02 -07:00
Sam Rawlins 3fb52b7f44 DAS: Un-cache the assist lint rule map when registering new generators
This fixes running
`dart --enable-asserts pkg/analysis_server/test/test_all.dart`.

Change-Id: I50aef9e2d2f073ac8917b3f97dcfc0cddc0290c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-14 14:06:44 -07:00
Sam Rawlins 7c646390c2 DAS: Simplify the storage of the fix mappings for assists
This map is a map of _assists_ and the lint rules that can _fix_, when
used as a _fix_ producer. A rather specific set of information. It was
being passed around everywhere, but now with the instance of
`_RegisteredAssistGenerators` to hang onto, we can leave the map there,
and remove it from a handful of other classes which all ultimately just
passed the map back to AssistProcessor.

Change-Id: Ib2aa4ea1fdb23bbaf55b3377232f2205b7f91447
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415460
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-14 10:48:34 -07:00
FMorschel fcf79e06ce [DAS] Adds working rename when shadowing global variable is assigned
R=srawlins@google.com

Bug: https://github.com/dart-lang/sdk/issues/59954
Change-Id: I39417d9e712a40b6992fbad86180c257e782e04a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414200
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-03-14 07:38:48 -07:00
pq a098bf3dae [analytics] performance tracking for getAssists
Bug: https://github.com/dart-lang/sdk/issues/60258
Change-Id: Iffc42602680786b93de877fb581fb8248a970c8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414826
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-03-14 07:28:09 -07:00