In eclipse, there is "Call Hierarchy" to find the call graph(or method invoke relationship) easily. I want to find some APIs to extract this relationship. However I cannot find any existing tutorial to help me. Can anybody give me some clues? Mainly I want to know which class in JDT should be used and what should be the input.
By the way, the goal is to extract this invoke relationship, so some other way may also help. I tried SOOT, but I think JDT is better for it has both caller and callee.
I figured it out looking the JDT code for those features, it's a nice place to find about this things.
Basically you can start with the following code snippet:
CallHierarchy callHierarchy = CallHierarchy.getDefault();
IMember[] members = { method };
MethodWrapper[] callers = callHierarchy.getCallerRoots(members);
Where method
is the IMethod type from JDT.
With the resulting MethodWrappers you can get all information about it.
It's important to notice that the class CallHierarchy is internal, so it can break in a Eclipse release, but I don't know a public API for that.