Bump version to 19.1.0git
[llvm-project.git] / clang-tools-extra / clangd / test / fixits-codeaction.test
blob75d0fb012ffc814dd17e9dfa8cc5a782e253ca6d
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"}}
3 ---
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": [
8 # CHECK-NEXT:      {
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
15 # CHECK-NEXT:          },
16 # CHECK-NEXT:          "start": {
17 # CHECK-NEXT:            "character": 32,
18 # CHECK-NEXT:            "line": 0
19 # CHECK-NEXT:          }
20 # CHECK-NEXT:        },
21 # CHECK-NEXT:        "severity": 2,
22 # CHECK-NEXT:        "source": "clang"
23 # CHECK-NEXT:      }
24 # CHECK-NEXT:    ],
25 # CHECK-NEXT:    "uri": "file://{{.*}}/foo.c",
26 # CHECK-NEXT:    "version": 0
27 # CHECK-NEXT:  }
28 ---
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"}]}}}
30 #      CHECK:  "id": 2,
31 # CHECK-NEXT:  "jsonrpc": "2.0",
32 # CHECK-NEXT:  "result": [
33 # CHECK-NEXT:    {
34 # CHECK-NEXT:      "diagnostics": [
35 # CHECK-NEXT:        {
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
42 # CHECK-NEXT:            },
43 # CHECK-NEXT:            "start": {
44 # CHECK-NEXT:              "character": 32,
45 # CHECK-NEXT:              "line": 0
46 # CHECK-NEXT:            }
47 # CHECK-NEXT:          },
48 # CHECK-NEXT:          "severity": 2,
49 # CHECK-NEXT:          "source": "clang"
50 # CHECK-NEXT:        }
51 # CHECK-NEXT:      ],
52 # CHECK-NEXT:      "edit": {
53 # CHECK-NEXT:        "changes": {
54 # CHECK-NEXT:          "file://{{.*}}/foo.c": [
55 # CHECK-NEXT:            {
56 # CHECK-NEXT:              "newText": "(",
57 # CHECK-NEXT:              "range": {
58 # CHECK-NEXT:                "end": {
59 # CHECK-NEXT:                  "character": 32,
60 # CHECK-NEXT:                  "line": 0
61 # CHECK-NEXT:                },
62 # CHECK-NEXT:                "start": {
63 # CHECK-NEXT:                  "character": 32,
64 # CHECK-NEXT:                  "line": 0
65 # CHECK-NEXT:                }
66 # CHECK-NEXT:              }
67 # CHECK-NEXT:            },
68 # CHECK-NEXT:            {
69 # CHECK-NEXT:              "newText": ")",
70 # CHECK-NEXT:              "range": {
71 # CHECK-NEXT:                "end": {
72 # CHECK-NEXT:                  "character": 37,
73 # CHECK-NEXT:                  "line": 0
74 # CHECK-NEXT:                },
75 # CHECK-NEXT:                "start": {
76 # CHECK-NEXT:                  "character": 37,
77 # CHECK-NEXT:                  "line": 0
78 # CHECK-NEXT:                }
79 # CHECK-NEXT:              }
80 # CHECK-NEXT:            }
81 # CHECK-NEXT:          ]
82 # CHECK-NEXT:        }
83 # CHECK-NEXT:      },
84 # CHECK-NEXT:      "kind": "quickfix",
85 # CHECK-NEXT:      "title": "place parentheses around the assignment to silence this warning"
86 # CHECK-NEXT:    },
87 # CHECK-NEXT:    {
88 # CHECK-NEXT:      "diagnostics": [
89 # CHECK-NEXT:        {
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
96 # CHECK-NEXT:            },
97 # CHECK-NEXT:            "start": {
98 # CHECK-NEXT:              "character": 32,
99 # CHECK-NEXT:              "line": 0
100 # CHECK-NEXT:            }
101 # CHECK-NEXT:          },
102 # CHECK-NEXT:          "severity": 2,
103 # CHECK-NEXT:          "source": "clang"
104 # CHECK-NEXT:        }
105 # CHECK-NEXT:      ],
106 # CHECK-NEXT:      "edit": {
107 # CHECK-NEXT:        "changes": {
108 # CHECK-NEXT:          "file://{{.*}}/foo.c": [
109 # CHECK-NEXT:            {
110 # CHECK-NEXT:              "newText": "==",
111 # CHECK-NEXT:              "range": {
112 # CHECK-NEXT:                "end": {
113 # CHECK-NEXT:                  "character": 35,
114 # CHECK-NEXT:                  "line": 0
115 # CHECK-NEXT:                },
116 # CHECK-NEXT:                "start": {
117 # CHECK-NEXT:                  "character": 34,
118 # CHECK-NEXT:                  "line": 0
119 # CHECK-NEXT:                }
120 # CHECK-NEXT:              }
121 # CHECK-NEXT:            }
122 # CHECK-NEXT:          ]
123 # CHECK-NEXT:        }
124 # CHECK-NEXT:      },
125 # CHECK-NEXT:      "kind": "quickfix",
126 # CHECK-NEXT:      "title": "use '==' to turn this assignment into an equality comparison"
127 # CHECK-NEXT:    }
128 # CHECK-NEXT:  ]
130 {"jsonrpc":"2.0","id":4,"method":"shutdown"}
132 {"jsonrpc":"2.0","method":"exit"}