在 Eclipse 项目中查找方法调用
我有一个包含方法 myMethod() 的类 X。我想在当前工作区的所有项目中找到调用此 myMethod() 的位置。我无法使用任何搜索函数,因为有多个类带有 myMethod(),而且它不是静态的。因此,我需要知道此类的对象的名称,如果不手动探索项目,这是不可能的。
Eclipse 有解决方案吗?
I have a class X containing method myMethod(). I would like to find locations in all projects in my current workspace where this myMethod() is being called. I cannot use any search functions as there are several classes with myMethod(), and it isn't static. Hence I need to know the name of the objects of this class, which isn't possible without manually exploring the projects.
Does Eclipse have a solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
转到 X.java 中的方法,然后从上下文菜单中选择“打开调用层次结构”。
Go to the method in X.java, and select Open Call Hierarchy from the context menu.
选择
mymethod()
并按 ctrl+alt+h。要查看有关任何方法的一些详细信息,您可以通过选择该特定对象或方法并右键单击来使用它。您可以看到“OpenCallHierarchy”(Ctrl+Alt+H)。像这样,有很多工具可以让您的工作更轻松,例如“快速大纲”(Ctrl+O)来查看中声明的数据类型和方法特定的 .java 文件。
要了解更多信息,请参阅此 eclipse 参考
Select
mymethod()
and press ctrl+alt+h.To see some detailed Information about any method you can use this by selecting that particular Object or method and right click. you can see the "OpenCallHierarchy" (Ctrl+Alt+H). Like that many tools are there to make your work Easier like "Quick Outline" (Ctrl+O) to view the Datatypes and methods declared in a particular .java file.
To know more about this, refer this eclipse Reference
具体方法也可以搜索一下。例如,如果您想搜索字符串类的
isEmpty()
方法,您必须 - Search ->; Java -> 类型java.lang.String.isEmpty()
并在“搜索”选项中使用 Method。然后您可以选择所需的范围。
You can also search for specific methods. For e.g. If you want to search for
isEmpty()
method of the string class you have to got to - Search -> Java -> typejava.lang.String.isEmpty()
and in the 'Search For' option use Method.You can then select the scope that you require.
将光标移至方法名称。右键单击并选择参考文献 >项目或参考文献>弹出菜单中的工作区。
Move the cursor to the method name. Right click and select References > Project or References > Workspace from the pop-up menu.
或
这将向您显示一个搜索视图,其中包含使用此方法的类和方法的层次结构。
or
This will show you a Search view containing the hierarchy of class and method which using this method.
右键单击方法,然后单击打开调用层次结构
Right click on method and click on Open call Hierarchy