Search in sources :

Example 1 with CallHierarchyOutgoingCall

use of org.eclipse.lsp4j.CallHierarchyOutgoingCall 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;
}
Also used : SubMonitor(org.eclipse.core.runtime.SubMonitor) ArrayList(java.util.ArrayList) CallHierarchyItem(org.eclipse.lsp4j.CallHierarchyItem) Range(org.eclipse.lsp4j.Range) IMember(org.eclipse.jdt.core.IMember) CallHierarchyOutgoingCall(org.eclipse.lsp4j.CallHierarchyOutgoingCall) CallLocation(org.eclipse.jdt.internal.corext.callhierarchy.CallLocation) MethodWrapper(org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper)

Aggregations

ArrayList (java.util.ArrayList)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 IMember (org.eclipse.jdt.core.IMember)1 CallLocation (org.eclipse.jdt.internal.corext.callhierarchy.CallLocation)1 MethodWrapper (org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper)1 CallHierarchyItem (org.eclipse.lsp4j.CallHierarchyItem)1 CallHierarchyOutgoingCall (org.eclipse.lsp4j.CallHierarchyOutgoingCall)1 Range (org.eclipse.lsp4j.Range)1