Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inlay hints should display inferred type argument #4366

Closed
Zekfad opened this issue Jan 28, 2023 · 10 comments
Closed

Inlay hints should display inferred type argument #4366

Zekfad opened this issue Jan 28, 2023 · 10 comments
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available
Milestone

Comments

@Zekfad
Copy link

Zekfad commented Jan 28, 2023

Is your feature request related to a problem? Please describe.
It's hard to navigate to inferred type of generics. You have to lookup relevant argument and find type from it.
For now it's only possible to see inferred type from hover popup, but it's just plain text.

Describe the solution you'd like
Inlay hints should show clickable inferred types of generics.

Describe alternatives you've considered
Make hovers interactive? (But that's likely out of scope).

Additional context

Screenshot of current behavior

image

@DanTup
Copy link
Member

DanTup commented Jan 28, 2023

Do you mean in cases like this?

foo<T>(T a) {
  foo('');         // Show an inlay hint of `<String>` after `foo` so this reads foo<String>('')
}

@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server labels Jan 28, 2023
@DanTup DanTup added this to the v3.60.0 milestone Jan 28, 2023
@Zekfad
Copy link
Author

Zekfad commented Jan 28, 2023

Hi @DanTup, thanks for fast reply, yes, that's what I meant.

@DanTup
Copy link
Member

DanTup commented Feb 21, 2023

I've a change open to add this for type arguments and also list/map/set literals where it was missing before.

Feb-21-2023 12-36-15

https://dart-review.googlesource.com/c/sdk/+/284143

@Zekfad
Copy link
Author

Zekfad commented Feb 21, 2023

Hi @DanTup, thank you for your work!
Is there ETA for Preview version with this feature?

On your screenshot, it infers <int>a: [1,2], shouldn't it be a: <int>[1,2]?

@DanTup
Copy link
Member

DanTup commented Feb 21, 2023

The change is in the Dart analysis server in the SDK, so once the review is done and the code landed, it'll be available in main channel builds of the SDK usually within a few hours or so (and Flutter's master branch probably within a few days). I wouldn't recommend using those versions for production work but they're good for testing. Of course the change will also then show up in future dev/beta/stable releases of the SDKs.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Feb 21, 2023
…s + literals

Fixes Dart-Code/Dart-Code#4366.

Change-Id: I92b28869961a6098031a21ca1cf0d34f4decd16c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284143
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Feb 21, 2023

Landed in dart-lang/sdk@e8a8e10.

@DanTup DanTup closed this as completed Feb 21, 2023
@DanTup DanTup added the relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available label Feb 21, 2023
@Zekfad
Copy link
Author

Zekfad commented Feb 21, 2023

Hi @DanTup, on your screenshot, it infers <int>a: [1,2], shouldn't it be a: <int>[1,2]?

@DanTup
Copy link
Member

DanTup commented Feb 21, 2023

@Zekfad Oof, yes, I hadn't noticed that (and apparently I didn't write tests when there are both type args and parameter names at the same offset). I will fix, thanks!

@DanTup DanTup reopened this Feb 21, 2023
@DanTup
Copy link
Member

DanTup commented Feb 22, 2023

Got a fix open at https://dart-review.googlesource.com/c/sdk/+/284641.

@DanTup
Copy link
Member

DanTup commented Feb 22, 2023

Fix landed in dart-lang/sdk@658e34e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available
Projects
None yet
Development

No branches or pull requests

2 participants