Commit Graph

10929 Commits

Author SHA1 Message Date
Danny Tuppeny f300269d0c [analysis_server] Exclude NameWithTypeParameters from selection ranges
This makes things more consistent between class/mixin (that have different ASTs) but also avoids jumping to the name+type args which probably isn't what you'd expect.

Change-Id: Ibd5e2a9b332c4c214ccc753080a61b1222445485
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-24 10:20:30 -07:00
Danny Tuppeny c1ebd226ea [analysis_server] Mark the dart.lineInfo setting as deprecated in LSP docs
This should be set in `analysis_options.yaml` now (since it applies to all IDEs and CLI invocations of tools). I've also marked this as a legacy setting in Dart-Code.

See https://github.com/Dart-Code/Dart-Code/issues/5943.

Change-Id: Ief585c08f1986afc2ddc40bc66b921bc368139a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489942
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-23 14:35:20 -07:00
Danny Tuppeny 88bbb2c09b [analysis_server] Add tests for empty bodies in LSP SelectionRanges
Change-Id: I0bbd45277e942bdfabcdc1e1737f2cef048a1269
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489961
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-23 14:00:09 -07:00
Danny Tuppeny 0b5a913de8 [analysis_server] Add Document Symbol + Outline tests with empty bodies
Change-Id: I77e901475c802dc4649ec09097618f2e5787fb7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-23 07:32:44 -07:00
Ben Konyi 2a83a78213 [ DAS ] Add initial support for widget preview detection service
The Flutter Widget Preview feature is currently implemented within
Flutter Tools, which is responsible for detecting widget preview
annotations in the user's project. When previews are detected, the
Flutter Tool injects code generated based on the detected previews into an artificial widget_preview_scaffold project and performs a hot reload to render updates to the preview set in the scaffold application.

`package:analyzer` is currently being used to detect previews, but this comes with a significant amount of memory overhead. Since widget
previews are mostly being used from within IDEs which already have an
active analysis server, moving widget preview detection into the DAS
will remove the need for creating an additional analysis context in the Flutter Tool itself.

This change includes the initial work to move widget preview detection
into the DAS. It utilizes a pull-based mechanism, where the Flutter Tool listens for file system events and then queries the DAS using the `dart/textDocument/getFlutterWidgetPreviews` and `dart/workspace/getFlutterWidgetPreviews` LSP methods.

Each reported preview contains some generated code based on the annotation used to define the preview. This code has all constants from the original annotation evaluated to either primitive values or constant expressions with namespaces applied to each symbol, allowing for the Flutter Tool to inject this code directly when updating the generated code in the scaffold project.

Towards https://github.com/flutter/flutter/issues/179584

Change-Id: I043cb3235a66b25dda3f852ca7f147bff0e1e537
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478100
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-03-22 19:19:03 -07:00
Lasse R.H. Nielsen 56505e0575 Stop using Match.group.
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)

Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-20 09:09:46 -07:00
D.ildo 7cad9ad43d #62878 quick fix incorrectly treats positional arguments
Closes https://github.com/dart-lang/sdk/pull/62921

GitOrigin-RevId: 5f21333b6fc53b56897ab2a83e9aa8638911a56a
Change-Id: Ie24702e8e7b1eda21b34f9972f02fd94387dc1f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488525
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-20 07:51:50 -07:00
Danny Tuppeny a5506417da [analysis_server] Fix a flaky diagnostics test
The test has become flaky for me recently. I believe the issue is that analysis is completing too quickly and `waitForAnalysisComplete()` starts waiting for a future analysis that never comes.

Change-Id: Ie76dffd3fbaef50eb27d5fc9692131d38553d4b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-19 17:58:11 -07:00
Danny Tuppeny 32379cbeae [analysis_server] Add tests for move-params-left refactor for Primary Constructors
Change-Id: I48ada3209032f40d1c9ca7de9b41699fae8ab8a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-19 14:18:30 -07:00
Danny Tuppeny a772b97058 [analysis_server] Support primary constructors and new/factory in Convert Parameters to Named refactor
Change-Id: Id78b372f9b345cb287214d008b43d8a20ce3cbcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485822
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-03-19 13:39:06 -07:00
Brian Wilkerson 8d15d9ffaf Update rename to work for primary constructors
We don't appear to have any end-to-end tests of the rename refactor (and
maybe not of other legacy refactors). We need to fix that, but that's a
bigger task than I want to include in this CL. For now I've locally built
and tested the rename on a primary constructor and verified that it
works as expected.

Change-Id: Icec20f3204c58fa219ff7df117511ed47629bd1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489120
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-19 10:17:01 -07:00
Sam Rawlins 2038706fbd analyzer: Refactor ContextLocatorImpl's entrypoint
The broad idea here is that ContextLocatorImpl was not so much a
_class_ as a collection of functions with
`ContextLocatorImpl.locateRoots` as an entrypoint. This "class" had one
field (a ResourceProvider), and one public method. That public method
was 220 lines long (inscrutable to me). That method was then forced to
pass around a handful of objects to all of the internal methods, which
were all computed in `locateRoots`, and not mutated afterwards.

Secondly, `Workspace.createSourceFactory(null, null)` was called in a
half dozen positions. In order to wire up a caching mechanism, and for
tidiness, and to satisfy a TODO, we add a late final field on Workspace
for retrieving a "partial source factory."

So, the change is to make a new top-level function,
`locateContextRoots`, which does some pre-computing, instantiates a
_ContextLocator with 4 pieces of data, and calls it's `locateRoots`
method, returning the result. In extracting this pre-computing code, a
few helper functions also had to be extracted into top-level functions:
* `_resourcesFromPaths`
* `_uniqueSortedPaths`

Otherwise, the code is mostly in-tact. I made a few small cleanups to
improve readability here and there, where I was already making changes:

* In `_createContextRootsIn`, there was a giant try-catch (which was
  very deep as well, try/for/if/if), but the catch was only there to
  catch something thrown from the _first_ statement. So I shrunk the
  size of the try-catch.
* Similarly, `_getExcludedGlobs` has a if/try/if/if/local-function that
  I simplified a little.
* `_locateRoots` was renamed to `_locateRoots`, and so is sorted
  different; it remains mostly intact, but is now only 140 lines,
  reduced via the pre-computing code moved to `locateContextRoots`.

Change-Id: I9f95bbddd546d55b206c77112247c1a6bc770626
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488940
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-19 10:09:18 -07:00
pq 6cb842ed05 [analytics] process and propagate analytics ENV context
Fixes: https://github.com/dart-lang/sdk/issues/62875

Bug: https://github.com/dart-lang/sdk/issues/62875
Change-Id: I864c2fb401dd2eb9859b1277ea971db758ace618
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2026-03-18 14:30:09 -07:00
Brian Wilkerson daa9b8e31b Refactor RenameConstructor to use a ChangeBuilder
In order to support primary constructors we need to have two new
refactors that will add and remove a constructor name. Rather than
duplicate the logic in the RenameConstructor class, I want to reuse it.
In order to do that, I need to be able to pass in a ChangeBuilder.

This CL accomplishes that goal by making it possible to pass in a
ChangeBuilder to any refactoring, even though in most cases the
ChangeBuilder will be ignored. In the future I intend that all of the
refactors will be updated to use the passed in ChangeBuilder, but that
would have been too big for a single CL.

Beyond that, I did make one other change, which is that the refactor
now supports classes with an empty body (`;`). I added a test for the
new functionality, but I believe that the existing tests should be
adequate to ensure that there was no loss of functionality.

This does not add support to RenameConstructor to deal with primary
constructors. That will also happen in a follow-on CL.

Change-Id: I51749e9cd1d775744dc6e64c1dc67967ef492d45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488527
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-17 14:26:21 -07:00
Brian Wilkerson e29caa8e9d Fix the handling of newlines in addSuperConstructorInvocation
This should also fix the windows bot.

Change-Id: I0d3b80c8ad0ecb0b84672cdea19a90c651596d2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488520
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-17 09:38:59 -07:00
Danny Tuppeny 811849dd1e [analysis_server] Fix LineInfo used in Type Hierarchy
This fixes the LineInfo used for type hierarchy, no longer assuming that the Element is in the same file where Type Hierarchy was invoked.

It also removes some of the fetching of LineInfos for files and caching them, since we can now access the LineInfo from a LibraryFragment much more easily.

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

Change-Id: I3dd3527cf4afb9ae3171b90def02452d04ffa9c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488481
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-17 08:49:50 -07:00
Konstantin Shcheglov e655e9fd6c DeCo. Add ClassBody.members, EnumBody.constants, EnumBody.members
Add `ClassBody.members` and `EnumBody.constants`/`members` so callers
can access class and enum contents through the common body interfaces
instead of pattern matching on `BlockClassBody` and `BlockEnumBody`.

Implement empty node lists for empty class and enum bodies, update the
public API, and migrate analyzer, analysis_server, analyzer_plugin, and
linter code to use the new accessors directly. This removes the ad hoc
`members2` helper extensions and a large amount of repeated `tryCast`
and `switch` logic, making body traversal more uniform.

Change-Id: I51d75f2253c7e6f75efecae84bf0443ff5eb6788
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-16 19:29:20 -07:00
Brian Wilkerson c457ab141d Update addSuperConstructorInvocation for primary constructors
We need to think about utilities we can add to `ChangeBuilder` to make
this kind of edit easier. I thought about an `addInitializer` utility,
but wasn't sure it would have other uses. I also thought about an
`addMember`, which would probably be good, but not for this use case.
More thinking is probably needed.

Change-Id: Ie30d9f4a47007b03b22a290e2ba6c72f3c5423bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488361
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-16 16:12:35 -07:00
Sam Rawlins 7d0a17196c DAS plugins: Add print-debugging support in Insights pages.
Work towards https://github.com/dart-lang/sdk/issues/61868

This adds a new notification type, 'PluginPrint'. There are several
fields and variables then named 'pluginPrint' or 'print', and I am
definitely open to changing these names, but this is the best one that
I thought of.

PluginPrint has three fields: The name of the plugin that printed, the
message that was printed, and the timestamp.

We wrap each plugin's AnalysisRule invocations with a zone, so that
the `print` handler can know the name of the plugin. The prints are
caught and sent to the server isolate as Notifications. The
PluginIsolate then stores the collected prints. The Plugins Insights
page can then retrieve them and display them.

Manual testing, with 1000 libraries that get new lint reported once per
file, I did not observe a negative performance impact.

Change-Id: Id800ae41781c15ce89d06b563878c2b0edae43d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486827
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-16 14:56:59 -07:00
Brian Wilkerson aa77bd2d21 Update the addMissingParameterNamed fix for primary constructors
This required updating some utility methods used by the fix. I'm not
sure what other code that effects.

Change-Id: If0c1df36847d4a319624252f63901af18c7fafe4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-16 11:28:00 -07:00
Konstantin Shcheglov e9d8109258 DeCo. Support empty bodies in membered declarations
Allow enums, extensions, and mixins to use `;` as their body and
represent that form explicitly in the AST. The parser now produces
`EmptyEnumBody` or `EmptyClassBody` for the empty form.

Also replace `LibraryIdentifier` with token-based `DottedName` and store
the full token sequence for dotted names. This preserves periods and
source offsets directly in the AST, which keeps printing, selection, and
directive name handling working with the new shape. See
https://github.com/dart-lang/sdk/issues/62819

See https://github.com/dart-lang/language/issues/4645

Google3 presubmit looks green:
https://fusion2.corp.google.com/presubmit/884063020/OCL:884063020:BASE:884079610:1773618867493:b2110d76

Change-Id: I2d023cd03b6423da634c3e14742e02a61dc3b403
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-16 08:56:11 -07:00
Danny Tuppeny 87e0fea473 [analysis_server] Don't let format errors fail change building
Some refactors try to format their code, but formatting can fail if there is a parse error anywhere in the file (including in completely unrelated code). This change catches formatting errors and ignores them, so the refactors will continue to work in that case (albeit without formatting).

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

Change-Id: Ia3c3769640314557191244393ab8c1bd38dc2fdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487841
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-14 07:27:50 -07:00
Sam Rawlins 89d370c89c DAS insights: Linkify more files to their contents
The main piece to this CL is to add more links in the diagnostics pages.
We add links to pubspec files in a context, and to the generated package
config files for plugins.

I also rename `writeOption` to `formatOption` as it doesn't actually
write (it just returns a String).

I also fix a few small UX issues:

* Contents page titles should break on slashes, so I just updated all
  page titles to break on slashes.
* A small bug where a context with zero library cycles of size > 1
  display the text "They contain" and then no more text.

Change-Id: I7c505b006872e70884bf4c59a34e0625c7663a6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487946
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-13 18:37:29 -07:00
Danny Tuppeny 7bd7595cfa [analysis_server] Use the minimum of SDK language version and formatter version for formatting
This allows the formatter to be both ahead or behind the SDK version and still format correctly. We should not use a newer language version than the SDK is using, and we cannot use a newer version than the formatter supports.

Change-Id: I5ef27363d213f570b2eb0d3b428752aef8e76af1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487580
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-13 14:42:03 -07:00
Paul Berry acca99ef86 Fix SDK constraints in analysis_server, front_end, and kernel.
Yesterday I bumped the SDK constraints for these packages to 3.12.0
(see https://dart-review.googlesource.com/c/sdk/+/487521 and
https://dart-review.googlesource.com/c/sdk/+/487542). Today I realized
that this makes a pub solve impossible, since Dart version 3.12.0
hasn't been published yet. That in turn prevents unit tests from being
run in the VSCode IDE.

Changing the SDK constraints to `3.12.0-0` fixes the problem, allowing
the tests to be run under any unreleased version of 3.12.0.

Change-Id: Ia018558dafae9dc958b2b39d19ec1e1d6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-13 07:45:41 -07:00
Jens Johansen 2849d34c7c [analyzer] Replace regex in ignore_info with normal code
The RegEx engine in the VM was updated in
e443b89f23 which caused the analyzer
analyzing the CFE to use ~150 mio instructions more.

Part of this was an increased cost in ignore comment processing which
relied on regex. Using regex before the updated engine made
`processPrecedingComments` have a cost of ~240 mio instructions,
updating the regex engine took that to ~264 mio instructions.

This CL gets rid of the regex and takes the cost of
`processPrecedingComments` to ~74.4 mio instructions a saving of about
189 mio instructions (all then analyzing the CFE and looking at output
from `valgrind --tool=callgrind`).

Benchmarking with `perf stat` with normal GC gives:

```
task-clock:u: -2.1760% +/- 1.6063% (-265608341.80 +/- 196062087.98) (12206056036.20 -> 11940447694.40)
page-faults:u: 0.2301% +/- 0.0313% (448.20 +/- 60.88) (194764.60 -> 195212.80)
cycles:u: -2.2906% +/- 1.6090% (-1180119481.60 +/- 828994273.75) (51521138476.00 -> 50341018994.40)
instructions:u: -0.3325% +/- 0.0032% (-196547942.60 +/- 1874215.18) (59120651337.60 -> 58924103395.00)
seconds time elapsed: -2.1715% +/- 1.6011% (-0.27 +/- 0.20) (12.21 -> 11.95)
seconds user: -2.2487% +/- 1.7816% (-0.27 +/- 0.21) (11.87 -> 11.60)

Comparing GC data:
'No' GC change.
```

Note that it must push the GC - the savings isn't really 2% in time.

And with GC disabled:

```
instructions:u: -0.4562% +/- 0.0029% (-185499444.00 +/- 1189012.77) (40663084597.80 -> 40477585153.80)
```

So here a saving of ~185 mio which fits okay with the data from
valgrind.

Change-Id: Ib203baeac6a93f5e37c737080fed342dbd0740a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487021
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-13 02:43:23 -07:00
Paul Berry 07b214eef5 Bump analysis server to language version 3.12.
Also start using the "private named parameters" feature.

Change-Id: I1c6da5f8ae2985e12313d405a2eb419c6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487521
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-12 14:18:11 -07:00
Brian Wilkerson 87a0f2e3af Add some design docs related to refactors
The question was raised recently about whether refactors should change
the semantics of the code, and if so under what conditions. There aren't
any hard-and-fast rules, but I wanted to capture the criteria I believe
we've generally used when making this decision.

Let me know if you think I've missed, or misrepresented, something.

Change-Id: I2d02dc35aa17386ff2ae8aa73ff0dc1271170ba4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487220
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-12 11:15:00 -07:00
Brian Wilkerson b54f4b718e Support primary constructors for the addKeyToConstructors fix
Change-Id: I74a07d76c4e874dd1cc2ecaffe0f6a5a994a746e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487221
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-12 08:57:25 -07:00
Brian Wilkerson 7fe34af78c Capture a decision about highlighting new
We made a decision about how to handle the `new` keyword in various
locations, and I thought it would be good to capture that decision.

Change-Id: I28373128955444dc09ad44c3fdab209020cc0bc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487180
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-11 12:02:22 -07:00
Sam Rawlins cd31d6e158 DAS: Update tutorial text to use the word "insights"
Also add a bare minimum of documentation for the plugin pages.

Also correct some removed and added pages, all with TODOs.

Change-Id: I5ca48c9013c47f6fc925c1da1c44055d3884448b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487081
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-11 10:37:49 -07:00
Sam Rawlins 6bf0941fb3 DAS: Wrap comment shorter than 80 characters
Change-Id: Ibdc21d53aae6b6b5d3e406e4e00eb8f3c9453931
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487100
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2026-03-11 09:42:00 -07:00
Danny Tuppeny 4a4658e014 [analysis_server] Pass experiments through to formatter
This passes any experiments that are both enabled, and marked as "future" through to the formatter.

I extracted most uses of the formatter to use the same shared `createFormatter()` helper that sets the appropriate values. Those that didn't already have a Result to pass I added TODOs to (though one is g3 so probably would require some internal migration).

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

Change-Id: I8f4ef4242614dc240e217cdaf99105f2a5b49dc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-10 12:46:31 -07:00
Sam Rawlins fe0afebf55 DAS session logger: Normalize paths as log entries are written.
This copies much of the logic from the normalize.dart standalone script.
It normalizes "workspace folders," context roots, and the Dart SDK path.

I tweaked the SessionLogger constructor to instantiate its own
`SessionLoggerInMemorySink` rather than the caller needing to call it.

And then the `SessionLoggerInMemorySink` instantiates the
`SessionLoggerFileSink` so that the caller doesn't need to worry about that. This lets the sink and the nextLogger each be final, and removes
details about what I consider "SessionLogger implementation details"
from the caller's concern.

When a SessionLogger is instantiated, it creates a LogNormalizer which
the SessionLoggerSinks use to normalize log entries.

I almost used
`WorkspacePackage.packagesAvailableTo(String libraryPath)`, but it
seemed unnecessary to require a file path (there is a TODO about
considering files in/out of the 'lib' folder, but not necessary for this
work). So I made `Workspace.packages`, as most of the subclasses
already implemented this concept.

Bug: https://github.com/dart-lang/sdk/issues/62697
Change-Id: Ic57fec490414cef7028c290614363623e88f5c15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485260
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-03-10 11:29:06 -07:00
Brian Wilkerson 282f109ddf Add another fix for invalidCovariantModifierInPrimaryConstructor
This adds a fix to replace the `final` with `var` in cases where the
defined field needs to be covariant because it overrides an inherited
member.

Change-Id: I2dc57253beedb89ce942ba38e7d0855a43bb3308
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486700
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-10 08:26:01 -07:00
Brian Wilkerson a547559f3c Add a fix for the representationFieldModifier diagnostic
In addition to wiring up the fix for this one diagnostic I also changed
the naming convention for the constructors so that they will be
consistent as we add support for keywords that can't be used as a name.

Change-Id: Icf83bc7d3f33fea14165acd755889233ac8797b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486480
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-09 09:11:07 -07:00
Brian Wilkerson 6015fddb43 [CQ] Use removeKeyword in place of removeAwait
This replaces the removeAwait correction producer with the awaitKeyword
producer.

The tests were moved to their new location. The test methods were not
changed, but the classes were renamed to be more appropriate.

In the process I noticed a performance improvement I could make to the
replaceKeyword producer, so I included that change here.

Change-Id: Ibff1e61762fa6d4d750d39f130d23681fee766ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486400
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-08 07:37:05 -07:00
Brian Wilkerson fde3828514 Add a fix for invalidCovariantModifierInPrimaryConstructor
This adds a fix for a newly added diagnostic.

I wrote another correction producer that removes a single keyword, but
the intent is for this one to be general enough that it can replace all
of the previous ones. I decided, however, not to try to replace all of
them in a single CL.

Change-Id: I1191021a81f3c1532235316aab6e47cf0b7c9957
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486320
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-06 14:33:29 -08:00
FMorschel 82c13315c0 [DAS] Adds quick-fix to unnecessary_null_aware_operator_on_extension_on_nullable
This changes `unnecessary_null_aware_operator_on_extension_on_nullable` to stop also triggering for non-null nodes because we already report `invalid_null_aware_operator` in that case, and having two diagnostics for the same problem is not useful and would make the fix run twice.

This also `exports 'package:linter/src/lint_names.dart'`, where we declare `FixProcessorLintTest`. This way, we don't need many existing `imports` for it, and this also removes those unnecessary imports.

Fixes: https://github.com/dart-lang/sdk/issues/62766
Change-Id: Iadb460e8db8eb8e020f413f371df424d768fa768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-06 14:12:15 -08:00
Brian Wilkerson 2ddceeaa3f Update the relevance table generator
This is the first CL in what will probably turn out to be a fairly large
number of CLs. The goal is to get the relevance table generator up to
date so that we could then use it to generate new tables, thereby,
hopefully, improving the ranking of completion suggestions.

It includes two sets of changes, and if it would be easier to review I
can split it into two CLs.

The first set of changes is to add visit methods for all of the AST
node classes. While the use of a recursive visitor doesn't allow the
compiler to let us know about missing visit methods, I temporarily
changed the superclass in order to ensure that all of them are
overridden. I want to do that so that we can know when a lack of data
collection is intentional vs. just an oversight.

Which is where the second set of changes comes in. This adds a
mechanism to report if the generator ever sees a keyword or identifier
for which data should have been collected but wasn't. It does this by
recording all such tokens before visiting the AST, and then removing
tokens for which data is collected and tokens that we've explicitly
decided we didn't need data for.

In future CLs I want to get it to a place where we can validate that
the generator and the code completion passes are using the same set of
keys for the generated tables. I also want to add reporting if we have
failed to record data for an expected key because that would indicate
that the corpus used to build the tables is incomplete in its coverate.

Change-Id: I9cb4b729f558884e7321abd741e7b8dc85c997ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486260
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-06 12:09:50 -08:00
Brian Wilkerson 901c94b18f Add tests for the add-required-keyword fix
In the process, I renamed the file so that it would correspond more
closely to the name of the class and the implementation file.

Change-Id: Ic878782a16e5bde34443157e22a14f9b16862ce0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486001
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-06 08:13:50 -08:00
Brian Wilkerson d4447b770b Update add_field_formal_parameters fix for primary constructors
The fix was failing to fire for primary constructors, but this CL fixes
that. It also adds tests for primary constructors.

Along the way I was able to clean up some repeated subexpressions.

Change-Id: I1870ad7c83478b141ab2099c26b9a719f1de7468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485602
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-05 07:48:56 -08:00
FMorschel 72c417c133 [DAS] Fixes dot shorthand completions when feature is disabled
Fixes: https://github.com/dart-lang/sdk/issues/61983
Change-Id: Id5901b1094e2d9b18bc2ab3c279ddc94f6063eb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472020
Commit-Queue: 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>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-04 10:51:41 -08:00
FMorschel 7b782cb298 [DAS] Fixes closure suggestions in returns
Fixes: https://github.com/dart-lang/sdk/issues/62791
Change-Id: Ie8cbdd28e52ca9d7199198b4f3396d31ec503baf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485340
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>
2026-03-04 10:30:51 -08:00
Danny Tuppeny b1355a46e5 [analysis_server] Add tests for primary constructors in inline/extract refactors
Change-Id: I884588e0b0d8ae5ab65af7b582d110d179a74f4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485523
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-04 10:22:47 -08:00
Brian Wilkerson df48c55595 Fix the remove-unused-parameter fix when applied to a field formal parameter
The assist used to change the semantics by removing the assignment of
the default value to the field. This fixes that by adding an explicit
assignment in the initializer list.

Fixes: https://github.com/dart-lang/sdk/issues/61810
Fixes: https://github.com/dart-lang/sdk/issues/62809
Change-Id: I8fdb9169e8499e5a99c7b954f3dad7ddab289bb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485280
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-03 16:30:09 -08:00
Brian Wilkerson 28b1ea93af Do not convert super parameters to field formal parameters
This ensures that the lint that suggests the converion to a field formal
parameter doesn't fire for super parameters, and also that the assist
isn't offered in those cases.

We can consider allowing both if we find a good way to perform the
conversion, but at the moment the tools can create invalid code.

Fixes: https://github.com/dart-lang/sdk/issues/62807
Change-Id: I7b4b2011059afc8ae0fc9649d012c51a37c64472
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485121
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-03 10:27:19 -08:00
Sam Rawlins 050923d9ce DAS: In the Contexts insights page, add some text defining a library cycle
Fixes https://github.com/dart-lang/sdk/issues/62724

Change-Id: I97132d1d7068f855b940bc7a1df57d11515f556a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484880
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-03 09:28:43 -08:00
Danny Tuppeny b26f951011 [analysis_server] Fix renames for constructors declared with new/factory keywords and no type name
Change-Id: Ifc19ad892695726d4a40bc69acffa7d7b27df6df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-03 08:39:43 -08:00
Danny Tuppeny c3cc1d53a3 [analysis_server] Add test for hover with factory()
This was recently updated for `new()` but didn't handle `factory()`.

Change-Id: I8a75dcbfa7d5454e0758f0ff8f2ca1bb7bd5ddfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-02 08:44:08 -08:00