language_server: fix "go to definition" to handle build_defs in plugins, add "show usages" that handle both build_defs, plugins and reverse dependencies#3485
Open
njskalski wants to merge 3 commits intothought-machine:masterfrom
Conversation
added 3 commits
February 5, 2026 17:08
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
Implements textDocument/references for the BUILD file language server. Supports two modes: 1. Function references: When cursor is on a function definition (e.g., `def go_repo(...)`), finds all BUILD files that call that function. 2. Build label references: When cursor is on a build label, uses query.FindRevdeps to find all targets that depend on it, then locates the exact string literal positions in their BUILD files.
- Add unit tests for textDocument/references functionality - Fix panic when package name is invalid (check graph before FindRevdeps) - Support finding references when cursor is on function call, not just definition - Add require dependency to BUILD for stricter test assertions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix "go to definition" to handle build_defs in plugins
add "show usages" that handle both build_defs, plugins and reverse dependencies
This makes the languageserver work like a charm, enabling good code navigation and all the magical AI tools that rely on LSP.