redhat-developer / redhat-developer/lsp4ij

"Find Usages" sends incorrect line number to `textDocument/references` on decorated function in python

Open
#985 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
344
Forks
113
Avg merge
5h 22m
Merged PRs (30d)
15

Description

steps to reproduce

  1. clone my test repo at https://github.com/DetachHead/test/commit/9e5a8fe2d6e53e18cee73547f8bdce1536a6ab68
  2. run ./pw uv sync (installs basedpyright)
  3. install the pyright for pycharm plugin
  4. create a python file with the following contents:
    def foo[T](fn: T) -> T: ...
    
    
    @foo
    def bar(): ...
    
  5. right click bar and click "Find Usages"

actual result

it shows usages of foo instead:

Image

this is because the request is sending line 3 & character 1:

Image

i assume it's not accounting for the decorators when determining where the function name is located.

expected result

when doing the same thing in vscode, it correctly sends line 4 & character 5:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the decorated-function case from the linked test repository and inspect the Find Usages request sent to textDocument/references. Trace the request construction in the Java LSP client, comparing the reported line and character with the working VS Code request; done means the request targets bar rather than foo.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.