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
Consider adding "Go to Super" to context menu for improved visibility #4552
class A {
void somemethod();
}
class B extends A {
@override
void somemethod() ;
}
It would be nice to have a method where I could quickly navigate from B:something to A:something.
In eclipse I can click on the method name and be offered a number of navigation options one of which is 'navigate to super class' which switches the editor to the same method in the super class i.e A: something.
We have this in the command palette as "Go to super class/method". You can key-bind it, but unfortunately we can't add things to the context menu that are based on the position clicked (this is only possible for first-class functions VS Code provides).
I don't personally like lots of CodeLens (partly because they can lead to the code jumping around), but that's just me.
But, to do this such that CodeLens only shows up where there actually is a super, we may need to do a lot more processing up-front (and on each file change). The current implementation does no work until you invoke it, and then just looks it up for the current location in the editor.
If you'd like it, it's worth opening an issue to collect 👍 's though. If there's some demand for it, it may be worth exploring.
But, to do this such that CodeLens only shows up where there actually is a super, we may need to do a lot more processing up-front (and on each file change).
Shouldn't a presence of the override annotation be enough? The annotation line is also known. And then you can calculate the navigation on click.
If you'd like it, it's worth opening an issue to collect 👍 's though. If there's some demand for it, it may be worth exploring.
I'm more concerned that this is something really not obvious (but we talked about this before), especially that it takes the cursor position. Not sure that there is enough demand for the change though.
Shouldn't a presence of the override annotation be enough? The annotation line is also known. And then you can calculate the navigation on click.
Yeah, that would probably be good enough - though it's not free. We don't currently implement CodeLens in the server, so it would be a new request/round-trip on each change and a visit across the whole file. It's unlikely to be slow, but I'm conscious of all the things that happen on each key press (or some buffered set of) that add up (when you type a character in VS Code, it will ask for Folding Ranges, Semantic Tokens, Document Symbols, Code completion, Code Actions, etc.).
Like I said, it's definitely worth filing an issue. There's a lot of things that could be done so having some gauge of interest will help prioritise them.
I'm more concerned that this is something really not obvious (but we talked about this before), especially that it takes the cursor position.
Yep, I completely agree discoverability in VS Code is not great (as we've discussed :)). Though I'm also conscious that we have a lot of features and if we try to put them all into the UI, things could get very busy, and the way CodeLens causes code to shift around can be really jarring, so it's probably the last place I'd like to put things without knowing they're wanted.
There is an open VS Code issue about being able to render CodeLens in a way that doesn't shift code around which would improve that, but it's not available today.
I don't personally like lots of CodeLens (partly because they can lead to the code jumping around), but that's just me.
But, to do this such that CodeLens only shows up where there actually is a super, we may need to do a lot more processing up-front (and on each file change). The current implementation does no work until you invoke it, and then just looks it up for the current location in the editor.
If you'd like it, it's worth opening an issue to collect +1 's though. If there's some demand for it, it may be worth exploring.
For the record, I also hate code lens.
I've never had the reaction of - oh that's providing something useful that I want just now.
add things to the context menu that are based on the position clicked
Is it worth opening a request on vs-code to allow this, or is it something they won't consider in order to protect visual studio?
We have this in the command palette as "Go to super class/method". You can key-bind it, but unfortunately we can't add things to the context menu that are based on the position clicked (this is only possible for first-class functions VS Code provides).
Is it worth opening a request on vs-code to allow this, or is it something they won't consider in order to protect visual studio?
I think they won't do it just because of how VS Code works. All menu entries like the top-level of context menu must be declared up-front so that there is no async work (eg. going to the extension host to ask for the entries). This is something I don't think they will compromise on for performance reasons.
However, I just did some testing again and it seems like when you right-click, it does more the cursor to where you clicked. Sometimes it's not obvious because sometimes the editor seems to lose focus and you can't see it - but clicking in the explorer then tabbing back to the editor has the cursor where you right-clicked.
So a possibility could be:
Add it to the context menu (it will show up always, just like Go to Definition)
When invoked from the context menu, use the current cursor position as the location
I don't know whether it's a bit noisy to add less-used features like this to the context menu though, it's already quite long. I'm also not sure if we could put it in with the other VS Code "Go to" items.
I'll re-open this as a request to try it out though.
changed the title [-]Provide a quick navigation to a super function.[/-][+]Consider adding "Go to Super" to context menu for improved visibility[/+]on May 19, 2023
@bsutton since my context menu already long, I don't think I want this. Did you tried set Keyboard Shortcuts for it? Current I am using Ctrl Alt Z, seem good.
Activity
DanTup commentedon May 18, 2023
We have this in the command palette as "Go to super class/method". You can key-bind it, but unfortunately we can't add things to the context menu that are based on the position clicked (this is only possible for first-class functions VS Code provides).
incendial commentedon May 18, 2023
@DanTup hey, have you considered using VS Code CodeLens feature for this? Or it'd be too noisy?
Just curious.
DanTup commentedon May 18, 2023
I don't personally like lots of CodeLens (partly because they can lead to the code jumping around), but that's just me.
But, to do this such that CodeLens only shows up where there actually is a super, we may need to do a lot more processing up-front (and on each file change). The current implementation does no work until you invoke it, and then just looks it up for the current location in the editor.
If you'd like it, it's worth opening an issue to collect 👍 's though. If there's some demand for it, it may be worth exploring.
incendial commentedon May 18, 2023
Shouldn't a presence of the override annotation be enough? The annotation line is also known. And then you can calculate the navigation on click.
I'm more concerned that this is something really not obvious (but we talked about this before), especially that it takes the cursor position. Not sure that there is enough demand for the change though.
DanTup commentedon May 18, 2023
Yeah, that would probably be good enough - though it's not free. We don't currently implement CodeLens in the server, so it would be a new request/round-trip on each change and a visit across the whole file. It's unlikely to be slow, but I'm conscious of all the things that happen on each key press (or some buffered set of) that add up (when you type a character in VS Code, it will ask for Folding Ranges, Semantic Tokens, Document Symbols, Code completion, Code Actions, etc.).
Like I said, it's definitely worth filing an issue. There's a lot of things that could be done so having some gauge of interest will help prioritise them.
Yep, I completely agree discoverability in VS Code is not great (as we've discussed :)). Though I'm also conscious that we have a lot of features and if we try to put them all into the UI, things could get very busy, and the way CodeLens causes code to shift around can be really jarring, so it's probably the last place I'd like to put things without knowing they're wanted.
There is an open VS Code issue about being able to render CodeLens in a way that doesn't shift code around which would improve that, but it's not available today.
bsutton commentedon May 19, 2023
For the record, I also hate code lens.
I've never had the reaction of - oh that's providing something useful that I want just now.
bsutton commentedon May 19, 2023
Is it worth opening a request on vs-code to allow this, or is it something they won't consider in order to protect visual studio?
DanTup commentedon May 19, 2023
I think they won't do it just because of how VS Code works. All menu entries like the top-level of context menu must be declared up-front so that there is no async work (eg. going to the extension host to ask for the entries). This is something I don't think they will compromise on for performance reasons.
However, I just did some testing again and it seems like when you right-click, it does more the cursor to where you clicked. Sometimes it's not obvious because sometimes the editor seems to lose focus and you can't see it - but clicking in the explorer then tabbing back to the editor has the cursor where you right-clicked.
So a possibility could be:
I don't know whether it's a bit noisy to add less-used features like this to the context menu though, it's already quite long. I'm also not sure if we could put it in with the other VS Code "Go to" items.
I'll re-open this as a request to try it out though.
[-]Provide a quick navigation to a super function.[/-][+]Consider adding "Go to Super" to context menu for improved visibility[/+]quyenvsp commentedon May 25, 2023
@bsutton since my context menu already long, I don't think I want this. Did you tried set Keyboard Shortcuts for it? Current I am using Ctrl Alt Z, seem good.
DanTup commentedon Jan 22, 2024
go_to_super_context.mp4
DanTup commentedon Jan 25, 2024
Forgot to tag this in the commit, implemented in 71a6e70.