Skip to content

Go to Type Definition #3833

Closed
Closed

Description

@dutsky

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.

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Feb 15, 2022
  2. DanTup commented on Mar 7, 2022

    @DanTup
    Member

    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.

  3. added this to the On Deck milestone on Mar 7, 2022
  4. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Mar 7, 2022
  5. modified the milestones: On Deck, v3.38.0 on Mar 9, 2022
  6. DanTup commented on Mar 9, 2022

    @DanTup
    Member

    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

  7. DanTup commented on Mar 29, 2022

    @DanTup
    Member
  8. modified the milestones: v3.38.0, v3.39.0 on Mar 29, 2022
  9. DanTup commented on Apr 27, 2022

    @DanTup
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/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.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions