简体   繁体   English

更智能的Eclipse“开放调用层次结构”?

[英]More Intelligent Eclipse “Open Call Hierarchy”?

If I have a Java project in Eclipse, I can right-click on a method name and "Open Call Hierarchy."如果我在 Eclipse 中有一个 Java 项目,我可以右键单击方法名称和“打开调用层次结构”。 Suppose I have two interfaces, A and B, that both specify a method x().假设我有两个接口 A 和 B,它们都指定了一个方法 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?我是否可以让 Eclipse 以更智能的方式使用“开放调用层次结构”,以便仅显示来自 A 的 x() 调用而不显示来自 B 的调用?

Eclipse should already do this. Eclipse 应该已经这样做了。 If you want to test it, go to your A interface, select the x() method and run 'Open Call Hierarchy' on it.如果您想测试它,请转到您的A接口,选择x()方法并在其上运行“Open Call Hierarchy”。 Do the same for your x() method in interface B .对接口B 中的x()方法执行相同操作。 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.这样做不会破坏任何编译或执行,您只会双重声明相同的方法签名。

I have tried this with a frequently-overridden method, toString().我已经用一个经常被覆盖的方法 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.当我右键单击它并选择“Open Call Hierarchy”时,Eclipse 会愉快地搜索我的整个工作区并返回对该方法签名的所有引用。

I often rely on Eclipse to go the opposite way: I select a method invocation and press F3 to Open Declaration.我经常依赖 Eclipse 走相反的路:我选择一个方法调用并按 F3 打开声明。 But I don't think Eclipse is able to go the direction you want, from the declaration to the calling reference.但我不认为 Eclipse 能够按照您想要的方向发展,从声明到调用引用。

It may help to remove "Potential matches" from the search results.从搜索结果中删除“潜在匹配项”可能会有所帮助。 Try this:试试这个:

Preferences -> General -> Search

And check "Ignore potential matches".并选中“忽略潜在匹配项”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM