Add @LSP-CALL to file_test (#4896)

Adds @LSP-CALL and refactors LSP keyword handling to implicitly handle a
little more of the LSP structure. This is coming out of textDocument
call handling, where this at least reduces some boilerplate of
`"params": {...}`.
This commit is contained in:
Jon Ross-Perkins
2025-02-05 23:39:27 +00:00
committed by GitHub
parent a735a4e463
commit 34ceb6bbbe
7 changed files with 112 additions and 71 deletions
@@ -4,9 +4,9 @@
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //testing/file_test:file_test_base_test --test_arg=--file_tests=testing/file_test/testdata/lsp_calls.carbon
// TIP: bazel test //testing/file_test:file_test_base_test --test_arg=--file_tests=testing/file_test/testdata/lsp_keywords.carbon
// TIP: To dump output, run:
// TIP: bazel run //testing/file_test:file_test_base_test -- --dump_output --file_tests=testing/file_test/testdata/lsp_calls.carbon
// TIP: bazel run //testing/file_test:file_test_base_test -- --dump_output --file_tests=testing/file_test/testdata/lsp_keywords.carbon
// --- STDIN
[[@LSP:foo:]]
@@ -16,6 +16,10 @@
multi
line
]]
[[@LSP-CALL:bar:content]]
[[@LSP-CALL:baz:
multi
line]]
[[@LSP-REPLY:7]]
[[@LSP-REPLY:8:bar]]
[[@LSP-NOTIFY:exit]]
@@ -23,32 +27,42 @@ line
// --- AUTOUPDATE-SPLIT
// CHECK:STDERR: --- STDIN:
// CHECK:STDERR: Content-Length: 48
// CHECK:STDERR: Content-Length: 37
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "id": "1", "method": "foo"}
// CHECK:STDERR: {"jsonrpc": "2.0", "method": "foo"}
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 48
// CHECK:STDERR: Content-Length: 37
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "id": "2", "method": "foo"}
// CHECK:STDERR: {"jsonrpc": "2.0", "method": "foo"}
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 57
// CHECK:STDERR: Content-Length: 46
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "id": "3", "method": "bar", content}
// CHECK:STDERR: {"jsonrpc": "2.0", "method": "bar", content}
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 61
// CHECK:STDERR: Content-Length: 50
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "id": "4", "method": "baz",
// CHECK:STDERR: {"jsonrpc": "2.0", "method": "baz",
// CHECK:STDERR: multi
// CHECK:STDERR: line
// CHECK:STDERR: }
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 67
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "method": "bar", "id": 1, "params": {content}}
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 71
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "method": "baz", "id": 2, "params": {
// CHECK:STDERR: multi
// CHECK:STDERR: line}}
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 31
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "id": "7"}
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 36
// CHECK:STDERR: Content-Length: 48
// CHECK:STDERR:
// CHECK:STDERR: {"jsonrpc": "2.0", "id": "8", bar}
// CHECK:STDERR: {"jsonrpc": "2.0", "id": "8", "result": {bar}}
// CHECK:STDERR:
// CHECK:STDERR: Content-Length: 38
// CHECK:STDERR: