@spyglassmc/mcdoc 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/binder/index.d.ts +3 -3
- package/lib/binder/index.js +12 -8
- package/lib/node/index.d.ts +205 -207
- package/lib/node/index.js +445 -301
- package/lib/parser/index.d.ts +1 -1
- package/lib/parser/index.js +13 -13
- package/lib/type/index.d.ts +1 -1
- package/lib/type/index.js +1 -0
- package/package.json +3 -3
package/lib/node/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { atArray, CommentNode, FloatNode, ResourceLocationNode, StringNode, } from '@spyglassmc/core';
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export var ModuleNode;
|
|
3
|
+
(function (ModuleNode) {
|
|
4
|
+
function is(node) {
|
|
4
5
|
return node?.type === 'mcdoc:module';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
}
|
|
7
|
+
ModuleNode.is = is;
|
|
8
|
+
})(ModuleNode || (ModuleNode = {}));
|
|
9
|
+
export var TopLevelNode;
|
|
10
|
+
(function (TopLevelNode) {
|
|
11
|
+
function is(node) {
|
|
9
12
|
return (CommentNode.is(node) ||
|
|
10
13
|
DispatchStatementNode.is(node) ||
|
|
11
14
|
EnumNode.is(node) ||
|
|
@@ -13,10 +16,12 @@ export const TopLevelNode = Object.freeze({
|
|
|
13
16
|
StructNode.is(node) ||
|
|
14
17
|
TypeAliasNode.is(node) ||
|
|
15
18
|
UseStatementNode.is(node));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
TopLevelNode.is = is;
|
|
21
|
+
})(TopLevelNode || (TopLevelNode = {}));
|
|
22
|
+
export var DispatchStatementNode;
|
|
23
|
+
(function (DispatchStatementNode) {
|
|
24
|
+
function destruct(node) {
|
|
20
25
|
return {
|
|
21
26
|
attributes: node.children.filter(AttributeNode.is),
|
|
22
27
|
location: node.children.find(ResourceLocationNode.is),
|
|
@@ -24,62 +29,81 @@ export const DispatchStatementNode = Object.freeze({
|
|
|
24
29
|
target: node.children.find(TypeNode.is),
|
|
25
30
|
typeParams: node.children.find(TypeParamBlockNode.is),
|
|
26
31
|
};
|
|
27
|
-
}
|
|
28
|
-
|
|
32
|
+
}
|
|
33
|
+
DispatchStatementNode.destruct = destruct;
|
|
34
|
+
function is(node) {
|
|
29
35
|
return (node?.type ===
|
|
30
36
|
'mcdoc:dispatch_statement');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
}
|
|
38
|
+
DispatchStatementNode.is = is;
|
|
39
|
+
})(DispatchStatementNode || (DispatchStatementNode = {}));
|
|
40
|
+
export var LiteralNode;
|
|
41
|
+
(function (LiteralNode) {
|
|
42
|
+
function is(node) {
|
|
35
43
|
return node?.type === 'mcdoc:literal';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
}
|
|
45
|
+
LiteralNode.is = is;
|
|
46
|
+
})(LiteralNode || (LiteralNode = {}));
|
|
47
|
+
export var IndexBodyNode;
|
|
48
|
+
(function (IndexBodyNode) {
|
|
49
|
+
function destruct(node) {
|
|
40
50
|
return {
|
|
41
51
|
parallelIndices: node.children.filter(IndexNode.is),
|
|
42
52
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
53
|
+
}
|
|
54
|
+
IndexBodyNode.destruct = destruct;
|
|
55
|
+
function is(node) {
|
|
45
56
|
return node?.type === 'mcdoc:index_body';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
}
|
|
58
|
+
IndexBodyNode.is = is;
|
|
59
|
+
})(IndexBodyNode || (IndexBodyNode = {}));
|
|
60
|
+
export var IndexNode;
|
|
61
|
+
(function (IndexNode) {
|
|
62
|
+
function is(node) {
|
|
50
63
|
return StaticIndexNode.is(node) || DynamicIndexNode.is(node);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
}
|
|
65
|
+
IndexNode.is = is;
|
|
66
|
+
})(IndexNode || (IndexNode = {}));
|
|
67
|
+
export var StaticIndexNode;
|
|
68
|
+
(function (StaticIndexNode) {
|
|
69
|
+
function is(node) {
|
|
55
70
|
return (LiteralNode.is(node) ||
|
|
56
71
|
IdentifierNode.is(node) ||
|
|
57
72
|
StringNode.is(node) ||
|
|
58
73
|
ResourceLocationNode.is(node));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
}
|
|
75
|
+
StaticIndexNode.is = is;
|
|
76
|
+
})(StaticIndexNode || (StaticIndexNode = {}));
|
|
77
|
+
export var IdentifierNode;
|
|
78
|
+
(function (IdentifierNode) {
|
|
79
|
+
function is(node) {
|
|
63
80
|
return node?.type === 'mcdoc:identifier';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
}
|
|
82
|
+
IdentifierNode.is = is;
|
|
83
|
+
})(IdentifierNode || (IdentifierNode = {}));
|
|
84
|
+
export var DynamicIndexNode;
|
|
85
|
+
(function (DynamicIndexNode) {
|
|
86
|
+
function destruct(node) {
|
|
68
87
|
return {
|
|
69
88
|
keys: node.children.filter(AccessorKeyNode.is),
|
|
70
89
|
};
|
|
71
|
-
}
|
|
72
|
-
|
|
90
|
+
}
|
|
91
|
+
DynamicIndexNode.destruct = destruct;
|
|
92
|
+
function is(node) {
|
|
73
93
|
return (node?.type === 'mcdoc:dynamic_index');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
}
|
|
95
|
+
DynamicIndexNode.is = is;
|
|
96
|
+
})(DynamicIndexNode || (DynamicIndexNode = {}));
|
|
97
|
+
export var AccessorKeyNode;
|
|
98
|
+
(function (AccessorKeyNode) {
|
|
99
|
+
function is(node) {
|
|
78
100
|
return (LiteralNode.is(node) || IdentifierNode.is(node) || StringNode.is(node));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
101
|
+
}
|
|
102
|
+
AccessorKeyNode.is = is;
|
|
103
|
+
})(AccessorKeyNode || (AccessorKeyNode = {}));
|
|
104
|
+
export var TypeNode;
|
|
105
|
+
(function (TypeNode) {
|
|
106
|
+
function is(node) {
|
|
83
107
|
return (AnyTypeNode.is(node) ||
|
|
84
108
|
BooleanTypeNode.is(node) ||
|
|
85
109
|
StringTypeNode.is(node) ||
|
|
@@ -93,57 +117,72 @@ export const TypeNode = Object.freeze({
|
|
|
93
117
|
ReferenceTypeNode.is(node) ||
|
|
94
118
|
DispatcherTypeNode.is(node) ||
|
|
95
119
|
UnionTypeNode.is(node));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
}
|
|
121
|
+
TypeNode.is = is;
|
|
122
|
+
})(TypeNode || (TypeNode = {}));
|
|
123
|
+
export var TypeBaseNode;
|
|
124
|
+
(function (TypeBaseNode) {
|
|
125
|
+
function destruct(node) {
|
|
100
126
|
return {
|
|
101
127
|
appendixes: node.children.filter((n) => IndexBodyNode.is(n) || TypeArgBlockNode.is(n)),
|
|
102
128
|
attributes: node.children.filter(AttributeNode.is),
|
|
103
129
|
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
130
|
+
}
|
|
131
|
+
TypeBaseNode.destruct = destruct;
|
|
132
|
+
})(TypeBaseNode || (TypeBaseNode = {}));
|
|
133
|
+
export var AttributeNode;
|
|
134
|
+
(function (AttributeNode) {
|
|
135
|
+
function destruct(node) {
|
|
108
136
|
return {
|
|
109
137
|
name: node.children.find(IdentifierNode.is),
|
|
110
138
|
value: node.children.find(AttributeValueNode.is),
|
|
111
139
|
};
|
|
112
|
-
}
|
|
113
|
-
|
|
140
|
+
}
|
|
141
|
+
AttributeNode.destruct = destruct;
|
|
142
|
+
function is(node) {
|
|
114
143
|
return node?.type === 'mcdoc:attribute';
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
}
|
|
145
|
+
AttributeNode.is = is;
|
|
146
|
+
})(AttributeNode || (AttributeNode = {}));
|
|
147
|
+
export var AttributeValueNode;
|
|
148
|
+
(function (AttributeValueNode) {
|
|
149
|
+
function is(node) {
|
|
119
150
|
return TypeNode.is(node) || AttributeTreeNode.is(node);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
151
|
+
}
|
|
152
|
+
AttributeValueNode.is = is;
|
|
153
|
+
})(AttributeValueNode || (AttributeValueNode = {}));
|
|
154
|
+
export var AttributeTreeNode;
|
|
155
|
+
(function (AttributeTreeNode) {
|
|
156
|
+
function destruct(node) {
|
|
124
157
|
return {
|
|
125
158
|
positional: node.children.find(AttributeTreePosValuesNode.is),
|
|
126
159
|
named: node.children.find(AttributeTreeNamedValuesNode.is),
|
|
127
160
|
};
|
|
128
|
-
}
|
|
129
|
-
|
|
161
|
+
}
|
|
162
|
+
AttributeTreeNode.destruct = destruct;
|
|
163
|
+
function is(node) {
|
|
130
164
|
return (node?.type ===
|
|
131
165
|
'mcdoc:attribute/tree');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
166
|
+
}
|
|
167
|
+
AttributeTreeNode.is = is;
|
|
168
|
+
})(AttributeTreeNode || (AttributeTreeNode = {}));
|
|
169
|
+
export var AttributeTreePosValuesNode;
|
|
170
|
+
(function (AttributeTreePosValuesNode) {
|
|
171
|
+
function destruct(node) {
|
|
136
172
|
return {
|
|
137
173
|
values: node.children.filter(AttributeValueNode.is),
|
|
138
174
|
};
|
|
139
|
-
}
|
|
140
|
-
|
|
175
|
+
}
|
|
176
|
+
AttributeTreePosValuesNode.destruct = destruct;
|
|
177
|
+
function is(node) {
|
|
141
178
|
return (node?.type ===
|
|
142
179
|
'mcdoc:attribute/tree/pos');
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
180
|
+
}
|
|
181
|
+
AttributeTreePosValuesNode.is = is;
|
|
182
|
+
})(AttributeTreePosValuesNode || (AttributeTreePosValuesNode = {}));
|
|
183
|
+
export var AttributeTreeNamedValuesNode;
|
|
184
|
+
(function (AttributeTreeNamedValuesNode) {
|
|
185
|
+
function destruct(node) {
|
|
147
186
|
const ans = {
|
|
148
187
|
values: [],
|
|
149
188
|
};
|
|
@@ -161,82 +200,105 @@ export const AttributeTreeNamedValuesNode = Object.freeze({
|
|
|
161
200
|
}
|
|
162
201
|
}
|
|
163
202
|
return ans;
|
|
164
|
-
}
|
|
165
|
-
|
|
203
|
+
}
|
|
204
|
+
AttributeTreeNamedValuesNode.destruct = destruct;
|
|
205
|
+
function is(node) {
|
|
166
206
|
return (node?.type ===
|
|
167
207
|
'mcdoc:attribute/tree/named');
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
208
|
+
}
|
|
209
|
+
AttributeTreeNamedValuesNode.is = is;
|
|
210
|
+
})(AttributeTreeNamedValuesNode || (AttributeTreeNamedValuesNode = {}));
|
|
211
|
+
export var TypeArgBlockNode;
|
|
212
|
+
(function (TypeArgBlockNode) {
|
|
213
|
+
function destruct(node) {
|
|
172
214
|
return {
|
|
173
215
|
args: node.children.filter(TypeNode.is),
|
|
174
216
|
};
|
|
175
|
-
}
|
|
176
|
-
|
|
217
|
+
}
|
|
218
|
+
TypeArgBlockNode.destruct = destruct;
|
|
219
|
+
function is(node) {
|
|
177
220
|
return (node?.type === 'mcdoc:type_arg_block');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
221
|
+
}
|
|
222
|
+
TypeArgBlockNode.is = is;
|
|
223
|
+
})(TypeArgBlockNode || (TypeArgBlockNode = {}));
|
|
224
|
+
export var AnyTypeNode;
|
|
225
|
+
(function (AnyTypeNode) {
|
|
226
|
+
function is(node) {
|
|
182
227
|
return node?.type === 'mcdoc:type/any';
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
228
|
+
}
|
|
229
|
+
AnyTypeNode.is = is;
|
|
230
|
+
})(AnyTypeNode || (AnyTypeNode = {}));
|
|
231
|
+
export var BooleanTypeNode;
|
|
232
|
+
(function (BooleanTypeNode) {
|
|
233
|
+
function is(node) {
|
|
187
234
|
return node?.type ===
|
|
188
235
|
'mcdoc:type/boolean';
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
236
|
+
}
|
|
237
|
+
BooleanTypeNode.is = is;
|
|
238
|
+
})(BooleanTypeNode || (BooleanTypeNode = {}));
|
|
239
|
+
export var IntRangeNode;
|
|
240
|
+
(function (IntRangeNode) {
|
|
241
|
+
function destruct(node) {
|
|
193
242
|
return destructRangeNode(node);
|
|
194
|
-
}
|
|
195
|
-
|
|
243
|
+
}
|
|
244
|
+
IntRangeNode.destruct = destruct;
|
|
245
|
+
function is(node) {
|
|
196
246
|
return node?.type === 'mcdoc:int_range';
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
247
|
+
}
|
|
248
|
+
IntRangeNode.is = is;
|
|
249
|
+
})(IntRangeNode || (IntRangeNode = {}));
|
|
250
|
+
export var LiteralTypeNode;
|
|
251
|
+
(function (LiteralTypeNode) {
|
|
252
|
+
function destruct(node) {
|
|
201
253
|
return {
|
|
202
254
|
value: node.children.find(LiteralTypeValueNode.is),
|
|
203
255
|
};
|
|
204
|
-
}
|
|
205
|
-
|
|
256
|
+
}
|
|
257
|
+
LiteralTypeNode.destruct = destruct;
|
|
258
|
+
function is(node) {
|
|
206
259
|
return node?.type ===
|
|
207
260
|
'mcdoc:type/literal';
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
261
|
+
}
|
|
262
|
+
LiteralTypeNode.is = is;
|
|
263
|
+
})(LiteralTypeNode || (LiteralTypeNode = {}));
|
|
264
|
+
export var LiteralTypeValueNode;
|
|
265
|
+
(function (LiteralTypeValueNode) {
|
|
266
|
+
function is(node) {
|
|
212
267
|
return (LiteralNode.is(node) || TypedNumberNode.is(node) || StringNode.is(node));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
268
|
+
}
|
|
269
|
+
LiteralTypeValueNode.is = is;
|
|
270
|
+
})(LiteralTypeValueNode || (LiteralTypeValueNode = {}));
|
|
271
|
+
export var TypedNumberNode;
|
|
272
|
+
(function (TypedNumberNode) {
|
|
273
|
+
function destruct(node) {
|
|
217
274
|
return {
|
|
218
275
|
value: node.children.find(FloatNode.is),
|
|
219
276
|
suffix: node.children.find(LiteralNode.is),
|
|
220
277
|
};
|
|
221
|
-
}
|
|
222
|
-
|
|
278
|
+
}
|
|
279
|
+
TypedNumberNode.destruct = destruct;
|
|
280
|
+
function is(node) {
|
|
223
281
|
return node?.type ===
|
|
224
282
|
'mcdoc:typed_number';
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
283
|
+
}
|
|
284
|
+
TypedNumberNode.is = is;
|
|
285
|
+
})(TypedNumberNode || (TypedNumberNode = {}));
|
|
286
|
+
export var NumericTypeNode;
|
|
287
|
+
(function (NumericTypeNode) {
|
|
288
|
+
function destruct(node) {
|
|
229
289
|
return {
|
|
230
290
|
numericKind: node.children.find(LiteralNode.is),
|
|
231
291
|
valueRange: node.children.find(FloatRangeNode.is) ||
|
|
232
292
|
node.children.find(IntRangeNode.is),
|
|
233
293
|
};
|
|
234
|
-
}
|
|
235
|
-
|
|
294
|
+
}
|
|
295
|
+
NumericTypeNode.destruct = destruct;
|
|
296
|
+
function is(node) {
|
|
236
297
|
return (node?.type ===
|
|
237
298
|
'mcdoc:type/numeric_type');
|
|
238
|
-
}
|
|
239
|
-
|
|
299
|
+
}
|
|
300
|
+
NumericTypeNode.is = is;
|
|
301
|
+
})(NumericTypeNode || (NumericTypeNode = {}));
|
|
240
302
|
export const RangeExclusiveChar = '<';
|
|
241
303
|
export function getRangeDelimiter(kind) {
|
|
242
304
|
const prefix = kind & 0b10 ? RangeExclusiveChar : '';
|
|
@@ -284,16 +346,20 @@ function destructRangeNode(node) {
|
|
|
284
346
|
return ans;
|
|
285
347
|
}
|
|
286
348
|
}
|
|
287
|
-
export
|
|
288
|
-
|
|
349
|
+
export var FloatRangeNode;
|
|
350
|
+
(function (FloatRangeNode) {
|
|
351
|
+
function destruct(node) {
|
|
289
352
|
return destructRangeNode(node);
|
|
290
|
-
}
|
|
291
|
-
|
|
353
|
+
}
|
|
354
|
+
FloatRangeNode.destruct = destruct;
|
|
355
|
+
function is(node) {
|
|
292
356
|
return node?.type === 'mcdoc:float_range';
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
357
|
+
}
|
|
358
|
+
FloatRangeNode.is = is;
|
|
359
|
+
})(FloatRangeNode || (FloatRangeNode = {}));
|
|
360
|
+
export var PrimitiveArrayTypeNode;
|
|
361
|
+
(function (PrimitiveArrayTypeNode) {
|
|
362
|
+
function destruct(node) {
|
|
297
363
|
let lengthRange;
|
|
298
364
|
let valueRange;
|
|
299
365
|
let afterBrackets = false;
|
|
@@ -315,55 +381,66 @@ export const PrimitiveArrayTypeNode = Object.freeze({
|
|
|
315
381
|
lengthRange,
|
|
316
382
|
valueRange,
|
|
317
383
|
};
|
|
318
|
-
}
|
|
319
|
-
|
|
384
|
+
}
|
|
385
|
+
PrimitiveArrayTypeNode.destruct = destruct;
|
|
386
|
+
function is(node) {
|
|
320
387
|
return (node?.type ===
|
|
321
388
|
'mcdoc:type/primitive_array');
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
389
|
+
}
|
|
390
|
+
PrimitiveArrayTypeNode.is = is;
|
|
391
|
+
})(PrimitiveArrayTypeNode || (PrimitiveArrayTypeNode = {}));
|
|
392
|
+
export var ListTypeNode;
|
|
393
|
+
(function (ListTypeNode) {
|
|
394
|
+
function destruct(node) {
|
|
326
395
|
return {
|
|
327
396
|
item: node.children.find(TypeNode.is),
|
|
328
397
|
lengthRange: node.children.find(IntRangeNode.is),
|
|
329
398
|
};
|
|
330
|
-
}
|
|
331
|
-
|
|
399
|
+
}
|
|
400
|
+
ListTypeNode.destruct = destruct;
|
|
401
|
+
function is(node) {
|
|
332
402
|
return node?.type === 'mcdoc:type/list';
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
403
|
+
}
|
|
404
|
+
ListTypeNode.is = is;
|
|
405
|
+
})(ListTypeNode || (ListTypeNode = {}));
|
|
406
|
+
export var StringTypeNode;
|
|
407
|
+
(function (StringTypeNode) {
|
|
408
|
+
function destruct(node) {
|
|
337
409
|
return {
|
|
338
410
|
lengthRange: node.children.find(IntRangeNode.is),
|
|
339
411
|
};
|
|
340
|
-
}
|
|
341
|
-
|
|
412
|
+
}
|
|
413
|
+
StringTypeNode.destruct = destruct;
|
|
414
|
+
function is(node) {
|
|
342
415
|
return node?.type === 'mcdoc:type/string';
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
416
|
+
}
|
|
417
|
+
StringTypeNode.is = is;
|
|
418
|
+
})(StringTypeNode || (StringTypeNode = {}));
|
|
419
|
+
export var TupleTypeNode;
|
|
420
|
+
(function (TupleTypeNode) {
|
|
421
|
+
function destruct(node) {
|
|
347
422
|
return {
|
|
348
423
|
items: node.children.filter(TypeNode.is),
|
|
349
424
|
};
|
|
350
|
-
}
|
|
351
|
-
|
|
425
|
+
}
|
|
426
|
+
TupleTypeNode.destruct = destruct;
|
|
427
|
+
function is(node) {
|
|
352
428
|
return node?.type === 'mcdoc:type/tuple';
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
429
|
+
}
|
|
430
|
+
TupleTypeNode.is = is;
|
|
431
|
+
})(TupleTypeNode || (TupleTypeNode = {}));
|
|
432
|
+
export var EnumNode;
|
|
433
|
+
(function (EnumNode) {
|
|
434
|
+
EnumNode.Kinds = new Set([
|
|
435
|
+
'byte',
|
|
436
|
+
'short',
|
|
437
|
+
'int',
|
|
438
|
+
'long',
|
|
439
|
+
'float',
|
|
440
|
+
'double',
|
|
441
|
+
'string',
|
|
442
|
+
]);
|
|
443
|
+
function destruct(node) {
|
|
367
444
|
return {
|
|
368
445
|
block: node.children.find(EnumBlockNode.is),
|
|
369
446
|
docComments: node.children.find(DocCommentsNode.is),
|
|
@@ -373,22 +450,25 @@ export const EnumNode = Object.freeze({
|
|
|
373
450
|
};
|
|
374
451
|
function getEnumKind(node) {
|
|
375
452
|
for (const literal of node.children.filter(LiteralNode.is)) {
|
|
376
|
-
if (
|
|
453
|
+
if (EnumNode.Kinds.has(literal.value)) {
|
|
377
454
|
return literal.value;
|
|
378
455
|
}
|
|
379
456
|
}
|
|
380
457
|
return undefined;
|
|
381
458
|
}
|
|
382
|
-
}
|
|
383
|
-
|
|
459
|
+
}
|
|
460
|
+
EnumNode.destruct = destruct;
|
|
461
|
+
function is(node) {
|
|
384
462
|
return node?.type === 'mcdoc:enum';
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
463
|
+
}
|
|
464
|
+
EnumNode.is = is;
|
|
465
|
+
})(EnumNode || (EnumNode = {}));
|
|
466
|
+
export var DocCommentsNode;
|
|
467
|
+
(function (DocCommentsNode) {
|
|
388
468
|
/**
|
|
389
469
|
* @returns The text content of this doc comment block.
|
|
390
470
|
*/
|
|
391
|
-
asText(node) {
|
|
471
|
+
function asText(node) {
|
|
392
472
|
if (!node) {
|
|
393
473
|
return undefined;
|
|
394
474
|
}
|
|
@@ -402,213 +482,272 @@ export const DocCommentsNode = Object.freeze({
|
|
|
402
482
|
comments = comments.map((s) => s.slice(1));
|
|
403
483
|
}
|
|
404
484
|
return comments.join('\n');
|
|
405
|
-
}
|
|
406
|
-
|
|
485
|
+
}
|
|
486
|
+
DocCommentsNode.asText = asText;
|
|
487
|
+
function is(node) {
|
|
407
488
|
return node?.type ===
|
|
408
489
|
'mcdoc:doc_comments';
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
490
|
+
}
|
|
491
|
+
DocCommentsNode.is = is;
|
|
492
|
+
})(DocCommentsNode || (DocCommentsNode = {}));
|
|
493
|
+
export var EnumBlockNode;
|
|
494
|
+
(function (EnumBlockNode) {
|
|
495
|
+
function destruct(node) {
|
|
413
496
|
return {
|
|
414
497
|
fields: node.children.filter(EnumFieldNode.is),
|
|
415
498
|
};
|
|
416
|
-
}
|
|
417
|
-
|
|
499
|
+
}
|
|
500
|
+
EnumBlockNode.destruct = destruct;
|
|
501
|
+
function is(node) {
|
|
418
502
|
return node?.type === 'mcdoc:enum/block';
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
503
|
+
}
|
|
504
|
+
EnumBlockNode.is = is;
|
|
505
|
+
})(EnumBlockNode || (EnumBlockNode = {}));
|
|
506
|
+
export var EnumFieldNode;
|
|
507
|
+
(function (EnumFieldNode) {
|
|
508
|
+
function destruct(node) {
|
|
423
509
|
return {
|
|
424
510
|
attributes: node.children.filter(AttributeNode.is),
|
|
425
511
|
identifier: node.children.find(IdentifierNode.is),
|
|
426
512
|
value: node.children.find(EnumValueNode.is),
|
|
427
513
|
};
|
|
428
|
-
}
|
|
429
|
-
|
|
514
|
+
}
|
|
515
|
+
EnumFieldNode.destruct = destruct;
|
|
516
|
+
function is(node) {
|
|
430
517
|
return node?.type === 'mcdoc:enum/field';
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
518
|
+
}
|
|
519
|
+
EnumFieldNode.is = is;
|
|
520
|
+
})(EnumFieldNode || (EnumFieldNode = {}));
|
|
521
|
+
export var EnumValueNode;
|
|
522
|
+
(function (EnumValueNode) {
|
|
523
|
+
function is(node) {
|
|
435
524
|
return TypedNumberNode.is(node) || StringNode.is(node);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
525
|
+
}
|
|
526
|
+
EnumValueNode.is = is;
|
|
527
|
+
})(EnumValueNode || (EnumValueNode = {}));
|
|
528
|
+
export var PrelimNode;
|
|
529
|
+
(function (PrelimNode) {
|
|
530
|
+
function is(node) {
|
|
440
531
|
return AttributeNode.is(node) || DocCommentsNode.is(node);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
532
|
+
}
|
|
533
|
+
PrelimNode.is = is;
|
|
534
|
+
})(PrelimNode || (PrelimNode = {}));
|
|
535
|
+
export var StructNode;
|
|
536
|
+
(function (StructNode) {
|
|
537
|
+
function destruct(node) {
|
|
445
538
|
return {
|
|
446
539
|
block: node.children.find(StructBlockNode.is),
|
|
447
540
|
docComments: node.children.find(DocCommentsNode.is),
|
|
448
541
|
identifier: node.children.find(IdentifierNode.is),
|
|
449
542
|
keyword: node.children.find(LiteralNode.is),
|
|
450
543
|
};
|
|
451
|
-
}
|
|
452
|
-
|
|
544
|
+
}
|
|
545
|
+
StructNode.destruct = destruct;
|
|
546
|
+
function is(node) {
|
|
453
547
|
return node?.type === 'mcdoc:struct';
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
548
|
+
}
|
|
549
|
+
StructNode.is = is;
|
|
550
|
+
})(StructNode || (StructNode = {}));
|
|
551
|
+
export var ReferenceTypeNode;
|
|
552
|
+
(function (ReferenceTypeNode) {
|
|
553
|
+
function destruct(node) {
|
|
458
554
|
return {
|
|
459
555
|
path: node.children.find(PathNode.is),
|
|
460
556
|
};
|
|
461
|
-
}
|
|
462
|
-
|
|
557
|
+
}
|
|
558
|
+
ReferenceTypeNode.destruct = destruct;
|
|
559
|
+
function is(node) {
|
|
463
560
|
return (node?.type ===
|
|
464
561
|
'mcdoc:type/reference');
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
562
|
+
}
|
|
563
|
+
ReferenceTypeNode.is = is;
|
|
564
|
+
})(ReferenceTypeNode || (ReferenceTypeNode = {}));
|
|
565
|
+
export var TypeParamBlockNode;
|
|
566
|
+
(function (TypeParamBlockNode) {
|
|
567
|
+
function destruct(node) {
|
|
469
568
|
return {
|
|
470
569
|
params: node.children.filter(TypeParamNode.is),
|
|
471
570
|
};
|
|
472
|
-
}
|
|
473
|
-
|
|
571
|
+
}
|
|
572
|
+
TypeParamBlockNode.destruct = destruct;
|
|
573
|
+
function is(node) {
|
|
474
574
|
return (node?.type ===
|
|
475
575
|
'mcdoc:type_param_block');
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
576
|
+
}
|
|
577
|
+
TypeParamBlockNode.is = is;
|
|
578
|
+
})(TypeParamBlockNode || (TypeParamBlockNode = {}));
|
|
579
|
+
export var TypeParamNode;
|
|
580
|
+
(function (TypeParamNode) {
|
|
581
|
+
function destruct(node) {
|
|
480
582
|
return {
|
|
481
583
|
// constraint: node.children.find(TypeNode.is),
|
|
482
584
|
identifier: node.children.find(IdentifierNode.is),
|
|
483
585
|
};
|
|
484
|
-
}
|
|
485
|
-
|
|
586
|
+
}
|
|
587
|
+
TypeParamNode.destruct = destruct;
|
|
588
|
+
function is(node) {
|
|
486
589
|
return node?.type === 'mcdoc:type_param';
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
590
|
+
}
|
|
591
|
+
TypeParamNode.is = is;
|
|
592
|
+
})(TypeParamNode || (TypeParamNode = {}));
|
|
593
|
+
export var PathNode;
|
|
594
|
+
(function (PathNode) {
|
|
595
|
+
function destruct(node) {
|
|
491
596
|
const lastChild = atArray(node?.children, -1);
|
|
492
597
|
return {
|
|
493
598
|
children: node?.children ?? [],
|
|
494
599
|
isAbsolute: node?.isAbsolute,
|
|
495
600
|
lastIdentifier: IdentifierNode.is(lastChild) ? lastChild : undefined,
|
|
496
601
|
};
|
|
497
|
-
}
|
|
498
|
-
|
|
602
|
+
}
|
|
603
|
+
PathNode.destruct = destruct;
|
|
604
|
+
function is(node) {
|
|
499
605
|
return node?.type === 'mcdoc:path';
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
606
|
+
}
|
|
607
|
+
PathNode.is = is;
|
|
608
|
+
})(PathNode || (PathNode = {}));
|
|
609
|
+
export var StructBlockNode;
|
|
610
|
+
(function (StructBlockNode) {
|
|
611
|
+
function destruct(node) {
|
|
504
612
|
return {
|
|
505
613
|
fields: node.children.filter(StructFieldNode.is),
|
|
506
614
|
};
|
|
507
|
-
}
|
|
508
|
-
|
|
615
|
+
}
|
|
616
|
+
StructBlockNode.destruct = destruct;
|
|
617
|
+
function is(node) {
|
|
509
618
|
return node?.type ===
|
|
510
619
|
'mcdoc:struct/block';
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
620
|
+
}
|
|
621
|
+
StructBlockNode.is = is;
|
|
622
|
+
})(StructBlockNode || (StructBlockNode = {}));
|
|
623
|
+
export var StructFieldNode;
|
|
624
|
+
(function (StructFieldNode) {
|
|
625
|
+
function is(node) {
|
|
515
626
|
return StructPairFieldNode.is(node) || StructSpreadFieldNode.is(node);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
627
|
+
}
|
|
628
|
+
StructFieldNode.is = is;
|
|
629
|
+
})(StructFieldNode || (StructFieldNode = {}));
|
|
630
|
+
export var StructPairFieldNode;
|
|
631
|
+
(function (StructPairFieldNode) {
|
|
632
|
+
function destruct(node) {
|
|
520
633
|
return {
|
|
521
634
|
attributes: node.children.filter(AttributeNode.is),
|
|
522
635
|
key: node.children.find(StructKeyNode.is),
|
|
523
636
|
type: node.children.find(TypeNode.is),
|
|
524
637
|
isOptional: node.isOptional,
|
|
525
638
|
};
|
|
526
|
-
}
|
|
527
|
-
|
|
639
|
+
}
|
|
640
|
+
StructPairFieldNode.destruct = destruct;
|
|
641
|
+
function is(node) {
|
|
528
642
|
return (node?.type ===
|
|
529
643
|
'mcdoc:struct/field/pair');
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
644
|
+
}
|
|
645
|
+
StructPairFieldNode.is = is;
|
|
646
|
+
})(StructPairFieldNode || (StructPairFieldNode = {}));
|
|
647
|
+
export var StructKeyNode;
|
|
648
|
+
(function (StructKeyNode) {
|
|
649
|
+
function is(node) {
|
|
534
650
|
return (StringNode.is(node) ||
|
|
535
651
|
IdentifierNode.is(node) ||
|
|
536
652
|
StructMapKeyNode.is(node));
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
653
|
+
}
|
|
654
|
+
StructKeyNode.is = is;
|
|
655
|
+
})(StructKeyNode || (StructKeyNode = {}));
|
|
656
|
+
export var StructMapKeyNode;
|
|
657
|
+
(function (StructMapKeyNode) {
|
|
658
|
+
function destruct(node) {
|
|
541
659
|
return {
|
|
542
660
|
type: node.children.find(TypeNode.is),
|
|
543
661
|
};
|
|
544
|
-
}
|
|
545
|
-
|
|
662
|
+
}
|
|
663
|
+
StructMapKeyNode.destruct = destruct;
|
|
664
|
+
function is(node) {
|
|
546
665
|
return (node?.type === 'mcdoc:struct/map_key');
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
666
|
+
}
|
|
667
|
+
StructMapKeyNode.is = is;
|
|
668
|
+
})(StructMapKeyNode || (StructMapKeyNode = {}));
|
|
669
|
+
export var StructSpreadFieldNode;
|
|
670
|
+
(function (StructSpreadFieldNode) {
|
|
671
|
+
function destruct(node) {
|
|
551
672
|
return {
|
|
552
673
|
attributes: node.children.filter(AttributeNode.is),
|
|
553
674
|
type: node.children.find(TypeNode.is),
|
|
554
675
|
};
|
|
555
|
-
}
|
|
556
|
-
|
|
676
|
+
}
|
|
677
|
+
StructSpreadFieldNode.destruct = destruct;
|
|
678
|
+
function is(node) {
|
|
557
679
|
return (node?.type ===
|
|
558
680
|
'mcdoc:struct/field/spread');
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
681
|
+
}
|
|
682
|
+
StructSpreadFieldNode.is = is;
|
|
683
|
+
})(StructSpreadFieldNode || (StructSpreadFieldNode = {}));
|
|
684
|
+
export var DispatcherTypeNode;
|
|
685
|
+
(function (DispatcherTypeNode) {
|
|
686
|
+
function destruct(node) {
|
|
563
687
|
return {
|
|
564
688
|
location: node.children.find(ResourceLocationNode.is),
|
|
565
689
|
index: node.children.find(IndexBodyNode.is),
|
|
566
690
|
};
|
|
567
|
-
}
|
|
568
|
-
|
|
691
|
+
}
|
|
692
|
+
DispatcherTypeNode.destruct = destruct;
|
|
693
|
+
function is(node) {
|
|
569
694
|
return (node?.type ===
|
|
570
695
|
'mcdoc:type/dispatcher');
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
696
|
+
}
|
|
697
|
+
DispatcherTypeNode.is = is;
|
|
698
|
+
})(DispatcherTypeNode || (DispatcherTypeNode = {}));
|
|
699
|
+
export var UnionTypeNode;
|
|
700
|
+
(function (UnionTypeNode) {
|
|
701
|
+
function destruct(node) {
|
|
575
702
|
return {
|
|
576
703
|
members: node.children.filter(TypeNode.is),
|
|
577
704
|
};
|
|
578
|
-
}
|
|
579
|
-
|
|
705
|
+
}
|
|
706
|
+
UnionTypeNode.destruct = destruct;
|
|
707
|
+
function is(node) {
|
|
580
708
|
return node?.type === 'mcdoc:type/union';
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
709
|
+
}
|
|
710
|
+
UnionTypeNode.is = is;
|
|
711
|
+
})(UnionTypeNode || (UnionTypeNode = {}));
|
|
712
|
+
export var InjectionNode;
|
|
713
|
+
(function (InjectionNode) {
|
|
714
|
+
function destruct(node) {
|
|
585
715
|
return {
|
|
586
716
|
injection: node.children.find(InjectionContentNode.is),
|
|
587
717
|
};
|
|
588
|
-
}
|
|
589
|
-
|
|
718
|
+
}
|
|
719
|
+
InjectionNode.destruct = destruct;
|
|
720
|
+
function is(node) {
|
|
590
721
|
return node?.type === 'mcdoc:injection';
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
722
|
+
}
|
|
723
|
+
InjectionNode.is = is;
|
|
724
|
+
})(InjectionNode || (InjectionNode = {}));
|
|
725
|
+
export var InjectionContentNode;
|
|
726
|
+
(function (InjectionContentNode) {
|
|
727
|
+
function is(node) {
|
|
595
728
|
return EnumInjectionNode.is(node) || StructInjectionNode.is(node);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
729
|
+
}
|
|
730
|
+
InjectionContentNode.is = is;
|
|
731
|
+
})(InjectionContentNode || (InjectionContentNode = {}));
|
|
732
|
+
export var EnumInjectionNode;
|
|
733
|
+
(function (EnumInjectionNode) {
|
|
734
|
+
function is(node) {
|
|
600
735
|
return (node?.type ===
|
|
601
736
|
'mcdoc:injection/enum');
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
737
|
+
}
|
|
738
|
+
EnumInjectionNode.is = is;
|
|
739
|
+
})(EnumInjectionNode || (EnumInjectionNode = {}));
|
|
740
|
+
export var StructInjectionNode;
|
|
741
|
+
(function (StructInjectionNode) {
|
|
742
|
+
function is(node) {
|
|
606
743
|
return (node?.type ===
|
|
607
744
|
'mcdoc:injection/struct');
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
745
|
+
}
|
|
746
|
+
StructInjectionNode.is = is;
|
|
747
|
+
})(StructInjectionNode || (StructInjectionNode = {}));
|
|
748
|
+
export var TypeAliasNode;
|
|
749
|
+
(function (TypeAliasNode) {
|
|
750
|
+
function destruct(node) {
|
|
612
751
|
return {
|
|
613
752
|
attributes: node.children.filter(AttributeNode.is),
|
|
614
753
|
docComments: node.children.find(DocCommentsNode.is),
|
|
@@ -617,20 +756,25 @@ export const TypeAliasNode = Object.freeze({
|
|
|
617
756
|
typeParams: node.children.find(TypeParamBlockNode.is),
|
|
618
757
|
rhs: node.children.find(TypeNode.is),
|
|
619
758
|
};
|
|
620
|
-
}
|
|
621
|
-
|
|
759
|
+
}
|
|
760
|
+
TypeAliasNode.destruct = destruct;
|
|
761
|
+
function is(node) {
|
|
622
762
|
return node?.type === 'mcdoc:type_alias';
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
763
|
+
}
|
|
764
|
+
TypeAliasNode.is = is;
|
|
765
|
+
})(TypeAliasNode || (TypeAliasNode = {}));
|
|
766
|
+
export var UseStatementNode;
|
|
767
|
+
(function (UseStatementNode) {
|
|
768
|
+
function destruct(node) {
|
|
627
769
|
return {
|
|
628
770
|
binding: node.children.find(IdentifierNode.is),
|
|
629
771
|
path: node.children.find(PathNode.is),
|
|
630
772
|
};
|
|
631
|
-
}
|
|
632
|
-
|
|
773
|
+
}
|
|
774
|
+
UseStatementNode.destruct = destruct;
|
|
775
|
+
function is(node) {
|
|
633
776
|
return (node?.type === 'mcdoc:use_statement');
|
|
634
|
-
}
|
|
635
|
-
|
|
777
|
+
}
|
|
778
|
+
UseStatementNode.is = is;
|
|
779
|
+
})(UseStatementNode || (UseStatementNode = {}));
|
|
636
780
|
//# sourceMappingURL=index.js.map
|