if (element instanceof IMethod) {
IMethod method = (IMethod) element;
IMember[] members = new IMember[]{method};
MethodWrapper[] roots;
CallHierarchy callHierarchy = CallHierarchy.getDefault();
// Keep search scope for hierarchy in current project
callHierarchy.setSearchScope(
SearchEngine.createJavaSearchScope(new IJavaElement[] {
src.getJavaProject(),
}));
Comparator<MethodWrapper> comparator = null;
if (callees) {
roots = callHierarchy.getCalleeRoots(members);
} else {
roots = callHierarchy.getCallerRoots(members);
// Following Eclipse's GUI, callers are ordered
// alphabetically, callees by position in function.
comparator = new Comparator<MethodWrapper>() {
public int compare(MethodWrapper o1, MethodWrapper o2) {
return o1.getName().compareToIgnoreCase(o2.getName());