Repository navigation
Inlay hints for nested patterns #4712
Copy link
Copy link
Closed
Labels
in editorRelates to code editing or language featuresRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.An enhancement or improvement that should be listed in release notes but is not a bug fix.relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become availableSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
Milestone
Description
Is your feature request related to a problem? Please describe.
It would be helpful to easily see (and navigate) to inferred types for nested patterns (switch, if-case, destructuring, etc.)
For now it's only possible to navigate to most inner inferred type.
Describe the solution you'd like
Make inlay hints for nested patterns behave like for generics (like #4366)
Describe alternatives you've considered
Not really.
Additional context
Addition to #4624
final class Box<T> {
const Box(this.value);
final T value;
}
void main() {
{
const boxedBox = Box(Box((1,2)));
const boxedList = Box([1,2]);
{ // actual (notice that inner pattern is augmented correctly)
if (boxedBox case Box(value: Box(:final (int, int) value))) {}
if (boxedList case Box(value: List(:final int length)) when length > 0) {}
}
{ // expected
if (boxedBox case Box<Box<(int, int)>>(value: Box<(int, int)>(:final (int, int) value))) {}
if (boxedList case Box<List<int>>(value: List<int>(:final int length)) when length > 0) {}
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in editorRelates to code editing or language featuresRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.An enhancement or improvement that should be listed in release notes but is not a bug fix.relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become availableSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
Activity
DanTup commentedon Sep 4, 2023
@Zekfad I'm not sure I understand the code sample (specifically, which parts of the code are intended to be code, and which parts are intended to be hints). I don't see any hints in either the "actual" or "expected" code because they already have explicit types.
Could you provide the code where you want to see hints without the hints (or with the hints in comments) so I can understand what you'd like? Thanks!
Zekfad commentedon Sep 4, 2023
Thank you for response, I'll clarify:
in this line:
First
Boxand secondBoxshould be augmented like so (Box<Box<(int, int)>>andBox<(int, int)>respectively):Same for
BoxandListpairs from the 2nd line of examples.DanTup commentedon Sep 4, 2023
Oh gotcha, thanks!
Zekfad commentedon Sep 4, 2023
Thank you for your work, these hits makes it really easy to play aground switch cases!
DanTup commentedon Oct 31, 2023
Working on a fix at https://dart-review.googlesource.com/c/sdk/+/332960. With the fix looks like this:
[analysis_server] Include inlay hints for type arguments in "if case"
DanTup commentedon Nov 1, 2023
Fixed by dart-lang/sdk@939e081. It ships in the analysis server so will show up in a future Dart/Flutter SDK release rather than a Dart-Code release.
Zekfad commentedon Nov 1, 2023
Thank you for your awesome work, this helps a lot!