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

Ali*_*lan 5 java eclipse eclipse-plugin call-hierarchy

我正在寻找调用 IMethod 的 IMethod、IType 或 IJavaElement。我探索了 org.eclipse.jdt.internal.corex.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);



}
Run Code Online (Sandbox Code Playgroud)