Getting call hierarchy in Eclipse CDT

I am developing a plugin for Eclipse CDT and want to generate a hierarchy of function calls.

Is it possible that you do not need to go through the syntax tree of each file?

+4
source share
2 answers
CallHierarchy hierarchy = new CallHierarchy(); IJavaSearchScope searchScope = SearchEngine.createWorkspaceScope(); hierarchy.setSearchScope(searchScope); ArrayList<MethodCall> methodCalls = new ArrayList<MethodCall>(); MethodWrapper[] callerWrapper = hierarchy.getCallerRoots(methods); ArrayList<MethodWrapper> callsWrapper = new ArrayList<MethodWrapper>(); for (int i = 0; i < callerWrapper.length; i++) { callsWrapper.addAll(Arrays.asList(callerWrapper[i] .getCalls(new NullProgressMonitor()))); } for (int i = 0; i < callsWrapper.size(); i++) methodCalls.add(callsWrapper.get(i).getMethodCall()); // Now you will get method calls in methodCalls list. IMember member = methodCalls.get(0).getMember();// you will get one of // caller method in // member by this method 
+3
source

Here is a link to the code in the CDT that is used to populate the call hierarchy window: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/core/org.eclipse.cdt.ui/src /org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java

It looks pretty complicated, and everything is internal (which means its not a public API). Enjoy.

0
source

All Articles