redhat-developer / redhat-developer/lsp4ij

"Find Usages" does not work for `LSPSemanticTokenElementType.DECLARATION`

Open
#1,281 11 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

At the moment, elements with type LSPSemanticTokenElementType.DECLARATION are not handled correctly by the "Find Usages" functionality.
As a result, it is impossible to invoke "Find Usages" for a class (or other declarations) that are recognized as DECLARATION type.

Actual behavior
  • I have a class defined in the project.
  • When trying to invoke Find Usages on it, the action does not work.
  • Investigation shows that the element is recognized as LSPSemanticTokenElementType.DECLARATION, and the current logic does not support this case.
Expected behavior
  • "Find Usages" should work correctly for elements with LSPSemanticTokenElementType.DECLARATION.
  • Classes and other declarations should be searchable as usage targets.

Tech notes:

The logic is here:

com.redhat.devtools.lsp4ij.features.semanticTokens.viewProvider.LSPSemanticTokensSingleRootFileViewProvider#getSemanticTokenReference

protected @Nullable PsiReference getSemanticTokenReference(int offset) { LSPSemanticToken semanticToken = this.isEnabled() ? this.getSemanticToken(offset) : null; LSPSemanticTokenElementType elementType = semanticToken != null ? semanticToken.getElementType() : null; return elementType == LSPSemanticTokenElementType.REFERENCE ? new LSPSemanticTokenPsiReference(semanticToken) : null; }

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 at com.redhat.devtools.lsp4ij.features.semanticTokens.viewProvider.LSPSemanticTokensSingleRootFileViewProvider#getSemanticTokenReference and inspect how semantic token element types become PSI references. Reproduce Find Usages for a class or declaration recognized as LSPSemanticTokenElementType.DECLARATION, then verify that declarations are searchable as usage targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools, search
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.