Skip to content

fix(langserver): support go-to-definition for plugin-defined rules#3491

Open
njskalski wants to merge 2 commits intothought-machine:masterfrom
njskalski:lsp-definition-fix-clean
Open

fix(langserver): support go-to-definition for plugin-defined rules#3491
njskalski wants to merge 2 commits intothought-machine:masterfrom
njskalski:lsp-definition-fix-clean

Conversation

@njskalski
Copy link
Contributor

This is a follow up MR from #3485 . As suggested by @toastwaffle I split the MR into two smaller pieces. This one is about go-to-definition in plugin rules.

I applied every single requested change. Furthermore, I removed all formatting changes my IDE did, to keep the patch short.

Andrzej J Skalski added 2 commits February 27, 2026 15:43
Previously, go-to-definition only worked for core builtin functions.
Plugin-defined rules like go_library, go_repo, etc. would return no
results because they were parsed by a different parser instance than
the one used by the language server.

Changes:
- Use parse.InitParser() to initialize the parser on BuildState, then
  get the same parser via parse.GetAspParser() for the language server
- Add periodic loading of function definitions (every 2 seconds) so
  go-to-definition works progressively while the full parse runs
- Add Range() method to cmap types to iterate over parsed ASTs
- Add AllFunctionsByFile() to asp.Parser to retrieve function definitions
- Fix file URIs to use absolute paths
@njskalski
Copy link
Contributor Author

@jwong-beep can I ask you for re-review?

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