Search in sources :

Example 1 with CallHierarchy

use of org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy in project gemoc-studio by eclipse.

the class CallHierarchyHelper method getCallersOf.

/**
 * Find methods calling method 'm'
 */
public static HashSet<IMethod> getCallersOf(IMethod m) {
    CallHierarchy callHierarchy = CallHierarchy.getDefault();
    IMember[] members = { m };
    MethodWrapper[] methodWrappers = callHierarchy.getCallerRoots(members);
    HashSet<IMethod> callers = new HashSet<IMethod>();
    for (MethodWrapper mw : methodWrappers) {
        MethodWrapper[] mw2 = mw.getCalls(new NullProgressMonitor());
        HashSet<IMethod> temp = getIMethods(mw2);
        callers.addAll(temp);
    }
    return callers;
}
Also used : CallHierarchy(org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MethodWrapper(org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper) IMethod(org.eclipse.jdt.core.IMethod) IMember(org.eclipse.jdt.core.IMember) HashSet(java.util.HashSet)

Example 2 with CallHierarchy

use of org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy in project gemoc-studio by eclipse.

the class CallHierarchyHelper method getCallLocationsOf.

/**
 * Find calling sites for method 'm'
 */
public static HashSet<CallLocation> getCallLocationsOf(IMethod m) {
    CallHierarchy callHierarchy = CallHierarchy.getDefault();
    IMember[] members = { m };
    MethodWrapper[] methodWrappers = callHierarchy.getCallerRoots(members);
    HashSet<CallLocation> callers = new HashSet<CallLocation>();
    for (MethodWrapper mw : methodWrappers) {
        MethodWrapper[] mw2 = mw.getCalls(new NullProgressMonitor());
        HashSet<CallLocation> temp = getCallLocations(mw2);
        callers.addAll(temp);
    }
    return callers;
}
Also used : CallHierarchy(org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CallLocation(org.eclipse.jdt.internal.corext.callhierarchy.CallLocation) MethodWrapper(org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper) IMember(org.eclipse.jdt.core.IMember) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IMember (org.eclipse.jdt.core.IMember)2 CallHierarchy (org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy)2 MethodWrapper (org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper)2 IMethod (org.eclipse.jdt.core.IMethod)1 CallLocation (org.eclipse.jdt.internal.corext.callhierarchy.CallLocation)1