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
+3 -3
View File
@@ -9,15 +9,15 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/language_server/testdata/initialize.carbon
// --- STDIN
[[@LSP:initialize]]
[[@LSP-CALL:initialize]]
[[@LSP-NOTIFY:exit]]
// --- AUTOUPDATE-SPLIT
// CHECK:STDOUT: Content-Length: 148{{\r}}
// CHECK:STDOUT: Content-Length: 146{{\r}}
// CHECK:STDOUT: {{\r}}
// CHECK:STDOUT: {
// CHECK:STDOUT: "id": "1",
// CHECK:STDOUT: "id": 1,
// CHECK:STDOUT: "jsonrpc": "2.0",
// CHECK:STDOUT: "result": {
// CHECK:STDOUT: "capabilities": {
@@ -15,6 +15,6 @@
// --- AUTOUPDATE-SPLIT
// CHECK:STDERR: warning: -32602: in call to `textDocument/didOpen`, JSON parse failed: expected object [LanguageServerNotificationParseError]
// CHECK:STDERR: warning: -32602: in call to `textDocument/didOpen`, JSON parse failed: missing value at (root).textDocument [LanguageServerNotificationParseError]
// CHECK:STDERR:
// CHECK:STDOUT:
+1 -1
View File
@@ -18,6 +18,6 @@
// CHECK:STDERR: warning: unexpected reply to request ID "1": null [LanguageServerUnexpectedReply]
// CHECK:STDERR:
// CHECK:STDERR: warning: unexpected reply to request ID "2": 3 [LanguageServerUnexpectedReply]
// CHECK:STDERR: warning: unexpected reply to request ID "2": {"result":3} [LanguageServerUnexpectedReply]
// CHECK:STDERR:
// CHECK:STDOUT:
+3 -3
View File
@@ -10,18 +10,18 @@
// --- STDIN
[[@LSP:unknown-call]]
[[@LSP-CALL:unknown-call]]
[[@LSP-NOTIFY:exit]]
// --- AUTOUPDATE-SPLIT
// CHECK:STDOUT: Content-Length: 122{{\r}}
// CHECK:STDOUT: Content-Length: 120{{\r}}
// CHECK:STDOUT: {{\r}}
// CHECK:STDOUT: {
// CHECK:STDOUT: "error": {
// CHECK:STDOUT: "code": -32601,
// CHECK:STDOUT: "message": "unsupported call `unknown-call`"
// CHECK:STDOUT: },
// CHECK:STDOUT: "id": "1",
// CHECK:STDOUT: "id": 1,
// CHECK:STDOUT: "jsonrpc": "2.0"
// CHECK:STDOUT: }