Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get method calls of IMethod through eclipse CallHierarchy

I am looking to get IMethod, IType or IJavaElement in which a IMethod is being called. I explored org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy. I have written this code but its not giving me anything in wrapper or in location. Please guide me.

public void getMethodCallers(IMethod[] methods){

CallHierarchy hierarchy = new CallHierarchy();
IJavaSearchScope searchScope= SearchEngine.createWorkspaceScope();
hierarchy.setSearchScope(searchScope);
CallLocation location = hierarchy.getCallLocation(method[0])
MethodWrapper [] wrapper = hierarchy.getCalleeRoots(methods);



}
like image 643
Ali Arslan Avatar asked Nov 04 '22 02:11

Ali Arslan


1 Answers

This post describes in detail how to achieve this: Java: Find all callers of a method – get all methods that call a particular method

like image 89
Heinrich Avatar answered Nov 12 '22 12:11

Heinrich