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
{{ message }}
Repository navigation
control-click on 'var' should navigate directly to the definition #2535
@bwilkerson interested in your thoughts on this (it would need to be done in the server). If it seems sensible, does the server have easy access to get the type? (I'm happy to take a look if it's within my ability!).
If we do that, should we also provide navigation from const and final? If yes, should we always provide it or only when there is no explicit type?
I think if it was supported on them without types, it should also work with types - if a user has it in their mind that it works on const and their cursor is already on const, they might (reasonably) assume it'll work there and press the keybind for it.
out of curiosity, what's a "code lense"?
In VS Code (and I think VS), there's a feature called CodeLens that allows injecting links into the editor. We use it in the VS Code extensions to provide easy links for things like running/debugging tests:
(unfortunately it doesn't work in the analysis server repo because it uses the outline data to know where tests are, and things work a bit differently there - something that bugs me and I'd love to find a fix for!).
However, I think in this context Brett was referring to the "peek"-style window that opens when Ctrl+Clicking var. It turns out we do actually find class, but we also include the location of the variable, and that results in VS Code this opening this to pick between the two definitions:
So it turns out, we don't need to add the location of the class, rather we need to not include the variable. For non-LSP, this could be done in the VS Code extension code (assuming we can tell which one is which - perhaps when there are multiple we should ignore the one that's on the same line that we searched?), and for LSP this would be done in the server. WDYT?
For non-LSP, this could be done in the VS Code extension code (assuming we can tell which one is which - perhaps when there are multiple we should ignore the one that's on the same line that we searched?), ...
Using the line number seems reasonable. It's highly unlikely that anyone will declare the type on the same line as a variable of that type.
... and for LSP this would be done in the server.
Yep, that would be the appropriate place. Then it will work the same for all LSP-based clients.
changed the title [-]control-click on 'var' should navigate to the type's libraries.[/-][+]control-click on 'var' should navigate directly to the definition[/+]on Jun 11, 2020
On Fri, 12 Jun 2020, 1:12 am Brian Wilkerson, ***@***.***> wrote:
Yes. It should be fairly straightforward to extend the
_DartNavigationComputerVisitor to add regions for the keyword var.
If we do that, should we also provide navigation from const and final? If
yes, should we always provide it or only when there is no explicit type?
(And out of curiosity, what's a "code lense"?)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2535 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OHNKZKU57GXCBIYEOTRWDX7HANCNFSM4NZCPOVA>
.
Activity
DanTup commentedon Jun 11, 2020
@bwilkerson interested in your thoughts on this (it would need to be done in the server). If it seems sensible, does the server have easy access to get the type? (I'm happy to take a look if it's within my ability!).
bwilkerson commentedon Jun 11, 2020
Yes. It should be fairly straightforward to extend the
_DartNavigationComputerVisitorto add regions for the keywordvar.If we do that, should we also provide navigation from
constandfinal? If yes, should we always provide it or only when there is no explicit type?(And out of curiosity, what's a "code lense"?)
DanTup commentedon Jun 11, 2020
I think if it was supported on them without types, it should also work with types - if a user has it in their mind that it works on
constand their cursor is already onconst, they might (reasonably) assume it'll work there and press the keybind for it.In VS Code (and I think VS), there's a feature called CodeLens that allows injecting links into the editor. We use it in the VS Code extensions to provide easy links for things like running/debugging tests:
(unfortunately it doesn't work in the analysis server repo because it uses the outline data to know where tests are, and things work a bit differently there - something that bugs me and I'd love to find a fix for!).
However, I think in this context Brett was referring to the "peek"-style window that opens when Ctrl+Clicking
var. It turns out we do actually find class, but we also include the location of the variable, and that results in VS Code this opening this to pick between the two definitions:So it turns out, we don't need to add the location of the class, rather we need to not include the variable. For non-LSP, this could be done in the VS Code extension code (assuming we can tell which one is which - perhaps when there are multiple we should ignore the one that's on the same line that we searched?), and for LSP this would be done in the server. WDYT?
bwilkerson commentedon Jun 11, 2020
Using the line number seems reasonable. It's highly unlikely that anyone will declare the type on the same line as a variable of that type.
Yep, that would be the appropriate place. Then it will work the same for all LSP-based clients.
DanTup commentedon Jun 11, 2020
Great - I pushed a fix here for non-LSP and a CL at https://dart-review.googlesource.com/c/sdk/+/150980/ for LSP.
[-]control-click on 'var' should navigate to the type's libraries.[/-][+]control-click on 'var' should navigate directly to the definition[/+]bsutton commentedon Jun 11, 2020
Filter LSP definitions to not include variable names