More Intelligent Eclipse “Open Call Hierarchy”?

2020-02-14 02:08发布

If I have a Java project in Eclipse, I can right-click on a method name and "Open Call Hierarchy." Suppose I have two interfaces, A and B, that both specify a method x(). Is it possible for me to have Eclipse use "Open Call Hierarchy" in a more intelligent way so as to only show calls to x() from A's while not showing those from B's?

3条回答
劳资没心,怎么记你
2楼-- · 2020-02-14 02:22

It may help to remove "Potential matches" from the search results. Try this:

Preferences -> General -> Search

And check "Ignore potential matches".

查看更多
Summer. ? 凉城
3楼-- · 2020-02-14 02:36

Eclipse should already do this. If you want to test it, go to your A interface, select the x() method and run 'Open Call Hierarchy' on it. Do the same for your x() method in interface B. You should get different code locations, unless you have a class which implements both, which you should never do. Doing so won't break any compilation or execution, you will just be doubly declaring the same method signature.

查看更多
不美不萌又怎样
4楼-- · 2020-02-14 02:39

I have tried this with a frequently-overridden method, toString(). When I right-click on it and choose "Open Call Hierarchy," Eclipse happily searches through my entire workspace and returns all references to that method signature.

I often rely on Eclipse to go the opposite way: I select a method invocation and press F3 to Open Declaration. But I don't think Eclipse is able to go the direction you want, from the declaration to the calling reference.

查看更多
登录 后发表回答