[mlir][sparse] implement non-permutation MapRef encoding (#69406)
[llvm-project.git] / clang-tools-extra / clangd / test / fixits-command-documentchanges.test
blobcd636c4df387ad7f774eeb8068b2df98a0c642f2
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"}}
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)"}]}}}
30 #      CHECK:  "id": 2,
31 # CHECK-NEXT:  "jsonrpc": "2.0",
32 # CHECK-NEXT:  "result": [
33 # CHECK-NEXT:    {
34 # CHECK-NEXT:      "arguments": [
35 # CHECK-NEXT:        {
36 # CHECK-NEXT:          "documentChanges": [
37 # CHECK-NEXT:            {
38 # CHECK-NEXT:              "edits": [
39 # CHECK-NEXT:                {
40 # CHECK-NEXT:                  "newText": "(",
41 # CHECK-NEXT:                  "range": {
42 # CHECK-NEXT:                    "end": {
43 # CHECK-NEXT:                      "character": 32,
44 # CHECK-NEXT:                      "line": 0
45 # CHECK-NEXT:                    },
46 # CHECK-NEXT:                    "start": {
47 # CHECK-NEXT:                      "character": 32,
48 # CHECK-NEXT:                      "line": 0
49 # CHECK-NEXT:                    }
50 # CHECK-NEXT:                  }
51 # CHECK-NEXT:                },
52 # CHECK-NEXT:                {
53 # CHECK-NEXT:                  "newText": ")",
54 # CHECK-NEXT:                  "range": {
55 # CHECK-NEXT:                    "end": {
56 # CHECK-NEXT:                      "character": 37,
57 # CHECK-NEXT:                      "line": 0
58 # CHECK-NEXT:                    },
59 # CHECK-NEXT:                    "start": {
60 # CHECK-NEXT:                      "character": 37,
61 # CHECK-NEXT:                      "line": 0
62 # CHECK-NEXT:                    }
63 # CHECK-NEXT:                  }
64 # CHECK-NEXT:                }
65 # CHECK-NEXT:              ],
66 # CHECK-NEXT:              "textDocument": {
67 # CHECK-NEXT:                "uri": "file://{{.*}}/foo.c",
68 # CHECK-NEXT:                "version": 0
69 # CHECK-NEXT:              }
70 # CHECK-NEXT:            }
71 # CHECK-NEXT:          ]
72 # CHECK-NEXT:        }
73 # CHECK-NEXT:      ],
74 # CHECK-NEXT:      "command": "clangd.applyFix",
75 # CHECK-NEXT:      "title": "Apply fix: place parentheses around the assignment to silence this warning"
76 # CHECK-NEXT:    },
77 # CHECK-NEXT:    {
78 # CHECK-NEXT:      "arguments": [
79 # CHECK-NEXT:        {
80 # CHECK-NEXT:          "documentChanges": [
81 # CHECK-NEXT:            {
82 # CHECK-NEXT:              "edits": [
83 # CHECK-NEXT:                {
84 # CHECK-NEXT:                  "newText": "==",
85 # CHECK-NEXT:                  "range": {
86 # CHECK-NEXT:                    "end": {
87 # CHECK-NEXT:                      "character": 35,
88 # CHECK-NEXT:                      "line": 0
89 # CHECK-NEXT:                    },
90 # CHECK-NEXT:                    "start": {
91 # CHECK-NEXT:                      "character": 34,
92 # CHECK-NEXT:                      "line": 0
93 # CHECK-NEXT:                    }
94 # CHECK-NEXT:                  }
95 # CHECK-NEXT:                }
96 # CHECK-NEXT:              ],
97 # CHECK-NEXT:              "textDocument": {
98 # CHECK-NEXT:                "uri": "file://{{.*}}/foo.c",
99 # CHECK-NEXT:                "version": 0
100 # CHECK-NEXT:              }
101 # CHECK-NEXT:            }
102 # CHECK-NEXT:          ]
103 # CHECK-NEXT:        }
104 # CHECK-NEXT:      ],
105 # CHECK-NEXT:      "command": "clangd.applyFix",
106 # CHECK-NEXT:      "title": "Apply fix: use '==' to turn this assignment into an equality comparison"
107 # CHECK-NEXT:    }
108 # CHECK-NEXT:  ]
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
112 #      CHECK:  "id": 3,
113 # CHECK-NEXT:  "jsonrpc": "2.0",
114 # CHECK-NEXT:  "result": [
115 # CHECK-NEXT:    {
116 # CHECK-NEXT:      "arguments": [
117 # CHECK-NEXT:        {
118 # CHECK-NEXT:          "documentChanges": [
119 # CHECK-NEXT:            {
120 # CHECK-NEXT:              "edits": [
121 # CHECK-NEXT:                {
122 # CHECK-NEXT:                  "newText": "(",
123 # CHECK-NEXT:                  "range": {
124 # CHECK-NEXT:                    "end": {
125 # CHECK-NEXT:                      "character": 32,
126 # CHECK-NEXT:                      "line": 0
127 # CHECK-NEXT:                    },
128 # CHECK-NEXT:                    "start": {
129 # CHECK-NEXT:                      "character": 32,
130 # CHECK-NEXT:                      "line": 0
131 # CHECK-NEXT:                    }
132 # CHECK-NEXT:                  }
133 # CHECK-NEXT:                },
134 # CHECK-NEXT:                {
135 # CHECK-NEXT:                  "newText": ")",
136 # CHECK-NEXT:                  "range": {
137 # CHECK-NEXT:                    "end": {
138 # CHECK-NEXT:                      "character": 37,
139 # CHECK-NEXT:                      "line": 0
140 # CHECK-NEXT:                    },
141 # CHECK-NEXT:                    "start": {
142 # CHECK-NEXT:                      "character": 37,
143 # CHECK-NEXT:                      "line": 0
144 # CHECK-NEXT:                    }
145 # CHECK-NEXT:                  }
146 # CHECK-NEXT:                }
147 # CHECK-NEXT:              ],
148 # CHECK-NEXT:              "textDocument": {
149 # CHECK-NEXT:                "uri": "file://{{.*}}/foo.c",
150 # CHECK-NEXT:                "version": 0
151 # CHECK-NEXT:              }
152 # CHECK-NEXT:            }
153 # CHECK-NEXT:          ]
154 # CHECK-NEXT:        }
155 # CHECK-NEXT:      ],
156 # CHECK-NEXT:      "command": "clangd.applyFix",
157 # CHECK-NEXT:      "title": "Apply fix: place parentheses around the assignment to silence this warning"
158 # CHECK-NEXT:    },
159 # CHECK-NEXT:    {
160 # CHECK-NEXT:      "arguments": [
161 # CHECK-NEXT:        {
162 # CHECK-NEXT:          "documentChanges": [
163 # CHECK-NEXT:            {
164 # CHECK-NEXT:              "edits": [
165 # CHECK-NEXT:                {
166 # CHECK-NEXT:                  "newText": "==",
167 # CHECK-NEXT:                  "range": {
168 # CHECK-NEXT:                    "end": {
169 # CHECK-NEXT:                      "character": 35,
170 # CHECK-NEXT:                      "line": 0
171 # CHECK-NEXT:                    },
172 # CHECK-NEXT:                    "start": {
173 # CHECK-NEXT:                      "character": 34,
174 # CHECK-NEXT:                      "line": 0
175 # CHECK-NEXT:                    }
176 # CHECK-NEXT:                  }
177 # CHECK-NEXT:                }
178 # CHECK-NEXT:              ],
179 # CHECK-NEXT:              "textDocument": {
180 # CHECK-NEXT:                "uri": "file://{{.*}}/foo.c",
181 # CHECK-NEXT:                "version": 0
182 # CHECK-NEXT:              }
183 # CHECK-NEXT:            }
184 # CHECK-NEXT:          ]
185 # CHECK-NEXT:        }
186 # CHECK-NEXT:      ],
187 # CHECK-NEXT:      "command": "clangd.applyFix",
188 # CHECK-NEXT:      "title": "Apply fix: use '==' to turn this assignment into an equality comparison"
189 # CHECK-NEXT:    }
190 # CHECK-NEXT:  ]
192 {"jsonrpc":"2.0","id":4,"method":"shutdown"}
194 {"jsonrpc":"2.0","method":"exit"}