feat(lsp): add gopls navigation + Go semantic trace#1
Conversation
- Add sx lsp read-only Go navigation commands - Use gopls call_hierarchy for Go call edges in sx trace with caching - Support multi-module (go.work / nearest go.mod) workspaces - Improve trace path diversity + cache invalidation on reindex
|
@codex please review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14ade84f52
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let cache_path = self | ||
| .cache_dir | ||
| .join(format!("{}-{}.json", sym.symbol_id, file_hash)); |
There was a problem hiding this comment.
Include broader invalidation inputs in gopls call cache key
The call-hierarchy cache key is built from only symbol_id and the caller file hash, so after reindexing changes in other files (e.g., moved/renamed callees) this code can reuse stale cached callee locations and emit outdated or mis-resolved call edges until the caller file itself changes. That directly affects trace accuracy because call_edges_for_symbol trusts cached callee_path/callee_def_line when rebuilding edges.
Useful? React with 👍 / 👎.
src/lsp/go/mod.rs
Outdated
| if let Some(stripped) = uri.strip_prefix("file://") { | ||
| // file:///a/b/c.go | ||
| let s = stripped.trim_start_matches('/'); | ||
| let path = format!("/{}", s); | ||
| return Ok(PathBuf::from(path)); |
There was a problem hiding this comment.
Decode file URIs before path conversion
This conversion treats a file:// URI as a plain string path and does not percent-decode it, so URIs like file:///repo/My%20Dir/main.go become non-existent filesystem paths. In repositories with spaces or non-ASCII characters, sx lsp def can therefore return unusable locations (and downstream normalization/path classification can be wrong).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f204c0b6f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let should_attempt_gopls = if call_edges.is_empty() { | ||
| false |
There was a problem hiding this comment.
Bypass heuristic gate when --lsp forces gopls call edges
The --lsp flag is documented to force Go call-edge resolution via gopls, but this gate unconditionally sets should_attempt_gopls to false when no heuristic call edges are present, so forced mode can still skip call_edges_for_symbol entirely and return incomplete traces. This is especially visible for functions where the heuristic extractor misses calls (or only yields unresolved externals): sx trace --lsp will silently omit call edges instead of forcing LSP-derived ones.
Useful? React with 👍 / 👎.
Summary
sx lsp …read-only Go navigation viagopls(def/refs/impl/calls/symbols/ws-symbol/sig/highlight/check).sx tracesemantically accurate for Go call edges usinggopls call_hierarchy(auto when available), with--lsp/--no-lspoverrides and heuristic fallback.(symbol_id, file content_hash)under.sx/cache/gopls/call_hierarchy/.go.work, else nearestgo.mod).meta.index_generation.Testing
cargo test