Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incoming call's hierarchy item's selectionRange behaves differently to all other (tested) servers #3184

Open
bstaletic opened this issue Jun 11, 2024 · 2 comments

Comments

@bstaletic
Copy link
Contributor

I am implementing call hierarchies in ycmd and ended up facing a situation where jdt.ls behaves differently than the other servers I have tested.

The response to the incomingCallHierarchy request looks something like this (irrelevant properties intentionally omitted):

{
    "from": {
        "range": spans_the_whole_function,
        "selectionRange": here_jdt_behaves_differently
    },
    "fromRanges": list_of_call_sites
}

Let's say function foo() is calling bar() and only once. With jdt.ls, selectionRange spans the call site. With other servers, selectionRange spans the name of foo().

This is important to me, because I want the ability to take the data from the incomingCallHierarchy and send a new prepareCallHierarchy request from the calling function (foo()).

I can also think of two other reasons why the current JDT behaviour is bad:

  1. It seems useless to have selectionRange == fromRanges[0], as it does not provide any additional information about the hierarchy item.
  2. The documentation for from seems to imply that the data should be about the calling function, not the called function.

Granted, I can achieve my goal with some JDT specific hacks, as JDT can do what I want if I switch to using range instead of selectionRange. However, that seems counterintuitive and would require server specific hacks for some other servers.

@bstaletic
Copy link
Contributor Author

For reference, here's a related discussion between myself and a rust-analyzer maintainer:

rust-lang/rust-analyzer#17388

@TomKrcmar2
Copy link

TomKrcmar2 commented Oct 9, 2024

I am experiencing the same issue. Typescript and pyright seem to provide the selectionRange of the caller, not the callsite, in this field.

The specification also suggests this, which seems to imply everything in from should refer to the caller, and callsite stuff should go in fromRanges:

export interface CallHierarchyIncomingCall {
	/**
	 * The item that makes the call.
	 */
	from: CallHierarchyItem;

	/**
	 * The ranges at which the calls appear. This is relative to the caller
	 * denoted by `this.from`.
	 */
	fromRanges: Range[];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants