Fix GCC build problem with 288f05f related to SmallVector. (#116958)
[llvm-project.git] / mlir / test / mlir-pdll-lsp-server / completion.test
blob76c062e474081f2c838a6518da3abfc2081872e6
1 // RUN: mlir-pdll-lsp-server -pdll-extra-dir %S -pdll-extra-dir %S/../../include  -lit-test < %s | FileCheck -strict-whitespace %s
2 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"pdll","capabilities":{},"trace":"off"}}
3 // -----
4 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{
5   "uri":"test:///foo.pdll",
6   "languageId":"pdll",
7   "version":1,
8   "text":"#include \"include/included.pdll\"\nConstraint ValueCst(value: Value);\nConstraint Cst();\nPattern FooPattern with benefit(1) {\nlet tuple = (value1 = _: Op, _: Op<test.op>);\nerase tuple.value1;\n}"
9 }}}
10 // -----
11 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{
12   "textDocument":{"uri":"test:///foo.pdll"},
13   "position":{"line":5,"character":12}
15 //      CHECK:  "id": 1
16 // CHECK-NEXT:  "jsonrpc": "2.0",
17 // CHECK-NEXT:  "result": {
18 // CHECK-NEXT:    "isIncomplete": false,
19 // CHECK-NEXT:    "items": [
20 // CHECK-NEXT:      {
21 // CHECK-NEXT:        "detail": "0: Op",
22 // CHECK-NEXT:        "filterText": "0",
23 // CHECK-NEXT:        "insertText": "0",
24 // CHECK-NEXT:        "insertTextFormat": 1,
25 // CHECK-NEXT:        "kind": 5,
26 // CHECK-NEXT:        "label": "0 (field #0)",
27 // CHECK-NEXT:        "sortText": "0"
28 // CHECK-NEXT:      },
29 // CHECK-NEXT:      {
30 // CHECK-NEXT:        "detail": "0: Op",
31 // CHECK-NEXT:        "filterText": "value1 (field #0)",
32 // CHECK-NEXT:        "insertText": "value1",
33 // CHECK-NEXT:        "insertTextFormat": 1,
34 // CHECK-NEXT:        "kind": 5,
35 // CHECK-NEXT:        "label": "value1 (field #0)",
36 // CHECK-NEXT:        "sortText": "0"
37 // CHECK-NEXT:      },
38 // CHECK-NEXT:      {
39 // CHECK-NEXT:        "detail": "1: Op<test.op>",
40 // CHECK-NEXT:        "filterText": "1",
41 // CHECK-NEXT:        "insertText": "1",
42 // CHECK-NEXT:        "insertTextFormat": 1,
43 // CHECK-NEXT:        "kind": 5,
44 // CHECK-NEXT:        "label": "1 (field #1)",
45 // CHECK-NEXT:        "sortText": "1"
46 // CHECK-NEXT:      }
47 // CHECK-NEXT:    ]
48 // CHECK-NEXT:  }
49 // -----
50 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{
51   "textDocument":{"uri":"test:///foo.pdll"},
52   "position":{"line":3,"character":23}
54 //      CHECK:  "id": 1
55 // CHECK-NEXT:  "jsonrpc": "2.0",
56 // CHECK-NEXT:  "result": {
57 // CHECK-NEXT:    "isIncomplete": false,
58 // CHECK-NEXT:    "items": [
59 // CHECK-NEXT:      {
60 // CHECK-NEXT:        "detail": "pattern metadata",
61 // CHECK-NEXT:        "documentation": {
62 // CHECK-NEXT:          "kind": "markdown",
63 // CHECK-NEXT:          "value": "The `benefit` of matching the pattern."
64 // CHECK-NEXT:        },
65 // CHECK-NEXT:        "insertText": "benefit($1)",
66 // CHECK-NEXT:        "insertTextFormat": 2,
67 // CHECK-NEXT:        "kind": 7,
68 // CHECK-NEXT:        "label": "benefit"
69 // CHECK-NEXT:      },
70 // CHECK-NEXT:      {
71 // CHECK-NEXT:        "detail": "pattern metadata",
72 // CHECK-NEXT:        "documentation": {
73 // CHECK-NEXT:          "kind": "markdown",
74 // CHECK-NEXT:          "value": "The pattern properly handles recursive application."
75 // CHECK-NEXT:        },
76 // CHECK-NEXT:        "insertTextFormat": 1,
77 // CHECK-NEXT:        "kind": 7,
78 // CHECK-NEXT:        "label": "recursion"
79 // CHECK-NEXT:      }
80 // CHECK-NEXT:    ]
81 // CHECK-NEXT:  }
82 // -----
83 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{
84   "textDocument":{"uri":"test:///foo.pdll"},
85   "position":{"line":4,"character":24}
87 //      CHECK:  "id": 1
88 // CHECK-NEXT:  "jsonrpc": "2.0",
89 // CHECK-NEXT:  "result": {
90 // CHECK-NEXT:    "isIncomplete": false,
91 // CHECK-NEXT:    "items": [
92 // CHECK-NEXT:      {
93 // CHECK-NEXT:        "detail": "Attr constraint",
94 // CHECK-NEXT:        "documentation": {
95 // CHECK-NEXT:          "kind": "markdown",
96 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::Attribute`"
97 // CHECK-NEXT:        },
98 // CHECK-NEXT:        "insertTextFormat": 1,
99 // CHECK-NEXT:        "kind": 7,
100 // CHECK-NEXT:        "label": "Attr",
101 // CHECK-NEXT:        "sortText": "0"
102 // CHECK-NEXT:      },
103 // CHECK-NEXT:      {
104 // CHECK-NEXT:        "detail": "Op constraint",
105 // CHECK-NEXT:        "documentation": {
106 // CHECK-NEXT:          "kind": "markdown",
107 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::Operation *`"
108 // CHECK-NEXT:        },
109 // CHECK-NEXT:        "insertTextFormat": 1,
110 // CHECK-NEXT:        "kind": 7,
111 // CHECK-NEXT:        "label": "Op",
112 // CHECK-NEXT:        "sortText": "0"
113 // CHECK-NEXT:      },
114 // CHECK-NEXT:      {
115 // CHECK-NEXT:        "detail": "Value constraint",
116 // CHECK-NEXT:        "documentation": {
117 // CHECK-NEXT:          "kind": "markdown",
118 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::Value`"
119 // CHECK-NEXT:        },
120 // CHECK-NEXT:        "insertTextFormat": 1,
121 // CHECK-NEXT:        "kind": 7,
122 // CHECK-NEXT:        "label": "Value",
123 // CHECK-NEXT:        "sortText": "0"
124 // CHECK-NEXT:      },
125 // CHECK-NEXT:      {
126 // CHECK-NEXT:        "detail": "ValueRange constraint",
127 // CHECK-NEXT:        "documentation": {
128 // CHECK-NEXT:          "kind": "markdown",
129 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::ValueRange`"
130 // CHECK-NEXT:        },
131 // CHECK-NEXT:        "insertTextFormat": 1,
132 // CHECK-NEXT:        "kind": 7,
133 // CHECK-NEXT:        "label": "ValueRange",
134 // CHECK-NEXT:        "sortText": "0"
135 // CHECK-NEXT:      },
136 // CHECK-NEXT:      {
137 // CHECK-NEXT:        "detail": "Type constraint",
138 // CHECK-NEXT:        "documentation": {
139 // CHECK-NEXT:          "kind": "markdown",
140 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::Type`"
141 // CHECK-NEXT:        },
142 // CHECK-NEXT:        "insertTextFormat": 1,
143 // CHECK-NEXT:        "kind": 7,
144 // CHECK-NEXT:        "label": "Type",
145 // CHECK-NEXT:        "sortText": "0"
146 // CHECK-NEXT:      },
147 // CHECK-NEXT:      {
148 // CHECK-NEXT:        "detail": "TypeRange constraint",
149 // CHECK-NEXT:        "documentation": {
150 // CHECK-NEXT:          "kind": "markdown",
151 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::TypeRange`"
152 // CHECK-NEXT:        },
153 // CHECK-NEXT:        "insertTextFormat": 1,
154 // CHECK-NEXT:        "kind": 7,
155 // CHECK-NEXT:        "label": "TypeRange",
156 // CHECK-NEXT:        "sortText": "0"
157 // CHECK-NEXT:      },
158 // CHECK-NEXT:      {
159 // CHECK-NEXT:        "detail": "Attr<type> constraint",
160 // CHECK-NEXT:        "documentation": {
161 // CHECK-NEXT:          "kind": "markdown",
162 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::Attribute`"
163 // CHECK-NEXT:        },
164 // CHECK-NEXT:        "insertText": "Attr<$1>",
165 // CHECK-NEXT:        "insertTextFormat": 2,
166 // CHECK-NEXT:        "kind": 7,
167 // CHECK-NEXT:        "label": "Attr<type>",
168 // CHECK-NEXT:        "sortText": "0"
169 // CHECK-NEXT:      },
170 // CHECK-NEXT:      {
171 // CHECK-NEXT:        "detail": "Value<type> constraint",
172 // CHECK-NEXT:        "documentation": {
173 // CHECK-NEXT:          "kind": "markdown",
174 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::Value`"
175 // CHECK-NEXT:        },
176 // CHECK-NEXT:        "insertText": "Value<$1>",
177 // CHECK-NEXT:        "insertTextFormat": 2,
178 // CHECK-NEXT:        "kind": 7,
179 // CHECK-NEXT:        "label": "Value<type>",
180 // CHECK-NEXT:        "sortText": "0"
181 // CHECK-NEXT:      },
182 // CHECK-NEXT:      {
183 // CHECK-NEXT:        "detail": "ValueRange<type> constraint",
184 // CHECK-NEXT:        "documentation": {
185 // CHECK-NEXT:          "kind": "markdown",
186 // CHECK-NEXT:          "value": "A single entity core constraint of type `mlir::ValueRange`"
187 // CHECK-NEXT:        },
188 // CHECK-NEXT:        "insertText": "ValueRange<$1>",
189 // CHECK-NEXT:        "insertTextFormat": 2,
190 // CHECK-NEXT:        "kind": 7,
191 // CHECK-NEXT:        "label": "ValueRange<type>",
192 // CHECK-NEXT:        "sortText": "0"
193 // CHECK-NEXT:      },
194 // CHECK-NEXT:      {
195 // CHECK-NEXT:        "detail": "(value: Value) -> Tuple<>",
196 // CHECK-NEXT:        "kind": 8,
197 // CHECK-NEXT:        "label": "ValueCst",
198 // CHECK-NEXT:        "sortText": "2_ValueCst"
199 // CHECK-NEXT:      }
200 // CHECK-NEXT:    ]
201 // CHECK-NEXT:  }
202 // -----
203 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{
204   "textDocument":{"uri":"test:///foo.pdll"},
205   "position":{"line":0,"character":18}
207 //      CHECK:  "id": 1
208 // CHECK-NEXT:  "jsonrpc": "2.0",
209 // CHECK-NEXT:  "result": {
210 // CHECK-NEXT:    "isIncomplete": false,
211 // CHECK-NEXT:    "items": [
212 // CHECK-NEXT:      {
213 // CHECK-NEXT:        "kind": 17,
214 // CHECK-NEXT:        "label": "included.pdll"
215 // CHECK-NEXT:      },
216 // CHECK-NEXT:      {
217 // CHECK-NEXT:        "kind": 17,
218 // CHECK-NEXT:        "label": "included.td"
219 // CHECK-NEXT:      }
220 // CHECK-NEXT:    ]
221 // CHECK-NEXT:  }
222 // -----
223 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
224 // -----
225 {"jsonrpc":"2.0","method":"exit"}