1 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
2 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true}}},"trace":"off"}}
4 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","text":"int main(int i, char **a) { if (i = 2) {}}"}}}
5 # CHECK: "method": "textDocument/publishDiagnostics",
6 # CHECK-NEXT: "params": {
7 # CHECK-NEXT: "diagnostics": [
9 # CHECK-NEXT: "code": "-Wparentheses",
10 # CHECK-NEXT: "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
11 # CHECK-NEXT: "range": {
12 # CHECK-NEXT: "end": {
13 # CHECK-NEXT: "character": 37,
14 # CHECK-NEXT: "line": 0
16 # CHECK-NEXT: "start": {
17 # CHECK-NEXT: "character": 32,
18 # CHECK-NEXT: "line": 0
21 # CHECK-NEXT: "severity": 2,
22 # CHECK-NEXT: "source": "clang"
25 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
26 # CHECK-NEXT: "version": 0
29 {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)"}]}}}
31 # CHECK-NEXT: "jsonrpc": "2.0",
32 # CHECK-NEXT: "result": [
34 # CHECK-NEXT: "arguments": [
36 # CHECK-NEXT: "documentChanges": [
38 # CHECK-NEXT: "edits": [
40 # CHECK-NEXT: "newText": "(",
41 # CHECK-NEXT: "range": {
42 # CHECK-NEXT: "end": {
43 # CHECK-NEXT: "character": 32,
44 # CHECK-NEXT: "line": 0
46 # CHECK-NEXT: "start": {
47 # CHECK-NEXT: "character": 32,
48 # CHECK-NEXT: "line": 0
53 # CHECK-NEXT: "newText": ")",
54 # CHECK-NEXT: "range": {
55 # CHECK-NEXT: "end": {
56 # CHECK-NEXT: "character": 37,
57 # CHECK-NEXT: "line": 0
59 # CHECK-NEXT: "start": {
60 # CHECK-NEXT: "character": 37,
61 # CHECK-NEXT: "line": 0
66 # CHECK-NEXT: "textDocument": {
67 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
68 # CHECK-NEXT: "version": 0
74 # CHECK-NEXT: "command": "clangd.applyFix",
75 # CHECK-NEXT: "title": "Apply fix: place parentheses around the assignment to silence this warning"
78 # CHECK-NEXT: "arguments": [
80 # CHECK-NEXT: "documentChanges": [
82 # CHECK-NEXT: "edits": [
84 # CHECK-NEXT: "newText": "==",
85 # CHECK-NEXT: "range": {
86 # CHECK-NEXT: "end": {
87 # CHECK-NEXT: "character": 35,
88 # CHECK-NEXT: "line": 0
90 # CHECK-NEXT: "start": {
91 # CHECK-NEXT: "character": 34,
92 # CHECK-NEXT: "line": 0
97 # CHECK-NEXT: "textDocument": {
98 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
99 # CHECK-NEXT: "version": 0
105 # CHECK-NEXT: "command": "clangd.applyFix",
106 # CHECK-NEXT: "title": "Apply fix: use '==' to turn this assignment into an equality comparison"
110 {"jsonrpc":"2.0","id":3,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)"}]}}}
111 # Make sure unused "code" and "source" fields ignored gracefully
113 # CHECK-NEXT: "jsonrpc": "2.0",
114 # CHECK-NEXT: "result": [
116 # CHECK-NEXT: "arguments": [
118 # CHECK-NEXT: "documentChanges": [
120 # CHECK-NEXT: "edits": [
122 # CHECK-NEXT: "newText": "(",
123 # CHECK-NEXT: "range": {
124 # CHECK-NEXT: "end": {
125 # CHECK-NEXT: "character": 32,
126 # CHECK-NEXT: "line": 0
128 # CHECK-NEXT: "start": {
129 # CHECK-NEXT: "character": 32,
130 # CHECK-NEXT: "line": 0
135 # CHECK-NEXT: "newText": ")",
136 # CHECK-NEXT: "range": {
137 # CHECK-NEXT: "end": {
138 # CHECK-NEXT: "character": 37,
139 # CHECK-NEXT: "line": 0
141 # CHECK-NEXT: "start": {
142 # CHECK-NEXT: "character": 37,
143 # CHECK-NEXT: "line": 0
148 # CHECK-NEXT: "textDocument": {
149 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
150 # CHECK-NEXT: "version": 0
156 # CHECK-NEXT: "command": "clangd.applyFix",
157 # CHECK-NEXT: "title": "Apply fix: place parentheses around the assignment to silence this warning"
160 # CHECK-NEXT: "arguments": [
162 # CHECK-NEXT: "documentChanges": [
164 # CHECK-NEXT: "edits": [
166 # CHECK-NEXT: "newText": "==",
167 # CHECK-NEXT: "range": {
168 # CHECK-NEXT: "end": {
169 # CHECK-NEXT: "character": 35,
170 # CHECK-NEXT: "line": 0
172 # CHECK-NEXT: "start": {
173 # CHECK-NEXT: "character": 34,
174 # CHECK-NEXT: "line": 0
179 # CHECK-NEXT: "textDocument": {
180 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
181 # CHECK-NEXT: "version": 0
187 # CHECK-NEXT: "command": "clangd.applyFix",
188 # CHECK-NEXT: "title": "Apply fix: use '==' to turn this assignment into an equality comparison"
192 {"jsonrpc":"2.0","id":4,"method":"shutdown"}
194 {"jsonrpc":"2.0","method":"exit"}