[英]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.