forked from OSchip/llvm-project
250 lines
11 KiB
Plaintext
250 lines
11 KiB
Plaintext
# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
|
|
# It is absolutely vital that this file has CRLF line endings.
|
|
#
|
|
Content-Length: 125
|
|
|
|
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
|
|
#
|
|
Content-Length: 180
|
|
|
|
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.c","languageId":"c","version":1,"text":"int main(int i, char **a) { if (i = 2) {}}"}}}
|
|
# CHECK: "method": "textDocument/publishDiagnostics",
|
|
# CHECK-NEXT: "params": {
|
|
# CHECK-NEXT: "diagnostics": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "message": "using the result of an assignment as a condition without parentheses",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "severity": 2
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "message": "place parentheses around the assignment to silence this warning",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "severity": 3
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "message": "use '==' to turn this assignment into an equality comparison",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "severity": 3
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ],
|
|
# CHECK-NEXT: "uri": "file:///foo.c"
|
|
# CHECK-NEXT: }
|
|
Content-Length: 746
|
|
|
|
{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
|
|
# CHECK: "id": 2,
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
# CHECK-NEXT: "result": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "arguments": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "changes": {
|
|
# CHECK-NEXT: "file:///foo.c": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": "(",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 32,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 32,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": ")",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 37,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 37,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ],
|
|
# CHECK-NEXT: "command": "clangd.applyFix",
|
|
# CHECK-NEXT: "title": "Apply FixIt place parentheses around the assignment to silence this warning"
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "arguments": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "changes": {
|
|
# CHECK-NEXT: "file:///foo.c": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": "==",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 34,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ],
|
|
# CHECK-NEXT: "command": "clangd.applyFix",
|
|
# CHECK-NEXT: "title": "Apply FixIt use '==' to turn this assignment into an equality comparison"
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
Content-Length: 771
|
|
|
|
{"jsonrpc":"2.0","id":3,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"code":"1","source":"foo","message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
|
|
# Make sure unused "code" and "source" fields ignored gracefully
|
|
# CHECK: "id": 3,
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
# CHECK-NEXT: "result": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "arguments": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "changes": {
|
|
# CHECK-NEXT: "file:///foo.c": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": "(",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 32,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 32,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": ")",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 37,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 37,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ],
|
|
# CHECK-NEXT: "command": "clangd.applyFix",
|
|
# CHECK-NEXT: "title": "Apply FixIt place parentheses around the assignment to silence this warning"
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "arguments": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "changes": {
|
|
# CHECK-NEXT: "file:///foo.c": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": "==",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 35,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 34,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ],
|
|
# CHECK-NEXT: "command": "clangd.applyFix",
|
|
# CHECK-NEXT: "title": "Apply FixIt use '==' to turn this assignment into an equality comparison"
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
Content-Length: 329
|
|
|
|
{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"file:///foo.c":[{"range":{"start":{"line":0,"character":32},"end":{"line":0,"character":32}},"newText":"("},{"range":{"start":{"line":0,"character":37},"end":{"line":0,"character":37}},"newText":")"}]}}]}}
|
|
# CHECK: "id": 4,
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
# CHECK-NEXT: "result": "Fix applied."
|
|
#
|
|
# CHECK: "id": 1,
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
# CHECK-NEXT: "method": "workspace/applyEdit",
|
|
# CHECK-NEXT: "params": {
|
|
# CHECK-NEXT: "edit": {
|
|
# CHECK-NEXT: "changes": {
|
|
# CHECK-NEXT: "file:///foo.c": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": "(",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 32,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 32,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "newText": ")",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 37,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 37,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: }
|
|
Content-Length: 44
|
|
|
|
{"jsonrpc":"2.0","id":4,"method":"shutdown"}
|
|
Content-Length: 33
|
|
|
|
{"jsonrpc":"2.0":"method":"exit"}
|