You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Hi! I'm looking for the way to go to type definition of var when I omitting local variable type like this:
final myVar =doSomething();
I can't find fast way(hotkey or something) to go to type definition of myVar.
There is no problem to open type definition if you annotate variable type like this:
finalMyType myVar =doSomething();
here you can set cursor to MyType and press F12(in default hotkey layout) and MyType definition will open, but it won't work in example before (F12 will show you list of references).
Describe the solution you'd like
It would be nice to have some kind of Go to Type Definition hotkey. Like set cursor to myVar and press some hotkey to open type definition of MyType
Describe alternatives you've considered
As alternative you can hover myVar with mouse cursor and popup with type name will appear. After that you can use Go to Symbol mechanic(Ctrl + T) and type name of type(sorry :) ) there.
Although not exactly what's requested here, I think doing #3853 could help with this issue. As well as being able to more easily get to the type from hovering myVar, it'd also be easier to jump to types from hovering a function (it's return type would produce a link too).
That doesn't provide a way to get there with a keyboard shortcut though, so I think there's also some value in an action like this.
This landed in the SDK in dart-lang/sdk@e7adcb6. Since the implementation is in the server, it'll show up in a future Dart/Flutter SDK release rather than a Dart-Code release.
Reacted by Denis Revin, Anson Heung and Tomasz Wyrowiński
Activity
DanTup commentedon Mar 7, 2022
Although not exactly what's requested here, I think doing #3853 could help with this issue. As well as being able to more easily get to the type from hovering
myVar, it'd also be easier to jump to types from hovering a function (it's return type would produce a link too).That doesn't provide a way to get there with a keyboard shortcut though, so I think there's also some value in an action like this.
DanTup commentedon Mar 9, 2022
Turns out VS Code/LSP already has a built-in command for this, so this is actually entirely server work and might not be too complex:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition
DanTup commentedon Mar 29, 2022
Working on this at https://dart-review.googlesource.com/c/sdk/+/239306/
[anlaysis_server] Add support for LSP's Go-to-Type Definition
DanTup commentedon Apr 27, 2022
This landed in the SDK in dart-lang/sdk@e7adcb6. Since the implementation is in the server, it'll show up in a future Dart/Flutter SDK release rather than a Dart-Code release.