Files
sdk/pkg/analysis_server/lib
Kallen Tu 35b09df976 [analysis_server] Dot shorthands: Update ReplaceWithVar fix and assist.
When the initializer of a variable declaration is exactly a dot shorthand, we can insert the declared type in front of the dot shorthand to ensure that we're retaining the necessary context type.
`E e = .a;` -> `var e = E.a;`
In other cases such as typed literals and constructor invocations, the correction already does what we need it to.

When we're looking at a for-each and the iterable is a typed literal, if there's a dependent dot shorthand, we add explicit type arguments to the literal to retain the context type.

Added tests for the fix and the assist which has the same code path.

Bug: https://github.com/dart-lang/sdk/issues/60957, https://github.com/dart-lang/sdk/issues/60994
Change-Id: I31a05f10a7cdaae731c6f6c59deae12c2543a4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-07-21 17:02:03 -07:00
..