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

Offer to 'Find all references' on overridden method #94

Open
raboof opened this issue May 15, 2019 · 21 comments
Open

Offer to 'Find all references' on overridden method #94

raboof opened this issue May 15, 2019 · 21 comments

Comments

@raboof
Copy link

raboof commented May 15, 2019

When doing a 'find all references' (in vscode) on a method that overrides a method from a superclass, only references to the method on the subclass are returned. It would be useful to have the option to also see references to the method on the superclass. Also easily jumping to the method in the superclass would be helpful.

@olafurpg
Copy link
Member

Thanks for reporting! This feature will be possible to implement once "rename symbol" is done. Currently, we are missing indexes to find all the overriden methods.

@raboof
Copy link
Author

raboof commented May 15, 2019

👍 - linking to scalameta/metals#679

@tgodzik
Copy link
Contributor

tgodzik commented Nov 12, 2019

It is finally possible to find all references on an overridden method now, everything that we need is implemented and it's used in the RenameProvider, however we need to figure out how to offer that option to user.

Perhaps it would make sense to offer it via code actions ?

@gabro
Copy link
Member

gabro commented Nov 12, 2019

@tgodzik what so you think about making it the default?

@tgodzik
Copy link
Contributor

tgodzik commented Nov 12, 2019

@tgodzik what so you think about making it the default?

I think that would be fine, but I would like to hear some more opinions.

Overall, it would be also nice to be able to customize the options for finding references, so that we can do it both ways.

@olafurpg
Copy link
Member

I think it's fine to default to always finding references to all overridden and supermethods. I don't think we need to add options to begin with.

@olafurpg olafurpg transferred this issue from scalameta/metals-feature-requests Nov 12, 2019
@olafurpg
Copy link
Member

Moving to the main repo since this issue is unblocked by textDocument/rename.

@raboof
Copy link
Author

raboof commented Nov 12, 2019

I think it's fine to default to always finding references to all overridden and supermethods.

yeah, only for toString and similar generic methods it can be helpful to only search for the specific one, for now I agree it makes sense to search for the supermethods

@olafurpg
Copy link
Member

Good point. We may want to special case toString, hashCode and equals to not include supermethods and overridden methods.

@kubukoz
Copy link

kubukoz commented Jan 5, 2020

Hi, is anyone currently working on this? If it's not too hard for a newcomer to the project, I'd like to give it a try :)

@tgodzik
Copy link
Contributor

tgodzik commented Jan 6, 2020

Hi, is anyone currently working on this? If it's not too hard for a newcomer to the project, I'd like to give it a try :)

Not currently, you're welcome to give it a try! We already try to find all references in the RenameProvider, which is done by going to the top symbol and searching for references of all implementations. This might probably be done better and we can move that logic to the ReferenceProvider.

@tgodzik
Copy link
Contributor

tgodzik commented Feb 3, 2020

@kubukoz Are you working on this? Or is ok for someone else to pick it up?

@kubukoz
Copy link

kubukoz commented Feb 3, 2020 via email

@tgodzik
Copy link
Contributor

tgodzik commented Feb 5, 2020

We'll work on it with @KBochenek to get him introduced into Metals and overall Scalameta environment.

@tgodzik
Copy link
Contributor

tgodzik commented Mar 9, 2020

This is blocked until we have a faster way to extract info about class hierarchy in dependencies.

Looking into ways to do it here: scalameta/metals#1287

@tgodzik tgodzik transferred this issue from scalameta/metals Mar 31, 2020
@tgodzik
Copy link
Contributor

tgodzik commented Mar 31, 2020

Moved it back to feature requests, since it will not be as easy to implement until we improve the efficiency of finding inheritance hierarchy in dependencies.

@gabro
Copy link
Member

gabro commented Mar 31, 2020

Also easily jumping to the method in the superclass would be helpful.

By the way, this part of the OP has been implemented in scalameta/metals#1487 🎉

@kubukoz
Copy link

kubukoz commented Apr 22, 2021

Is "find references for implementations of method" also in scope for this?

@tgodzik
Copy link
Contributor

tgodzik commented Apr 23, 2021

@kubukoz that's the plan, however we still need a way to get class hierarchy from dependencies, which is not trivial to do effectively.

@KacperFKorban
Copy link

Hi, any plans for supporting this? It seems that the previous blocker has been resolved by @kasiaMarek.
Also AFAIK, just going up in the class hierarchy can be done using PC with SymDenotations#allOverriddenSymbols.

@tgodzik
Copy link
Contributor

tgodzik commented Jan 24, 2025

We could probably do that now yeah, but not sure when.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants