z_mirror/luapls

git clone https://git.raiguard.me/z_mirror/luapls

Caleb HeuerFix testsa9d7242

main
8.4 KiB336 linesraw
1[
2  {
3    "Label": "complex_literal",
4    "Input": "a = {1, 2, three = 3, ['four'] = 4, [2+3] = 5}",
5    "AST": {
6      "Type": "Block",
7      "Range": {
8        "Start": 0,
9        "End": 46
10      },
11      "Stmts": [
12        {
13          "Type": "AssignmentStatement",
14          "Range": {
15            "Start": 0,
16            "End": 46
17          },
18          "Vars": [
19            {
20              "Type": "Identifier",
21              "Range": {
22                "Start": 0,
23                "End": 1
24              },
25              "Literal": "a"
26            }
27          ],
28          "Exps": [
29            {
30              "Type": "TableLiteral",
31              "Range": {
32                "Start": 4,
33                "End": 46
34              },
35              "Fields": [
36                {
37                  "Type": "TableField",
38                  "Range": {
39                    "Start": 5,
40                    "End": 6
41                  },
42                  "Key": null,
43                  "Value": {
44                    "Type": "NumberLiteral",
45                    "Range": {
46                      "Start": 5,
47                      "End": 6
48                    },
49                    "Literal": "1",
50                    "Value": 1
51                  }
52                },
53                {
54                  "Type": "TableField",
55                  "Range": {
56                    "Start": 8,
57                    "End": 9
58                  },
59                  "Key": null,
60                  "Value": {
61                    "Type": "NumberLiteral",
62                    "Range": {
63                      "Start": 8,
64                      "End": 9
65                    },
66                    "Literal": "2",
67                    "Value": 2
68                  }
69                },
70                {
71                  "Type": "TableField",
72                  "Range": {
73                    "Start": 11,
74                    "End": 20
75                  },
76                  "Key": {
77                    "Type": "Identifier",
78                    "Range": {
79                      "Start": 11,
80                      "End": 16
81                    },
82                    "Literal": "three"
83                  },
84                  "Value": {
85                    "Type": "NumberLiteral",
86                    "Range": {
87                      "Start": 19,
88                      "End": 20
89                    },
90                    "Literal": "3",
91                    "Value": 3
92                  }
93                },
94                {
95                  "Type": "TableField",
96                  "Range": {
97                    "Start": 22,
98                    "End": 34
99                  },
100                  "Key": {
101                    "Type": "StringLiteral",
102                    "Range": {
103                      "Start": 23,
104                      "End": 29
105                    },
106                    "Literal": "'four'"
107                  },
108                  "Value": {
109                    "Type": "NumberLiteral",
110                    "Range": {
111                      "Start": 33,
112                      "End": 34
113                    },
114                    "Literal": "4",
115                    "Value": 4
116                  }
117                },
118                {
119                  "Type": "TableField",
120                  "Range": {
121                    "Start": 36,
122                    "End": 45
123                  },
124                  "Key": {
125                    "Type": "InfixExpression",
126                    "Range": {
127                      "Start": 37,
128                      "End": 40
129                    },
130                    "Left": {
131                      "Type": "NumberLiteral",
132                      "Range": {
133                        "Start": 37,
134                        "End": 38
135                      },
136                      "Literal": "2",
137                      "Value": 2
138                    },
139                    "Operator": "plus",
140                    "Right": {
141                      "Type": "NumberLiteral",
142                      "Range": {
143                        "Start": 39,
144                        "End": 40
145                      },
146                      "Literal": "3",
147                      "Value": 3
148                    }
149                  },
150                  "Value": {
151                    "Type": "NumberLiteral",
152                    "Range": {
153                      "Start": 44,
154                      "End": 45
155                    },
156                    "Literal": "5",
157                    "Value": 5
158                  }
159                }
160              ],
161              "StartPos": 4
162            }
163          ]
164        }
165      ]
166    }
167  },
168  {
169    "Label": "missing_end_brace_eof",
170    "Input": "local tbl = {",
171    "AST": {
172      "Type": "Block",
173      "Range": {
174        "Start": 0,
175        "End": 13
176      },
177      "Stmts": [
178        {
179          "Type": "LocalStatement",
180          "Range": {
181            "Start": 0,
182            "End": 13
183          },
184          "Names": [
185            {
186              "Type": "Identifier",
187              "Range": {
188                "Start": 6,
189                "End": 9
190              },
191              "Literal": "tbl"
192            }
193          ],
194          "Exps": [
195            {
196              "Type": "TableLiteral",
197              "Range": {
198                "Start": 12,
199                "End": 13
200              },
201              "Fields": [
202                {
203                  "Type": "TableField",
204                  "Range": {
205                    "Start": 13,
206                    "End": 13
207                  },
208                  "Key": null,
209                  "Value": {
210                    "Type": "Invalid",
211                    "Range": {
212                      "Start": 13,
213                      "End": 13
214                    },
215                    "Token": {
216                      "Type": "eof",
217                      "Literal": "",
218                      "Pos": 13
219                    }
220                  }
221                }
222              ],
223              "StartPos": 12
224            }
225          ]
226        }
227      ]
228    },
229    "Errors": [
230      {
231        "Message": "Expected expression, got eof",
232        "Range": {
233          "Start": 13,
234          "End": 13
235        }
236      },
237      {
238        "Message": "Expected right brace, got eof",
239        "Range": {
240          "Start": 13,
241          "End": 13
242        }
243      }
244    ]
245  },
246  {
247    "Label": "unwrapped_expression_key",
248    "Input": "local tbl = {foo.bar = 'baz'}",
249    "AST": {
250      "Type": "Block",
251      "Range": {
252        "Start": 0,
253        "End": 29
254      },
255      "Stmts": [
256        {
257          "Type": "LocalStatement",
258          "Range": {
259            "Start": 0,
260            "End": 29
261          },
262          "Names": [
263            {
264              "Type": "Identifier",
265              "Range": {
266                "Start": 6,
267                "End": 9
268              },
269              "Literal": "tbl"
270            }
271          ],
272          "Exps": [
273            {
274              "Type": "TableLiteral",
275              "Range": {
276                "Start": 12,
277                "End": 29
278              },
279              "Fields": [
280                {
281                  "Type": "TableField",
282                  "Range": {
283                    "Start": 13,
284                    "End": 28
285                  },
286                  "Key": {
287                    "Type": "IndexExpression",
288                    "Range": {
289                      "Start": 13,
290                      "End": 20
291                    },
292                    "Left": {
293                      "Type": "Identifier",
294                      "Range": {
295                        "Start": 13,
296                        "End": 16
297                      },
298                      "Literal": "foo"
299                    },
300                    "Indexer": "dot",
301                    "Inner": {
302                      "Type": "Identifier",
303                      "Range": {
304                        "Start": 17,
305                        "End": 20
306                      },
307                      "Literal": "bar"
308                    }
309                  },
310                  "Value": {
311                    "Type": "StringLiteral",
312                    "Range": {
313                      "Start": 23,
314                      "End": 28
315                    },
316                    "Literal": "'baz'"
317                  }
318                }
319              ],
320              "StartPos": 12
321            }
322          ]
323        }
324      ]
325    },
326    "Errors": [
327      {
328        "Message": "Missing brackets around expression key",
329        "Range": {
330          "Start": 13,
331          "End": 20
332        }
333      }
334    ]
335  }
336]