How do I get a list of Methods called from a Class in Eclipse IDE?

前端 未结 7 1680
眼角桃花
眼角桃花 2021-01-23 04:38

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

7条回答
  •  佛祖请我去吃肉
    2021-01-23 04:51

    You can do it by creating a single method that invokes all the methods on your class. If you already have one of those even better. Take the Logo.java class from Junit as an example if I create this:

    private void ExposeAllCalledMethods()
    {
        Logo x = new Logo();
        x.loadImage("something");
        Graphics g;
        x.paint(g);     
    }
    

    Note I didn't need to call paintBackround() because paint() already calls it.

    Then I can right-click in the method name ExposeAllCalledMethods and select Open Call Hierarchy. Then in the call hierarchy window click on the Callees button (see the green arrow in the image) and open all the gray hierarchy arrows as shown in the image below. A complete list of all methods called by the current class is shown.

    Now I wish I had shown how to do this in my new Pluralsight Eclipse course.

    Hierarchy window showing all called methods.

提交回复
热议问题