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

Go to Type Definition #3833

Closed
dutsky opened this issue Feb 15, 2022 · 4 comments
Closed

Go to Type Definition #3833

dutsky opened this issue Feb 15, 2022 · 4 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
Milestone

Comments

@dutsky
Copy link

dutsky commented Feb 15, 2022

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:

final MyType 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.

@DanTup
Copy link
Member

DanTup commented 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 DanTup added this to the On Deck milestone Mar 7, 2022
@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 Mar 7, 2022
@DanTup DanTup modified the milestones: On Deck, v3.38.0 Mar 9, 2022
@DanTup
Copy link
Member

DanTup commented 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
Copy link
Member

DanTup commented Mar 29, 2022

Working on this at https://dart-review.googlesource.com/c/sdk/+/239306/

Mar-29-2022 15-45-46

@DanTup DanTup modified the milestones: v3.38.0, v3.39.0 Mar 29, 2022
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Mar 29, 2022
Fixes Dart-Code/Dart-Code#3833.

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

DanTup commented 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.

@DanTup DanTup closed this as completed Apr 27, 2022
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
Projects
None yet
Development

No branches or pull requests

2 participants