summaryrefslogtreecommitdiffstats
path: root/test/clangd/execute-command.test
blob: 85d4b9b88d9f9675df9bcf738941ea159878fde4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
---
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///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": 37,
# CHECK-NEXT:            "line": 0
# CHECK-NEXT:          },
# CHECK-NEXT:          "start": {
# CHECK-NEXT:            "character": 32,
# CHECK-NEXT:            "line": 0
# CHECK-NEXT:          }
# CHECK-NEXT:        },
# CHECK-NEXT:        "severity": 2
# CHECK-NEXT:      }
# CHECK-NEXT:    ],
# CHECK-NEXT:    "uri": "file://{{.*}}/foo.c"
# CHECK-NEXT:  }
---
# No command name
{"jsonrpc":"2.0","id":3,"method":"workspace/executeCommand","params":{}}
---
# Invalid, non-scalar command name
{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command": {}}}
---
{"jsonrpc":"2.0","id":5,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","custom":"foo", "arguments":[{"changes":{"test:///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":")"}]}}]}}
---
# Arguments not a sequence.
{"jsonrpc":"2.0","id":6,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":"foo"}}
---
# Unknown command.
{"jsonrpc":"2.0","id":7,"method":"workspace/executeCommand","params":{"command":"mycommand"}}
---
# ApplyFix argument not a mapping node.
{"jsonrpc":"2.0","id":8,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","custom":"foo", "arguments":[""]}}
---
# Custom field in WorkspaceEdit
{"jsonrpc":"2.0","id":9,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"custom":"foo", "changes":{"test:///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":")"}]}}]}}
---
# changes in WorkspaceEdit with no mapping node
{"jsonrpc":"2.0","id":10,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":"foo"}]}}
---
# Custom field in WorkspaceEditChange
{"jsonrpc":"2.0","id":11,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///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":")"}], "custom":"foo"}}]}}
---
# No sequence node for TextEdits
{"jsonrpc":"2.0","id":12,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///foo.c":"bar"}}]}}
---
# No mapping node for TextEdit
{"jsonrpc":"2.0","id":13,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///foo.c":[""]}}]}}
---
# TextEdit not decoded
{"jsonrpc":"2.0","id":14,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///foo.c":[{"range":{"start":{"line":0,"character":32},"end":{"line":0,"character":32}},"newText":"("},{"range":"","newText":")"}]}}]}}
---
# Command name after arguments
{"jsonrpc":"2.0","id":9,"method":"workspace/executeCommand","params":{"arguments":[{"custom":"foo", "changes":{"test:///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":")"}]}}],"command":"clangd.applyFix"}}
---
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
---
{"jsonrpc":"2.0","method":"exit"}