如何获取在Eclipse IDE中从类调用的方法的列表? [英] How do I get a list of Methods called from a Class in Eclipse IDE?
问题描述
我为我的Java项目使用Eclipse IDE。我需要一个方法列表,从一个特定的类,即我需要看到所有的方法,从一个类中调用,但没有在那里声明的列表。我正在寻找一些可能在Eclipse中已经存在的选项。我不愿意为此编写代码(这将是我的最后一个选择)。
I am using Eclipse IDE for my Java project. I need a list of methods which are being called from a particular class i.e. I need to see a list of all the methods which are being called from a class but not declared in that. I am looking for some option which might be there in Eclipse already. I am not willing to write a code for this (that will be my last choice).
让我用这个例子解释 -
Let me explain using this example -
public class ABC {
public void methodA {
System.out.println("In methodA");
BCD bcd = new BCD();
bcd.callMethodAA(); // defined in class BCD
}
public void methodB {
System.out.println("In methodB");
CDE cde = new CDE();
cde.callMethodBB(); // defined in class CDE
}
}
将显示我 -
从ABC类,我们调用 -
a)callMethodAA
b)callMethodBB
I want an option which will show me - From Class ABC we are calling - a) callMethodAA b) callMethodBB
推荐答案
p>如果你只需要列出使用的方法,没有语言的方式来实现。虽然可能有一些覆盖工具可以处理这个问题。
If you need to list only the method being used, there is no in-language way to achieve that. Though there might be some coverage tools which can handle this.
但是如果关于所有可用的方法,你可以使用反射:
But If its about all the available methods, you can use reflection:
Class<?> cls = Class.forName("className");
Method[] methodList = cls.getMethods();
这篇关于如何获取在Eclipse IDE中从类调用的方法的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!