[英]Method investigation in Eclipse - How to find out which classes call this particular method?
说我有Class1实现了名为Class1interface的接口。
该接口通过依赖项注入和IoC自动连接到另一个名为Class2的类中 。 Class2使用Class1interface提供的一些方法。
假设我们使用Spring符号:
class Class2 {
@Autowired
Class1interface;
// methods calls of Class1interface and application logic
}
如何在不滚动屏幕的情况下找出Class1interface / Class1的哪些方法在Class2中使用? 或者如何检查Class2中是否使用了此特定的Class1interface方法?
我知道狡猾的解释,但我尽力了。
谢谢,
光标在某个方法上时,按Ctrl + Shift + G将显示对该方法的引用。 这不会为您提供有关类关系的漂亮报告,但是您可以浏览Class1.blah的结果以查看Class2中的哪些方法引用了它。
如果要在运行时表示,则必须使用反射来提取方法列表。
Method[] list1 = Class1.class.getMethods();
Method[] list2 = Class2.class.getMethods();
//Your code to compare the lists here
如果您的意思是开发环境,请使用@digitaljoel的答案
可能是将光标放在字段引用上时可以使用“ Ctrl + shift + U”,您应该能够看到该类中字段引用的用法。
Search > Occurences in File > Identifier
为您提供了对该字段的所有访问权限的列表。 这不是确切的解决方案,但可能会有所帮助:
将光标放在任何字段或方法上,然后按<Ctrl>
+ <Alt>
+ <H>
,这将为您提供调用层次结构。 这仍然意味着您必须检查Class1
/ Interface1
每个方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.