diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 12:19:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | 267f48d215366fdf3bb90d655e3af33f723a6f94 (patch) | |
| tree | 9782e7d288ecd4efa4d38c70d6f3e84f9953ebd4 /src/lsp/lsp.zig | |
| parent | 4f57043e39396bc958a103f87466870cf8dafe00 (diff) | |
| download | pardes-267f48d215366fdf3bb90d655e3af33f723a6f94.tar.gz pardes-267f48d215366fdf3bb90d655e3af33f723a6f94.zip | |
Callers and Callees on a .zig file say the language server does not answer them
The in-process ZLS answers no call hierarchy, and no other backend speaks .zig, so the question went nowhere and came back empty, as if nothing called the function. A question no backend answers, or a server that advertises no call or type hierarchy, now answers @none with why, which the core says.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/lsp/lsp.zig')
| -rw-r--r-- | src/lsp/lsp.zig | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig index 9dd1da5a..7e5595fd 100644 --- a/src/lsp/lsp.zig +++ b/src/lsp/lsp.zig @@ -61,7 +61,18 @@ pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, req: Req, out: *s return b.query(gpa, arena, req, out); } if (req.kind == .explain and backends.len > 0) - try backends[0].query(gpa, arena, req, out); + return backends[0].query(gpa, arena, req, out); + // Nothing asked: said why, where an empty answer would read as nothing + // found. + inline for (backends) |b| if (b.speaks(req.path)) + return none(out, "the language server for this file does not answer it", .{}); + try none(out, "no language server for this file", .{}); +} + +/// The one line a backend answers with when it cannot answer at all, and +/// why: the core says it rather than "nothing found". +pub fn none(out: *std.Io.Writer, comptime fmt: []const u8, args: anytype) std.Io.Writer.Error!void { + try out.print("@none " ++ fmt ++ "\n", args); } // Called on server reader threads; the sink must copy text before returning. @@ -146,3 +157,14 @@ test "LSP encoders report every insufficient output capacity" { } } } + +test "a question no backend answers for a file says why rather than find nothing" { + if (backends.len == 0) return; + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + var buf: [256]u8 = undefined; + var out: std.Io.Writer = .fixed(&buf); + // The in-process ZLS answers no call hierarchy for a .zig file. + try query(std.testing.allocator, arena.allocator(), .{ .kind = .incoming_calls, .path = "/x/main.zig", .source = "", .offset = 0 }, &out); + try std.testing.expectStringStartsWith(out.buffered(), "@none "); +} |
