summaryrefslogtreecommitdiff
path: root/test/lspmock.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/lspmock.zig')
-rw-r--r--test/lspmock.zig11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/lspmock.zig b/test/lspmock.zig
index 8b5c73a8..0fd34677 100644
--- a/test/lspmock.zig
+++ b/test/lspmock.zig
@@ -207,7 +207,7 @@ fn handle(a: std.mem.Allocator, raw: []const u8) void {
\\"referencesProvider":true,"documentHighlightProvider":true,
\\"hoverProvider":true,"documentSymbolProvider":true,
\\"workspaceSymbolProvider":true,"renameProvider":true,
- \\"documentFormattingProvider":true,"codeActionProvider":true,
+ \\"documentFormattingProvider":true,"codeActionProvider":{{"resolveProvider":true}},
\\"completionProvider":{{}},
\\"callHierarchyProvider":true,"typeHierarchyProvider":true,
\\"diagnosticProvider":{{"interFileDependencies":false,"workspaceDiagnostics":false}},
@@ -283,7 +283,14 @@ fn handle(a: std.mem.Allocator, raw: []const u8) void {
} else if (std.mem.eql(u8, method, "textDocument/formatting")) {
reply(a, rid, "[{{\"range\":{s},\"newText\":\"// formatted by mock\\n\"}}]", .{range(a, 0, 0, 0)});
} else if (std.mem.eql(u8, method, "textDocument/codeAction")) {
- reply(a, rid, "[{{\"title\":\"mock action: extract\"}}]", .{});
+ // A title alone (a command's), one with its edit (a line put in
+ // at the top), and one whose edit is resolved when asked (its
+ // `data` the document's uri).
+ reply(a, rid, "[{{\"title\":\"mock action: extract\"}},{{\"title\":\"mock action: add a line\",\"edit\":{{\"changes\":{{\"{s}\":[{{\"range\":{s},\"newText\":\"// added by mock\\n\"}}]}}}}}},{{\"title\":\"mock action: rename add to sum\",\"data\":\"{s}\"}}]", .{ uri, range(a, 0, 0, 0), uri });
+ } else if (std.mem.eql(u8, method, "codeAction/resolve")) {
+ // main.rs's two calls of `add` (L3, L4) renamed.
+ const doc = str(get(params, "data")) orelse uri;
+ reply(a, rid, "{{\"title\":\"mock action: rename add to sum\",\"edit\":{{\"changes\":{{\"{s}\":[{{\"range\":{s},\"newText\":\"sum\"}},{{\"range\":{s},\"newText\":\"sum\"}}]}}}}}}", .{ doc, range(a, 3, 12, 15), range(a, 4, 12, 15) });
} else if (std.mem.eql(u8, method, "textDocument/completion")) {
reply(a, rid, "{{\"items\":[{{\"label\":\"alpha\",\"detail\":\"fn alpha()\"}},{{\"label\":\"beta\",\"detail\":\"fn beta()\"}}]}}", .{});
} else if (std.mem.eql(u8, method, "textDocument/diagnostic")) {