eclipse 更智能的Eclipse“开放调用层次结构”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4650021/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
More Intelligent Eclipse "Open Call Hierarchy"?
提问by Michael McGowan
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?
如果我在 Eclipse 中有一个 Java 项目,我可以右键单击方法名称和“打开调用层次结构”。假设我有两个接口 A 和 B,它们都指定了一个方法 x()。我是否可以让 Eclipse 以更智能的方式使用“开放调用层次结构”,以便仅显示来自 A 的 x() 调用而不显示来自 B 的调用?
采纳答案by Wagan8r
Eclipse should already do this. If you want to test it, go to your Ainterface, 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.
Eclipse 应该已经这样做了。如果要测试它,请转到A接口,选择x()方法并在其上运行“Open Call Hierarchy”。对接口B 中的x()方法执行相同操作。您应该获得不同的代码位置,除非您有一个实现这两者的类,这是您永远不应该做的。这样做不会破坏任何编译或执行,您只会双重声明相同的方法签名。
回答by rajah9
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.
我已经用一个经常被覆盖的方法 toString() 尝试了这个。当我右键单击它并选择“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. But I don't think Eclipse is able to go the direction you want, from the declaration to the calling reference.
我经常依赖 Eclipse 走相反的路:我选择一个方法调用并按 F3 打开声明。但我不认为 Eclipse 能够按照您想要的方向发展,从声明到调用引用。
回答by Andrew Eisenberg
It may help to remove "Potential matches" from the search results. Try this:
从搜索结果中删除“潜在匹配项”可能会有所帮助。尝试这个:
Preferences -> General -> Search
Preferences -> General -> Search
And check "Ignore potential matches".
并选中“忽略潜在匹配项”。