1 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
2 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{}}}},"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)", "code": "-Wparentheses", "source": "clang"}]}}}
31 # CHECK-NEXT: "jsonrpc": "2.0",
32 # CHECK-NEXT: "result": [
34 # CHECK-NEXT: "diagnostics": [
36 # CHECK-NEXT: "code": "-Wparentheses",
37 # CHECK-NEXT: "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
38 # CHECK-NEXT: "range": {
39 # CHECK-NEXT: "end": {
40 # CHECK-NEXT: "character": 37,
41 # CHECK-NEXT: "line": 0
43 # CHECK-NEXT: "start": {
44 # CHECK-NEXT: "character": 32,
45 # CHECK-NEXT: "line": 0
48 # CHECK-NEXT: "severity": 2,
49 # CHECK-NEXT: "source": "clang"
52 # CHECK-NEXT: "edit": {
53 # CHECK-NEXT: "changes": {
54 # CHECK-NEXT: "file://{{.*}}/foo.c": [
56 # CHECK-NEXT: "newText": "(",
57 # CHECK-NEXT: "range": {
58 # CHECK-NEXT: "end": {
59 # CHECK-NEXT: "character": 32,
60 # CHECK-NEXT: "line": 0
62 # CHECK-NEXT: "start": {
63 # CHECK-NEXT: "character": 32,
64 # CHECK-NEXT: "line": 0
69 # CHECK-NEXT: "newText": ")",
70 # CHECK-NEXT: "range": {
71 # CHECK-NEXT: "end": {
72 # CHECK-NEXT: "character": 37,
73 # CHECK-NEXT: "line": 0
75 # CHECK-NEXT: "start": {
76 # CHECK-NEXT: "character": 37,
77 # CHECK-NEXT: "line": 0
84 # CHECK-NEXT: "kind": "quickfix",
85 # CHECK-NEXT: "title": "place parentheses around the assignment to silence this warning"
88 # CHECK-NEXT: "diagnostics": [
90 # CHECK-NEXT: "code": "-Wparentheses",
91 # CHECK-NEXT: "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
92 # CHECK-NEXT: "range": {
93 # CHECK-NEXT: "end": {
94 # CHECK-NEXT: "character": 37,
95 # CHECK-NEXT: "line": 0
97 # CHECK-NEXT: "start": {
98 # CHECK-NEXT: "character": 32,
99 # CHECK-NEXT: "line": 0
102 # CHECK-NEXT: "severity": 2,
103 # CHECK-NEXT: "source": "clang"
106 # CHECK-NEXT: "edit": {
107 # CHECK-NEXT: "changes": {
108 # CHECK-NEXT: "file://{{.*}}/foo.c": [
110 # CHECK-NEXT: "newText": "==",
111 # CHECK-NEXT: "range": {
112 # CHECK-NEXT: "end": {
113 # CHECK-NEXT: "character": 35,
114 # CHECK-NEXT: "line": 0
116 # CHECK-NEXT: "start": {
117 # CHECK-NEXT: "character": 34,
118 # CHECK-NEXT: "line": 0
125 # CHECK-NEXT: "kind": "quickfix",
126 # CHECK-NEXT: "title": "use '==' to turn this assignment into an equality comparison"
130 {"jsonrpc":"2.0","id":4,"method":"shutdown"}
132 {"jsonrpc":"2.0","method":"exit"}