java – 通过eclipse CallHierarchy获取IMethod的方法调用

我希望得到IMethod,IType或I
JavaElement,其中正在调用IMethod.我探讨了org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy.

我已经编写了这段代码但它没有给我任何包装或位置.

请指导我.

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);



}

最佳答案 你看过
Java: Find all callers of a method – get all methods that call a particular method 了吗?

点赞