use of org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper in project eclipse.jdt.ls by eclipse.
the class CallHierarchyHandler method getIncomingCallItemsAt.
private List<CallHierarchyIncomingCall> getIncomingCallItemsAt(String uri, int line, int character, IProgressMonitor monitor) throws JavaModelException {
SubMonitor sub = SubMonitor.convert(monitor, 2);
IMember candidate = getCallHierarchyElement(uri, line, character, sub.split(1));
if (candidate == null) {
return null;
}
checkMonitor(monitor);
MethodWrapper wrapper = incomingMethodWrapperCache.containsKey(candidate) ? incomingMethodWrapperCache.get(candidate) : getCallRoot(candidate, true);
if (wrapper == null || !wrapper.canHaveChildren()) {
return null;
}
MethodWrapper[] calls = wrapper.getCalls(sub.split(1));
if (calls == null) {
return null;
}
List<CallHierarchyIncomingCall> result = new ArrayList<>();
for (MethodWrapper call : calls) {
Collection<CallLocation> callLocations = call.getMethodCall().getCallLocations();
if (callLocations != null) {
for (CallLocation location : callLocations) {
IOpenable openable = getOpenable(location);
Range callRange = getRange(openable, location);
CallHierarchyItem symbol = toCallHierarchyItem(call.getMember());
symbol.setSelectionRange(callRange);
List<Range> ranges = toCallRanges(callLocations);
result.add(new CallHierarchyIncomingCall(symbol, ranges));
}
}
IMember member = call.getMember();
if (member != null) {
incomingMethodWrapperCache.put(member, call);
}
}
return result;
}
use of org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper 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;
}
use of org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper 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;
}
use of org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper in project eclipse.jdt.ls by eclipse.
the class CallHierarchyHandler method getOutgoingCallItemsAt.
private List<CallHierarchyOutgoingCall> getOutgoingCallItemsAt(String uri, int line, int character, IProgressMonitor monitor) throws JavaModelException {
SubMonitor sub = SubMonitor.convert(monitor, 2);
IMember candidate = getCallHierarchyElement(uri, line, character, sub.split(1));
if (candidate == null) {
return null;
}
checkMonitor(monitor);
MethodWrapper wrapper = outgoingMethodWrapperCache.containsKey(candidate) ? outgoingMethodWrapperCache.get(candidate) : getCallRoot(candidate, false);
if (wrapper == null) {
return null;
}
MethodWrapper[] calls = wrapper.getCalls(sub.split(1));
if (calls == null) {
return null;
}
List<CallHierarchyOutgoingCall> result = new ArrayList<>();
for (MethodWrapper call : calls) {
Collection<CallLocation> callLocations = call.getMethodCall().getCallLocations();
if (callLocations != null && !callLocations.isEmpty()) {
List<Range> ranges = toCallRanges(callLocations);
for (int i = 0; i < callLocations.size(); i++) {
CallHierarchyItem symbol = toCallHierarchyItem(call.getMember());
result.add(new CallHierarchyOutgoingCall(symbol, ranges));
}
}
IMember member = call.getMember();
if (member != null) {
outgoingMethodWrapperCache.put(member, call);
}
}
return result;
}
use of org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper in project eclipse.jdt.ls by eclipse.
the class CallHierarchyHandler method getCallRoot.
private MethodWrapper getCallRoot(IMember member, boolean isIncomingCall) {
Assert.isNotNull(member, "member");
IMember[] members = { member };
CallHierarchyCore callHierarchy = CallHierarchyCore.getDefault();
final MethodWrapper[] result;
if (isIncomingCall) {
result = callHierarchy.getCallerRoots(members);
} else {
result = callHierarchy.getCalleeRoots(members);
}
if (result == null || result.length < 1) {
return null;
}
return result[0];
}
Aggregations