mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Implements formatting support within LSP. Current implementation performs while file formatting, we just replace file with output of Carbon::Format() https://github.com/carbon-language/carbon-lang/pull/7687 independently improves formatting so that this output is somewhat decent. Assisted-With: Gemini / Antigravity
81 lines
2.9 KiB
Plaintext
81 lines
2.9 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:"capabilities": {}]]
|
|
[[@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: 394{{\r}}
|
|
// CHECK:STDOUT: {{\r}}
|
|
// CHECK:STDOUT: {
|
|
// CHECK:STDOUT: "id": 1,
|
|
// CHECK:STDOUT: "jsonrpc": "2.0",
|
|
// CHECK:STDOUT: "result": {
|
|
// CHECK:STDOUT: "capabilities": {
|
|
// CHECK:STDOUT: "declarationProvider": true,
|
|
// CHECK:STDOUT: "definitionProvider": true,
|
|
// CHECK:STDOUT: "documentFormattingProvider": true,
|
|
// CHECK:STDOUT: "documentSymbolProvider": true,
|
|
// CHECK:STDOUT: "hoverProvider": true,
|
|
// CHECK:STDOUT: "positionEncoding": "utf-16",
|
|
// CHECK:STDOUT: "referencesProvider": true,
|
|
// CHECK:STDOUT: "textDocumentSync": 2,
|
|
// CHECK:STDOUT: "typeDefinitionProvider": true
|
|
// 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: }
|