Fix GCC build problem with 288f05f related to SmallVector. (#116958)
[llvm-project.git] / mlir / test / mlir-lsp-server / completion.test
blob5f3c939fc97a4e5c6a88d3540ad444f0443be1f3
1 // RUN: mlir-lsp-server -lit-test < %s | FileCheck -strict-whitespace %s
2 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"mlir","capabilities":{},"trace":"off"}}
3 // -----
4 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{
5   "uri":"test:///foo.mlir",
6   "languageId":"mlir",
7   "version":1,
8   "text":"#attr = i32\n!alias = i32\nfunc.func private @foo(%arg: i32) -> i32 {\n%cast = \"builtin.unrealized_conversion_cast\"() : () -> (!pdl.value)\nreturn %"
9 }}}
10 // -----
11 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{
12   "textDocument":{"uri":"test:///foo.mlir"},
13   "position":{"line":2,"character":0}
15 // CHECK-LABEL: "id": 1
16 // CHECK-NEXT:  "jsonrpc": "2.0",
17 // CHECK-NEXT:  "result": {
18 // CHECK-NEXT:    "isIncomplete": false,
19 // CHECK-NEXT:    "items": [
20 // CHECK:           {
21 // CHECK:             "detail": "dialect",
22 // CHECK:             "insertTextFormat": 1,
23 // CHECK:             "kind": 9,
24 // CHECK:             "label": "builtin",
25 // CHECK:             "sortText": "3"
26 // CHECK:           },
27 // CHECK:           {
28 // CHECK:             "detail": "operation",
29 // CHECK:             "insertTextFormat": 1,
30 // CHECK:             "kind": 5,
31 // CHECK:             "label": "module",
32 // CHECK:             "sortText": "1"
33 // CHECK:           }
34 // CHECK:         ]
35 // CHECK-NEXT:  }
36 // -----
37 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{
38   "textDocument":{"uri":"test:///foo.mlir"},
39   "position":{"line":3,"character":9}
41 // CHECK-LABEL: "id": 2
42 // CHECK-NEXT:  "jsonrpc": "2.0",
43 // CHECK-NEXT:  "result": {
44 // CHECK-NEXT:    "isIncomplete": false,
45 // CHECK-NEXT:    "items": [
46 // CHECK:           {
47 // CHECK:             "detail": "dialect",
48 // CHECK:             "insertTextFormat": 1,
49 // CHECK:             "kind": 9,
50 // CHECK:             "label": "builtin",
51 // CHECK:             "sortText": "3"
52 // CHECK:           },
53 // CHECK-NOT:       "detail": "operation",
54 // CHECK:         ]
55 // CHECK-NEXT:  }
56 // -----
57 {"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{
58   "textDocument":{"uri":"test:///foo.mlir"},
59   "position":{"line":3,"character":17}
61 // CHECK-LABEL: "id": 3
62 // CHECK-NEXT:  "jsonrpc": "2.0",
63 // CHECK-NEXT:  "result": {
64 // CHECK-NEXT:    "isIncomplete": false,
65 // CHECK-NEXT:    "items": [
66 // CHECK-NOT:       "detail": "dialect",
67 // CHECK:           {
68 // CHECK:             "detail": "operation",
69 // CHECK:             "insertTextFormat": 1,
70 // CHECK:             "kind": 5,
71 // CHECK:             "label": "module",
72 // CHECK:             "sortText": "1"
73 // CHECK:           }
74 // CHECK:         ]
75 // CHECK-NEXT:  }
76 // -----
77 {"jsonrpc":"2.0","id":4,"method":"textDocument/completion","params":{
78   "textDocument":{"uri":"test:///foo.mlir"},
79   "position":{"line":4,"character":8}
81 // CHECK-LABEL: "id": 4
82 // CHECK-NEXT:  "jsonrpc": "2.0",
83 // CHECK-NEXT:  "result": {
84 // CHECK-NEXT:    "isIncomplete": false,
85 // CHECK-NEXT:    "items": [
86 // CHECK-NEXT:      {
87 // CHECK-NEXT:        "detail": "arg #0: i32",
88 // CHECK-NEXT:        "insertText": "arg",
89 // CHECK-NEXT:        "insertTextFormat": 1,
90 // CHECK-NEXT:        "kind": 6,
91 // CHECK-NEXT:        "label": "%arg"
92 // CHECK-NEXT:      },
93 // CHECK-NEXT:      {
94 // CHECK-NEXT:        "detail": "builtin.unrealized_conversion_cast: !pdl.value",
95 // CHECK-NEXT:        "insertText": "cast",
96 // CHECK-NEXT:        "insertTextFormat": 1,
97 // CHECK-NEXT:        "kind": 6,
98 // CHECK-NEXT:        "label": "%cast"
99 // CHECK-NEXT:      }
100 // CHECK:         ]
101 // CHECK-NEXT:  }
102 // -----
103 {"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{
104   "textDocument":{"uri":"test:///foo.mlir"},
105   "position":{"line":2,"character":10}
107 // CHECK-LABEL: "id": 5
108 // CHECK-NEXT:  "jsonrpc": "2.0",
109 // CHECK-NEXT:  "result": {
110 // CHECK-NEXT:    "isIncomplete": false,
111 // CHECK-NEXT:    "items": [
112 // CHECK-NEXT:      {
113 // CHECK-NEXT:        "detail": "optional",
114 // CHECK-NEXT:        "insertTextFormat": 1,
115 // CHECK-NEXT:        "kind": 14,
116 // CHECK-NEXT:        "label": "public",
117 // CHECK-NEXT:        "sortText": "0"
118 // CHECK-NEXT:      },
119 // CHECK-NEXT:      {
120 // CHECK-NEXT:        "detail": "optional",
121 // CHECK-NEXT:        "insertTextFormat": 1,
122 // CHECK-NEXT:        "kind": 14,
123 // CHECK-NEXT:        "label": "private",
124 // CHECK-NEXT:        "sortText": "0"
125 // CHECK-NEXT:      },
126 // CHECK-NEXT:      {
127 // CHECK-NEXT:        "detail": "optional",
128 // CHECK-NEXT:        "insertTextFormat": 1,
129 // CHECK-NEXT:        "kind": 14,
130 // CHECK-NEXT:        "label": "nested",
131 // CHECK-NEXT:        "sortText": "0"
132 // CHECK-NEXT:      }
133 // CHECK-NEXT:    ]
134 // CHECK-NEXT:  }
135 // -----
136 {"jsonrpc":"2.0","id":6,"method":"textDocument/completion","params":{
137   "textDocument":{"uri":"test:///foo.mlir"},
138   "position":{"line":0,"character":8}
140 // CHECK-LABEL: "id": 6
141 // CHECK-NEXT:  "jsonrpc": "2.0",
142 // CHECK-NEXT:  "result": {
143 // CHECK-NEXT:    "isIncomplete": false,
144 // CHECK-NEXT:    "items": [
145 // CHECK:           {
146 // CHECK:             "insertTextFormat": 1,
147 // CHECK:             "kind": 5,
148 // CHECK:             "label": "false"
149 // CHECK:           },
150 // CHECK:           {
151 // CHECK:             "insertTextFormat": 1,
152 // CHECK:             "kind": 5,
153 // CHECK:             "label": "loc"
154 // CHECK:           },
155 // CHECK:           {
156 // CHECK:             "insertTextFormat": 1,
157 // CHECK:             "kind": 5,
158 // CHECK:             "label": "true"
159 // CHECK:           },
160 // CHECK:           {
161 // CHECK:             "insertTextFormat": 1,
162 // CHECK:             "kind": 5,
163 // CHECK:             "label": "unit"
164 // CHECK:           }
165 // CHECK:    ]
166 // CHECK:  }
167 // -----
168 {"jsonrpc":"2.0","id":7,"method":"textDocument/completion","params":{
169   "textDocument":{"uri":"test:///foo.mlir"},
170   "position":{"line":3,"character":56}
172 // CHECK-LABEL: "id": 7
173 // CHECK-NEXT:  "jsonrpc": "2.0",
174 // CHECK-NEXT:  "result": {
175 // CHECK-NEXT:    "isIncomplete": false,
176 // CHECK-NEXT:    "items": [
177 // CHECK:           {
178 // CHECK:              "insertTextFormat": 1,
179 // CHECK:              "kind": 5,
180 // CHECK:             "label": "index"
181 // CHECK:           },
182 // CHECK:           {
183 // CHECK:             "insertTextFormat": 1,
184 // CHECK:             "kind": 5,
185 // CHECK:             "label": "none"
186 // CHECK:           },
187 // CHECK:           {
188 // CHECK:             "insertText": "i",
189 // CHECK:             "insertTextFormat": 1,
190 // CHECK:             "kind": 5,
191 // CHECK:             "label": "i<N>"
192 // CHECK:           }
193 // CHECK:         ]
194 // CHECK-NEXT:  }
195 // -----
196 {"jsonrpc":"2.0","id":8,"method":"textDocument/completion","params":{
197   "textDocument":{"uri":"test:///foo.mlir"},
198   "position":{"line":3,"character":57}
200 // CHECK-LABEL: "id": 8
201 // CHECK-NEXT:  "jsonrpc": "2.0",
202 // CHECK-NEXT:  "result": {
203 // CHECK-NEXT:    "isIncomplete": false,
204 // CHECK-NEXT:    "items": [
205 // CHECK:           {
206 // CHECK:             "detail": "dialect",
207 // CHECK:             "insertTextFormat": 1,
208 // CHECK:             "kind": 9,
209 // CHECK:             "label": "builtin",
210 // CHECK:             "sortText": "3"
211 // CHECK:           },
212 // CHECK:           {
213 // CHECK:             "detail": "alias: i32",
214 // CHECK:             "insertTextFormat": 1,
215 // CHECK:             "kind": 5,
216 // CHECK:             "label": "alias",
217 // CHECK:             "sortText": "2"
218 // CHECK:           }
219 // CHECK:         ]
220 // CHECK-NEXT:  }
221 // -----
222 {"jsonrpc":"2.0","id":9,"method":"textDocument/completion","params":{
223   "textDocument":{"uri":"test:///foo.mlir"},
224   "position":{"line":3,"character":61}
226 // CHECK-LABEL: "id": 9
227 // CHECK-NEXT:  "jsonrpc": "2.0",
228 // CHECK-NEXT:  "result": {
229 // CHECK-NEXT:    "isIncomplete": false,
230 // CHECK-NEXT:    "items": [
231 // CHECK-NEXT:      {
232 // CHECK-NEXT:        "insertTextFormat": 1,
233 // CHECK-NEXT:        "kind": 14,
234 // CHECK-NEXT:        "label": "attribute",
235 // CHECK-NEXT:        "sortText": "0"
236 // CHECK-NEXT:      },
237 // CHECK-NEXT:      {
238 // CHECK-NEXT:        "insertTextFormat": 1,
239 // CHECK-NEXT:        "kind": 14,
240 // CHECK-NEXT:        "label": "operation",
241 // CHECK-NEXT:        "sortText": "0"
242 // CHECK-NEXT:      },
243 // CHECK-NEXT:      {
244 // CHECK-NEXT:        "insertTextFormat": 1,
245 // CHECK-NEXT:        "kind": 14,
246 // CHECK-NEXT:        "label": "range",
247 // CHECK-NEXT:        "sortText": "0"
248 // CHECK-NEXT:      },
249 // CHECK-NEXT:      {
250 // CHECK-NEXT:        "insertTextFormat": 1,
251 // CHECK-NEXT:        "kind": 14,
252 // CHECK-NEXT:        "label": "type",
253 // CHECK-NEXT:        "sortText": "0"
254 // CHECK-NEXT:      },
255 // CHECK-NEXT:      {
256 // CHECK-NEXT:        "insertTextFormat": 1,
257 // CHECK-NEXT:        "kind": 14,
258 // CHECK-NEXT:        "label": "value",
259 // CHECK-NEXT:        "sortText": "0"
260 // CHECK-NEXT:      }
261 // CHECK-NEXT:    ]
262 // CHECK-NEXT:  }
263 // -----
264 {"jsonrpc":"2.0","id":10,"method":"shutdown"}
265 // -----
266 {"jsonrpc":"2.0","method":"exit"}