mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 22:30:30 +00:00
Without this, diagnostics will linger after closing a file. This refactors towards a pattern of putting outgoing calls as methods on `Context`. I'm mixed on this, mainly thinking it's an improvement on using `outgoing` directly (because it shares the name and structure), might want to move it to a side-class later that is _only_ LSP wrappers. I could also make inheritance private on OutgoingMessages and these kinds of methods public there, but I'm hesitant to adopt that approach versus a type separation.
74 lines
2.6 KiB
Plaintext
74 lines
2.6 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/language_server/testdata/text_document/open_change_close.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/language_server/testdata/text_document/open_change_close.carbon
|
|
|
|
// --- STDIN
|
|
[[@LSP-CALL:initialize]]
|
|
[[@LSP-NOTIFY:textDocument/didOpen:
|
|
"textDocument": {"uri": "file:/test.carbon", "languageId": "carbon",
|
|
"text": "// Empty"}
|
|
]]
|
|
[[@LSP-NOTIFY:textDocument/didChange:
|
|
"textDocument": {"uri": "file:/test.carbon"},
|
|
"contentChanges": [{"text": "// Differently empty"}]
|
|
]]
|
|
[[@LSP-NOTIFY:textDocument/didClose:
|
|
"textDocument": {"uri": "file:/test.carbon"}
|
|
]]
|
|
[[@LSP-CALL:shutdown]]
|
|
[[@LSP-NOTIFY:exit]]
|
|
|
|
// --- AUTOUPDATE-SPLIT
|
|
|
|
// CHECK:STDOUT: Content-Length: 146{{\r}}
|
|
// CHECK:STDOUT: {{\r}}
|
|
// CHECK:STDOUT: {
|
|
// CHECK:STDOUT: "id": 1,
|
|
// CHECK:STDOUT: "jsonrpc": "2.0",
|
|
// CHECK:STDOUT: "result": {
|
|
// CHECK:STDOUT: "capabilities": {
|
|
// CHECK:STDOUT: "documentSymbolProvider": true,
|
|
// CHECK:STDOUT: "textDocumentSync": 1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }Content-Length: 144{{\r}}
|
|
// CHECK:STDOUT: {{\r}}
|
|
// CHECK:STDOUT: {
|
|
// CHECK:STDOUT: "jsonrpc": "2.0",
|
|
// CHECK:STDOUT: "method": "textDocument/publishDiagnostics",
|
|
// CHECK:STDOUT: "params": {
|
|
// CHECK:STDOUT: "diagnostics": [],
|
|
// CHECK:STDOUT: "uri": "file:///test.carbon"
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }Content-Length: 144{{\r}}
|
|
// CHECK:STDOUT: {{\r}}
|
|
// CHECK:STDOUT: {
|
|
// CHECK:STDOUT: "jsonrpc": "2.0",
|
|
// CHECK:STDOUT: "method": "textDocument/publishDiagnostics",
|
|
// CHECK:STDOUT: "params": {
|
|
// CHECK:STDOUT: "diagnostics": [],
|
|
// CHECK:STDOUT: "uri": "file:///test.carbon"
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }Content-Length: 144{{\r}}
|
|
// CHECK:STDOUT: {{\r}}
|
|
// CHECK:STDOUT: {
|
|
// CHECK:STDOUT: "jsonrpc": "2.0",
|
|
// CHECK:STDOUT: "method": "textDocument/publishDiagnostics",
|
|
// CHECK:STDOUT: "params": {
|
|
// CHECK:STDOUT: "diagnostics": [],
|
|
// CHECK:STDOUT: "uri": "file:///test.carbon"
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }Content-Length: 51{{\r}}
|
|
// CHECK:STDOUT: {{\r}}
|
|
// CHECK:STDOUT: {
|
|
// CHECK:STDOUT: "id": 2,
|
|
// CHECK:STDOUT: "jsonrpc": "2.0",
|
|
// CHECK:STDOUT: "result": null
|
|
// CHECK:STDOUT: }
|