Oliver Watkins
Oliver Watkins

Reputation: 13489

How do I find usages of method implementation in eclipse?

When I want to find usages of a normal method in java it is fairly easy and straightforward CTRL-SHIFT-G .

However if this method has a super definition, or implementation, then eclipse will show me usages of all types in the hierarchy types.

For example, if I have a toString() method on my class, I would only be interested in finding exactly where this toString() of this class was being called, instead eclipse gives me every single ancestor toString in the project (ie Object.toString()).

How do I find only specific usages to my class? And not usages of parent classes like Object.toString() ?

Upvotes: 17

Views: 13960

Answers (3)

bladedh
bladedh

Reputation: 71

After having the same problem as many others in the comments (Eclipse shows references to Object.toString()) I have found a way that seems to work correctly:

Go to outline from your custom class, right click on your toString() implementation and References -> Project. This displays only references to said implementation.

Upvotes: 0

Prateek Jain
Prateek Jain

Reputation: 3045

Alt + ctrl + h should give you exactly, what you are looking for.

Updated with screenshot from my workspace as some people are facing issue in following it:

enter image description here

Upvotes: 21

Ori Marko
Ori Marko

Reputation: 58774

Thanks to @manouti answer, To show when using the overridden method only follow the steps:

Search by Java the method as com.package.MyObject.toString()

And after in search result screen click on the right arrow to the left and check References to Overridden

Upvotes: 4

Related Questions