简体   繁体   English

如果直接或间接地从另一个方法调用某个方法,如何在Eclipse中查找?

[英]How to find out in Eclipse if certain method is called from another method directly or indirectly?

How to find out in Eclipse if certain method is potentially invoked or reachable (directly or indirectly) from another method? 如果可以从另一个方法中直接或间接地调用或访问某些方法,如何在Eclipse中查找?

Assume I want to refactor A.one() which can be negatively influenced by a side-effect in D.four() . 假设我想重构A.one() ,这可能会受到D.four()D.four()负面影响。 Therefore I'd like to find out if D.four() can potentially be invoked from A.one() . 因此,我想知道是否可以从A.one()调用D.four() A.one() I can see which methods are called from A.one() using the Call Hierarchy. 我可以看到使用Call Hierarchy从A.one()调用哪些方法。 I can navigate the call tree and eventually find that A.one() calls B.two() which calls C.three() which calls D.four() . 我可以导航调用树并最终发现A.one()调用B.two()调用C.three()调用D.four()

Is there a way in Eclipse to make this search somehow automatic? 在Eclipse中是否有办法以某种方式自动进行此搜索?

ps. PS。 There's a "Filters..." option in Call Hierarchy Dialog, but it only hides matching names. “调用层次结构对话框”中有一个“过滤器...”选项,但它只隐藏匹配的名称。

This is a modified version of the way you (@lexicore) found, that involves significantly less button punching (my changes in bold ): 这是你(@lexicore)找到的方式的修改版本,它显着减少了按钮打孔(我的粗体更改):

  • Open Call Hierarchy for A.one(), Show Callee Hierarchy. 打开A.one(),显示Callee层次结构的调用层次结构。
  • Select the root node, and press the * key until the whole tree is expanded. 选择根节点,然后按*键直到展开整个树。 Note that you only need to press * on the root node. 请注意,您只需要在根节点上按*。 This will expand the whole tree in "no time". 这将“很快”扩展整棵树。
  • Right mouse click, Copy Expanded Hierarchy. 单击鼠标右键,复制扩展层次结构。
  • Paste into a text file. 粘贴到文本文件中。
  • Full-text search for D.four(). 全文搜索D.four()。

Notes 笔记

  • The key * expands all unexpanded leaf nodes one level. 键*将所有未展开的叶节点扩展到一个级别。
  • The keys + and - works for expanding and closing just the selected node. 键+和 - 用于扩展和关闭所选节点。
  • I've tried this on a Swedish keyboard, where * is located in a different place than on a US keyboard, but hopefully Eclipse won't care about that. 我在瑞典语键盘上试过这个,其中*位于与美国键盘不同的地方,但希望Eclipse不关心这一点。

Update 更新

Here is some documentation , where the * key is mentioned. 这是一些文档 ,其中提到了*键。

We've just encountered a way. 我们刚刚遇到了一个方法。 Not really "automatic", involves a lot of -> -button punching. 不是真的“自动”,涉及很多->按钮冲孔。 :) :)

  • Open Call Hierarchy for A.one() , Show Callee Hierarchy. 打开A.one() ,显示Callee层次结构的调用层次结构。
  • Start from the root, expand the whole tree by clicking the -> button many many times. 从根开始,通过多次单击->按钮展开整个树。 Really many times. 真的很多次。 :) :)
  • Right mouse click, Copy Expanded Hierarchy. 单击鼠标右键,复制扩展层次结构。
  • Paste into a text file. 粘贴到文本文件中。
  • Full-text search for D.four() . 全文搜索D.four()

I hope there are better ways not involving punching the -> -button. 我希望有更好的方法不涉及打击->按钮。

我所知道的最简单的方法是手动导航到D.four() ,在该方法上使用Call Hierarchy ,看看A.one()是否包含在层次结构中。

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

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