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

[READY] Prefer selectionRange over range in LSP Location-like objects #1744

Closed
wants to merge 1 commit into from

Conversation

bstaletic
Copy link
Collaborator

@bstaletic bstaletic commented Jun 11, 2024

Currently, the LSP specification uses selectionRange in only three places:

  1. In selectionRange requests
  2. In hierarchy items
  3. In DocumentSymbol

Since ycmd does not support the first and the third point, we can ignore them..

As for hierarchy items, range property is meant to span the entire symbol definition, while selectionRange property is meant to span just the identifier of a symbol. Note that range also can include a docstring preceeding a function definition. That means that symbol[ 'range' ][ 'start' ] might be pointing at the start of a docstring, instead of pointing at the function name.

Current behaviour of the tested servers:

  • clangd and gopls put what should be in selectionRange into both properties.
  • jdt.ls and rust-analyzer properly differentiate these two ranges.

Not handling selectionRange properly leads to at least two problems:

  1. In hierarchy requests, the description of the root node can be wrong.
  2. Requesting outgoing calls of an incoming call picks the wrong location altogether.

This change is Reviewable

Currently, the LSP specification uses selectionRange in only three
places:

1. In `selectionRange` requests
2. In hierarchy items
3. In DocumentSymbol

Since ycmd does not support the first and the third point, we can ignore
them..

As for hierarchy items, `range` property is meant to span the entire
symbol definition, while `selectionRange` property is meant to span just
the identifier of a symbol. Note that `range` also can include a
docstring preceeding a function definition. That means that `symbol[
'range' ][ 'start' ]` might be pointing at the start of a docstring,
instead of pointing at the function name.

Current behaviour of the tested servers:

- `clangd` and `gopls` put what should be in `selectionRange` into both
  properties.
- `jdt.ls` and `rust-analyzer` properly differentiate these two ranges.

Not handling `selectionRange` properly leads to at least two problems:

1. In hierarchy requests, the description of the root node can be wrong.
2. Requesting outgoing calls of an incoming call picks the wrong
   location altogether.
@bstaletic
Copy link
Collaborator Author

Already discussed and a different approach was decided for #1733
Closing.

@bstaletic bstaletic closed this Jun 13, 2024
@bstaletic bstaletic deleted the selectionRange branch June 13, 2024 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant