@spyglassmc/mcdoc 0.3.2 → 0.3.4
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 +19 -10
- package/lib/common.d.ts +1 -1
- package/lib/node/index.d.ts +218 -220
- package/lib/node/index.js +465 -311
- package/lib/parser/index.d.ts +1 -1
- package/lib/parser/index.js +19 -14
- package/lib/type/index.d.ts +22 -22
- 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,56 +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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
161
|
+
}
|
|
162
|
+
AttributeTreeNode.destruct = destruct;
|
|
163
|
+
function is(node) {
|
|
164
|
+
return (node?.type ===
|
|
165
|
+
'mcdoc:attribute/tree');
|
|
166
|
+
}
|
|
167
|
+
AttributeTreeNode.is = is;
|
|
168
|
+
})(AttributeTreeNode || (AttributeTreeNode = {}));
|
|
169
|
+
export var AttributeTreePosValuesNode;
|
|
170
|
+
(function (AttributeTreePosValuesNode) {
|
|
171
|
+
function destruct(node) {
|
|
135
172
|
return {
|
|
136
173
|
values: node.children.filter(AttributeValueNode.is),
|
|
137
174
|
};
|
|
138
|
-
}
|
|
139
|
-
|
|
175
|
+
}
|
|
176
|
+
AttributeTreePosValuesNode.destruct = destruct;
|
|
177
|
+
function is(node) {
|
|
140
178
|
return (node?.type ===
|
|
141
179
|
'mcdoc:attribute/tree/pos');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
180
|
+
}
|
|
181
|
+
AttributeTreePosValuesNode.is = is;
|
|
182
|
+
})(AttributeTreePosValuesNode || (AttributeTreePosValuesNode = {}));
|
|
183
|
+
export var AttributeTreeNamedValuesNode;
|
|
184
|
+
(function (AttributeTreeNamedValuesNode) {
|
|
185
|
+
function destruct(node) {
|
|
146
186
|
const ans = {
|
|
147
187
|
values: [],
|
|
148
188
|
};
|
|
@@ -160,78 +200,105 @@ export const AttributeTreeNamedValuesNode = Object.freeze({
|
|
|
160
200
|
}
|
|
161
201
|
}
|
|
162
202
|
return ans;
|
|
163
|
-
}
|
|
164
|
-
|
|
203
|
+
}
|
|
204
|
+
AttributeTreeNamedValuesNode.destruct = destruct;
|
|
205
|
+
function is(node) {
|
|
165
206
|
return (node?.type ===
|
|
166
207
|
'mcdoc:attribute/tree/named');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
208
|
+
}
|
|
209
|
+
AttributeTreeNamedValuesNode.is = is;
|
|
210
|
+
})(AttributeTreeNamedValuesNode || (AttributeTreeNamedValuesNode = {}));
|
|
211
|
+
export var TypeArgBlockNode;
|
|
212
|
+
(function (TypeArgBlockNode) {
|
|
213
|
+
function destruct(node) {
|
|
171
214
|
return {
|
|
172
215
|
args: node.children.filter(TypeNode.is),
|
|
173
216
|
};
|
|
174
|
-
}
|
|
175
|
-
|
|
217
|
+
}
|
|
218
|
+
TypeArgBlockNode.destruct = destruct;
|
|
219
|
+
function is(node) {
|
|
176
220
|
return (node?.type === 'mcdoc:type_arg_block');
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
221
|
+
}
|
|
222
|
+
TypeArgBlockNode.is = is;
|
|
223
|
+
})(TypeArgBlockNode || (TypeArgBlockNode = {}));
|
|
224
|
+
export var AnyTypeNode;
|
|
225
|
+
(function (AnyTypeNode) {
|
|
226
|
+
function is(node) {
|
|
181
227
|
return node?.type === 'mcdoc:type/any';
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
228
|
+
}
|
|
229
|
+
AnyTypeNode.is = is;
|
|
230
|
+
})(AnyTypeNode || (AnyTypeNode = {}));
|
|
231
|
+
export var BooleanTypeNode;
|
|
232
|
+
(function (BooleanTypeNode) {
|
|
233
|
+
function is(node) {
|
|
234
|
+
return node?.type ===
|
|
235
|
+
'mcdoc:type/boolean';
|
|
236
|
+
}
|
|
237
|
+
BooleanTypeNode.is = is;
|
|
238
|
+
})(BooleanTypeNode || (BooleanTypeNode = {}));
|
|
239
|
+
export var IntRangeNode;
|
|
240
|
+
(function (IntRangeNode) {
|
|
241
|
+
function destruct(node) {
|
|
191
242
|
return destructRangeNode(node);
|
|
192
|
-
}
|
|
193
|
-
|
|
243
|
+
}
|
|
244
|
+
IntRangeNode.destruct = destruct;
|
|
245
|
+
function is(node) {
|
|
194
246
|
return node?.type === 'mcdoc:int_range';
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
247
|
+
}
|
|
248
|
+
IntRangeNode.is = is;
|
|
249
|
+
})(IntRangeNode || (IntRangeNode = {}));
|
|
250
|
+
export var LiteralTypeNode;
|
|
251
|
+
(function (LiteralTypeNode) {
|
|
252
|
+
function destruct(node) {
|
|
199
253
|
return {
|
|
200
254
|
value: node.children.find(LiteralTypeValueNode.is),
|
|
201
255
|
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
is
|
|
256
|
+
}
|
|
257
|
+
LiteralTypeNode.destruct = destruct;
|
|
258
|
+
function is(node) {
|
|
259
|
+
return node?.type ===
|
|
260
|
+
'mcdoc:type/literal';
|
|
261
|
+
}
|
|
262
|
+
LiteralTypeNode.is = is;
|
|
263
|
+
})(LiteralTypeNode || (LiteralTypeNode = {}));
|
|
264
|
+
export var LiteralTypeValueNode;
|
|
265
|
+
(function (LiteralTypeValueNode) {
|
|
266
|
+
function is(node) {
|
|
209
267
|
return (LiteralNode.is(node) || TypedNumberNode.is(node) || StringNode.is(node));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
268
|
+
}
|
|
269
|
+
LiteralTypeValueNode.is = is;
|
|
270
|
+
})(LiteralTypeValueNode || (LiteralTypeValueNode = {}));
|
|
271
|
+
export var TypedNumberNode;
|
|
272
|
+
(function (TypedNumberNode) {
|
|
273
|
+
function destruct(node) {
|
|
214
274
|
return {
|
|
215
275
|
value: node.children.find(FloatNode.is),
|
|
216
276
|
suffix: node.children.find(LiteralNode.is),
|
|
217
277
|
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
278
|
+
}
|
|
279
|
+
TypedNumberNode.destruct = destruct;
|
|
280
|
+
function is(node) {
|
|
281
|
+
return node?.type ===
|
|
282
|
+
'mcdoc:typed_number';
|
|
283
|
+
}
|
|
284
|
+
TypedNumberNode.is = is;
|
|
285
|
+
})(TypedNumberNode || (TypedNumberNode = {}));
|
|
286
|
+
export var NumericTypeNode;
|
|
287
|
+
(function (NumericTypeNode) {
|
|
288
|
+
function destruct(node) {
|
|
225
289
|
return {
|
|
226
290
|
numericKind: node.children.find(LiteralNode.is),
|
|
227
291
|
valueRange: node.children.find(FloatRangeNode.is) ||
|
|
228
292
|
node.children.find(IntRangeNode.is),
|
|
229
293
|
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
294
|
+
}
|
|
295
|
+
NumericTypeNode.destruct = destruct;
|
|
296
|
+
function is(node) {
|
|
297
|
+
return (node?.type ===
|
|
298
|
+
'mcdoc:type/numeric_type');
|
|
299
|
+
}
|
|
300
|
+
NumericTypeNode.is = is;
|
|
301
|
+
})(NumericTypeNode || (NumericTypeNode = {}));
|
|
235
302
|
export const RangeExclusiveChar = '<';
|
|
236
303
|
export function getRangeDelimiter(kind) {
|
|
237
304
|
const prefix = kind & 0b10 ? RangeExclusiveChar : '';
|
|
@@ -279,16 +346,20 @@ function destructRangeNode(node) {
|
|
|
279
346
|
return ans;
|
|
280
347
|
}
|
|
281
348
|
}
|
|
282
|
-
export
|
|
283
|
-
|
|
349
|
+
export var FloatRangeNode;
|
|
350
|
+
(function (FloatRangeNode) {
|
|
351
|
+
function destruct(node) {
|
|
284
352
|
return destructRangeNode(node);
|
|
285
|
-
}
|
|
286
|
-
|
|
353
|
+
}
|
|
354
|
+
FloatRangeNode.destruct = destruct;
|
|
355
|
+
function is(node) {
|
|
287
356
|
return node?.type === 'mcdoc:float_range';
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
357
|
+
}
|
|
358
|
+
FloatRangeNode.is = is;
|
|
359
|
+
})(FloatRangeNode || (FloatRangeNode = {}));
|
|
360
|
+
export var PrimitiveArrayTypeNode;
|
|
361
|
+
(function (PrimitiveArrayTypeNode) {
|
|
362
|
+
function destruct(node) {
|
|
292
363
|
let lengthRange;
|
|
293
364
|
let valueRange;
|
|
294
365
|
let afterBrackets = false;
|
|
@@ -310,55 +381,66 @@ export const PrimitiveArrayTypeNode = Object.freeze({
|
|
|
310
381
|
lengthRange,
|
|
311
382
|
valueRange,
|
|
312
383
|
};
|
|
313
|
-
}
|
|
314
|
-
|
|
384
|
+
}
|
|
385
|
+
PrimitiveArrayTypeNode.destruct = destruct;
|
|
386
|
+
function is(node) {
|
|
315
387
|
return (node?.type ===
|
|
316
388
|
'mcdoc:type/primitive_array');
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
389
|
+
}
|
|
390
|
+
PrimitiveArrayTypeNode.is = is;
|
|
391
|
+
})(PrimitiveArrayTypeNode || (PrimitiveArrayTypeNode = {}));
|
|
392
|
+
export var ListTypeNode;
|
|
393
|
+
(function (ListTypeNode) {
|
|
394
|
+
function destruct(node) {
|
|
321
395
|
return {
|
|
322
396
|
item: node.children.find(TypeNode.is),
|
|
323
397
|
lengthRange: node.children.find(IntRangeNode.is),
|
|
324
398
|
};
|
|
325
|
-
}
|
|
326
|
-
|
|
399
|
+
}
|
|
400
|
+
ListTypeNode.destruct = destruct;
|
|
401
|
+
function is(node) {
|
|
327
402
|
return node?.type === 'mcdoc:type/list';
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
403
|
+
}
|
|
404
|
+
ListTypeNode.is = is;
|
|
405
|
+
})(ListTypeNode || (ListTypeNode = {}));
|
|
406
|
+
export var StringTypeNode;
|
|
407
|
+
(function (StringTypeNode) {
|
|
408
|
+
function destruct(node) {
|
|
332
409
|
return {
|
|
333
410
|
lengthRange: node.children.find(IntRangeNode.is),
|
|
334
411
|
};
|
|
335
|
-
}
|
|
336
|
-
|
|
412
|
+
}
|
|
413
|
+
StringTypeNode.destruct = destruct;
|
|
414
|
+
function is(node) {
|
|
337
415
|
return node?.type === 'mcdoc:type/string';
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
416
|
+
}
|
|
417
|
+
StringTypeNode.is = is;
|
|
418
|
+
})(StringTypeNode || (StringTypeNode = {}));
|
|
419
|
+
export var TupleTypeNode;
|
|
420
|
+
(function (TupleTypeNode) {
|
|
421
|
+
function destruct(node) {
|
|
342
422
|
return {
|
|
343
423
|
items: node.children.filter(TypeNode.is),
|
|
344
424
|
};
|
|
345
|
-
}
|
|
346
|
-
|
|
425
|
+
}
|
|
426
|
+
TupleTypeNode.destruct = destruct;
|
|
427
|
+
function is(node) {
|
|
347
428
|
return node?.type === 'mcdoc:type/tuple';
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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) {
|
|
362
444
|
return {
|
|
363
445
|
block: node.children.find(EnumBlockNode.is),
|
|
364
446
|
docComments: node.children.find(DocCommentsNode.is),
|
|
@@ -368,22 +450,25 @@ export const EnumNode = Object.freeze({
|
|
|
368
450
|
};
|
|
369
451
|
function getEnumKind(node) {
|
|
370
452
|
for (const literal of node.children.filter(LiteralNode.is)) {
|
|
371
|
-
if (
|
|
453
|
+
if (EnumNode.Kinds.has(literal.value)) {
|
|
372
454
|
return literal.value;
|
|
373
455
|
}
|
|
374
456
|
}
|
|
375
457
|
return undefined;
|
|
376
458
|
}
|
|
377
|
-
}
|
|
378
|
-
|
|
459
|
+
}
|
|
460
|
+
EnumNode.destruct = destruct;
|
|
461
|
+
function is(node) {
|
|
379
462
|
return node?.type === 'mcdoc:enum';
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
463
|
+
}
|
|
464
|
+
EnumNode.is = is;
|
|
465
|
+
})(EnumNode || (EnumNode = {}));
|
|
466
|
+
export var DocCommentsNode;
|
|
467
|
+
(function (DocCommentsNode) {
|
|
383
468
|
/**
|
|
384
469
|
* @returns The text content of this doc comment block.
|
|
385
470
|
*/
|
|
386
|
-
asText(node) {
|
|
471
|
+
function asText(node) {
|
|
387
472
|
if (!node) {
|
|
388
473
|
return undefined;
|
|
389
474
|
}
|
|
@@ -397,208 +482,272 @@ export const DocCommentsNode = Object.freeze({
|
|
|
397
482
|
comments = comments.map((s) => s.slice(1));
|
|
398
483
|
}
|
|
399
484
|
return comments.join('\n');
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
485
|
+
}
|
|
486
|
+
DocCommentsNode.asText = asText;
|
|
487
|
+
function is(node) {
|
|
488
|
+
return node?.type ===
|
|
489
|
+
'mcdoc:doc_comments';
|
|
490
|
+
}
|
|
491
|
+
DocCommentsNode.is = is;
|
|
492
|
+
})(DocCommentsNode || (DocCommentsNode = {}));
|
|
493
|
+
export var EnumBlockNode;
|
|
494
|
+
(function (EnumBlockNode) {
|
|
495
|
+
function destruct(node) {
|
|
407
496
|
return {
|
|
408
497
|
fields: node.children.filter(EnumFieldNode.is),
|
|
409
498
|
};
|
|
410
|
-
}
|
|
411
|
-
|
|
499
|
+
}
|
|
500
|
+
EnumBlockNode.destruct = destruct;
|
|
501
|
+
function is(node) {
|
|
412
502
|
return node?.type === 'mcdoc:enum/block';
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
503
|
+
}
|
|
504
|
+
EnumBlockNode.is = is;
|
|
505
|
+
})(EnumBlockNode || (EnumBlockNode = {}));
|
|
506
|
+
export var EnumFieldNode;
|
|
507
|
+
(function (EnumFieldNode) {
|
|
508
|
+
function destruct(node) {
|
|
417
509
|
return {
|
|
418
510
|
attributes: node.children.filter(AttributeNode.is),
|
|
419
511
|
identifier: node.children.find(IdentifierNode.is),
|
|
420
512
|
value: node.children.find(EnumValueNode.is),
|
|
421
513
|
};
|
|
422
|
-
}
|
|
423
|
-
|
|
514
|
+
}
|
|
515
|
+
EnumFieldNode.destruct = destruct;
|
|
516
|
+
function is(node) {
|
|
424
517
|
return node?.type === 'mcdoc:enum/field';
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
518
|
+
}
|
|
519
|
+
EnumFieldNode.is = is;
|
|
520
|
+
})(EnumFieldNode || (EnumFieldNode = {}));
|
|
521
|
+
export var EnumValueNode;
|
|
522
|
+
(function (EnumValueNode) {
|
|
523
|
+
function is(node) {
|
|
429
524
|
return TypedNumberNode.is(node) || StringNode.is(node);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
525
|
+
}
|
|
526
|
+
EnumValueNode.is = is;
|
|
527
|
+
})(EnumValueNode || (EnumValueNode = {}));
|
|
528
|
+
export var PrelimNode;
|
|
529
|
+
(function (PrelimNode) {
|
|
530
|
+
function is(node) {
|
|
434
531
|
return AttributeNode.is(node) || DocCommentsNode.is(node);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
532
|
+
}
|
|
533
|
+
PrelimNode.is = is;
|
|
534
|
+
})(PrelimNode || (PrelimNode = {}));
|
|
535
|
+
export var StructNode;
|
|
536
|
+
(function (StructNode) {
|
|
537
|
+
function destruct(node) {
|
|
439
538
|
return {
|
|
440
539
|
block: node.children.find(StructBlockNode.is),
|
|
441
540
|
docComments: node.children.find(DocCommentsNode.is),
|
|
442
541
|
identifier: node.children.find(IdentifierNode.is),
|
|
443
542
|
keyword: node.children.find(LiteralNode.is),
|
|
444
543
|
};
|
|
445
|
-
}
|
|
446
|
-
|
|
544
|
+
}
|
|
545
|
+
StructNode.destruct = destruct;
|
|
546
|
+
function is(node) {
|
|
447
547
|
return node?.type === 'mcdoc:struct';
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
548
|
+
}
|
|
549
|
+
StructNode.is = is;
|
|
550
|
+
})(StructNode || (StructNode = {}));
|
|
551
|
+
export var ReferenceTypeNode;
|
|
552
|
+
(function (ReferenceTypeNode) {
|
|
553
|
+
function destruct(node) {
|
|
452
554
|
return {
|
|
453
555
|
path: node.children.find(PathNode.is),
|
|
454
556
|
};
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
557
|
+
}
|
|
558
|
+
ReferenceTypeNode.destruct = destruct;
|
|
559
|
+
function is(node) {
|
|
560
|
+
return (node?.type ===
|
|
561
|
+
'mcdoc:type/reference');
|
|
562
|
+
}
|
|
563
|
+
ReferenceTypeNode.is = is;
|
|
564
|
+
})(ReferenceTypeNode || (ReferenceTypeNode = {}));
|
|
565
|
+
export var TypeParamBlockNode;
|
|
566
|
+
(function (TypeParamBlockNode) {
|
|
567
|
+
function destruct(node) {
|
|
462
568
|
return {
|
|
463
569
|
params: node.children.filter(TypeParamNode.is),
|
|
464
570
|
};
|
|
465
|
-
}
|
|
466
|
-
|
|
571
|
+
}
|
|
572
|
+
TypeParamBlockNode.destruct = destruct;
|
|
573
|
+
function is(node) {
|
|
467
574
|
return (node?.type ===
|
|
468
575
|
'mcdoc:type_param_block');
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
576
|
+
}
|
|
577
|
+
TypeParamBlockNode.is = is;
|
|
578
|
+
})(TypeParamBlockNode || (TypeParamBlockNode = {}));
|
|
579
|
+
export var TypeParamNode;
|
|
580
|
+
(function (TypeParamNode) {
|
|
581
|
+
function destruct(node) {
|
|
473
582
|
return {
|
|
474
583
|
// constraint: node.children.find(TypeNode.is),
|
|
475
584
|
identifier: node.children.find(IdentifierNode.is),
|
|
476
585
|
};
|
|
477
|
-
}
|
|
478
|
-
|
|
586
|
+
}
|
|
587
|
+
TypeParamNode.destruct = destruct;
|
|
588
|
+
function is(node) {
|
|
479
589
|
return node?.type === 'mcdoc:type_param';
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
590
|
+
}
|
|
591
|
+
TypeParamNode.is = is;
|
|
592
|
+
})(TypeParamNode || (TypeParamNode = {}));
|
|
593
|
+
export var PathNode;
|
|
594
|
+
(function (PathNode) {
|
|
595
|
+
function destruct(node) {
|
|
484
596
|
const lastChild = atArray(node?.children, -1);
|
|
485
597
|
return {
|
|
486
598
|
children: node?.children ?? [],
|
|
487
599
|
isAbsolute: node?.isAbsolute,
|
|
488
600
|
lastIdentifier: IdentifierNode.is(lastChild) ? lastChild : undefined,
|
|
489
601
|
};
|
|
490
|
-
}
|
|
491
|
-
|
|
602
|
+
}
|
|
603
|
+
PathNode.destruct = destruct;
|
|
604
|
+
function is(node) {
|
|
492
605
|
return node?.type === 'mcdoc:path';
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
606
|
+
}
|
|
607
|
+
PathNode.is = is;
|
|
608
|
+
})(PathNode || (PathNode = {}));
|
|
609
|
+
export var StructBlockNode;
|
|
610
|
+
(function (StructBlockNode) {
|
|
611
|
+
function destruct(node) {
|
|
497
612
|
return {
|
|
498
613
|
fields: node.children.filter(StructFieldNode.is),
|
|
499
614
|
};
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
is
|
|
615
|
+
}
|
|
616
|
+
StructBlockNode.destruct = destruct;
|
|
617
|
+
function is(node) {
|
|
618
|
+
return node?.type ===
|
|
619
|
+
'mcdoc:struct/block';
|
|
620
|
+
}
|
|
621
|
+
StructBlockNode.is = is;
|
|
622
|
+
})(StructBlockNode || (StructBlockNode = {}));
|
|
623
|
+
export var StructFieldNode;
|
|
624
|
+
(function (StructFieldNode) {
|
|
625
|
+
function is(node) {
|
|
507
626
|
return StructPairFieldNode.is(node) || StructSpreadFieldNode.is(node);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
627
|
+
}
|
|
628
|
+
StructFieldNode.is = is;
|
|
629
|
+
})(StructFieldNode || (StructFieldNode = {}));
|
|
630
|
+
export var StructPairFieldNode;
|
|
631
|
+
(function (StructPairFieldNode) {
|
|
632
|
+
function destruct(node) {
|
|
512
633
|
return {
|
|
513
634
|
attributes: node.children.filter(AttributeNode.is),
|
|
514
635
|
key: node.children.find(StructKeyNode.is),
|
|
515
636
|
type: node.children.find(TypeNode.is),
|
|
516
637
|
isOptional: node.isOptional,
|
|
517
638
|
};
|
|
518
|
-
}
|
|
519
|
-
|
|
639
|
+
}
|
|
640
|
+
StructPairFieldNode.destruct = destruct;
|
|
641
|
+
function is(node) {
|
|
520
642
|
return (node?.type ===
|
|
521
643
|
'mcdoc:struct/field/pair');
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
644
|
+
}
|
|
645
|
+
StructPairFieldNode.is = is;
|
|
646
|
+
})(StructPairFieldNode || (StructPairFieldNode = {}));
|
|
647
|
+
export var StructKeyNode;
|
|
648
|
+
(function (StructKeyNode) {
|
|
649
|
+
function is(node) {
|
|
526
650
|
return (StringNode.is(node) ||
|
|
527
651
|
IdentifierNode.is(node) ||
|
|
528
652
|
StructMapKeyNode.is(node));
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
653
|
+
}
|
|
654
|
+
StructKeyNode.is = is;
|
|
655
|
+
})(StructKeyNode || (StructKeyNode = {}));
|
|
656
|
+
export var StructMapKeyNode;
|
|
657
|
+
(function (StructMapKeyNode) {
|
|
658
|
+
function destruct(node) {
|
|
533
659
|
return {
|
|
534
660
|
type: node.children.find(TypeNode.is),
|
|
535
661
|
};
|
|
536
|
-
}
|
|
537
|
-
|
|
662
|
+
}
|
|
663
|
+
StructMapKeyNode.destruct = destruct;
|
|
664
|
+
function is(node) {
|
|
538
665
|
return (node?.type === 'mcdoc:struct/map_key');
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
666
|
+
}
|
|
667
|
+
StructMapKeyNode.is = is;
|
|
668
|
+
})(StructMapKeyNode || (StructMapKeyNode = {}));
|
|
669
|
+
export var StructSpreadFieldNode;
|
|
670
|
+
(function (StructSpreadFieldNode) {
|
|
671
|
+
function destruct(node) {
|
|
543
672
|
return {
|
|
544
673
|
attributes: node.children.filter(AttributeNode.is),
|
|
545
674
|
type: node.children.find(TypeNode.is),
|
|
546
675
|
};
|
|
547
|
-
}
|
|
548
|
-
|
|
676
|
+
}
|
|
677
|
+
StructSpreadFieldNode.destruct = destruct;
|
|
678
|
+
function is(node) {
|
|
549
679
|
return (node?.type ===
|
|
550
680
|
'mcdoc:struct/field/spread');
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
681
|
+
}
|
|
682
|
+
StructSpreadFieldNode.is = is;
|
|
683
|
+
})(StructSpreadFieldNode || (StructSpreadFieldNode = {}));
|
|
684
|
+
export var DispatcherTypeNode;
|
|
685
|
+
(function (DispatcherTypeNode) {
|
|
686
|
+
function destruct(node) {
|
|
555
687
|
return {
|
|
556
688
|
location: node.children.find(ResourceLocationNode.is),
|
|
557
689
|
index: node.children.find(IndexBodyNode.is),
|
|
558
690
|
};
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
691
|
+
}
|
|
692
|
+
DispatcherTypeNode.destruct = destruct;
|
|
693
|
+
function is(node) {
|
|
694
|
+
return (node?.type ===
|
|
695
|
+
'mcdoc:type/dispatcher');
|
|
696
|
+
}
|
|
697
|
+
DispatcherTypeNode.is = is;
|
|
698
|
+
})(DispatcherTypeNode || (DispatcherTypeNode = {}));
|
|
699
|
+
export var UnionTypeNode;
|
|
700
|
+
(function (UnionTypeNode) {
|
|
701
|
+
function destruct(node) {
|
|
566
702
|
return {
|
|
567
703
|
members: node.children.filter(TypeNode.is),
|
|
568
704
|
};
|
|
569
|
-
}
|
|
570
|
-
|
|
705
|
+
}
|
|
706
|
+
UnionTypeNode.destruct = destruct;
|
|
707
|
+
function is(node) {
|
|
571
708
|
return node?.type === 'mcdoc:type/union';
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
709
|
+
}
|
|
710
|
+
UnionTypeNode.is = is;
|
|
711
|
+
})(UnionTypeNode || (UnionTypeNode = {}));
|
|
712
|
+
export var InjectionNode;
|
|
713
|
+
(function (InjectionNode) {
|
|
714
|
+
function destruct(node) {
|
|
576
715
|
return {
|
|
577
716
|
injection: node.children.find(InjectionContentNode.is),
|
|
578
717
|
};
|
|
579
|
-
}
|
|
580
|
-
|
|
718
|
+
}
|
|
719
|
+
InjectionNode.destruct = destruct;
|
|
720
|
+
function is(node) {
|
|
581
721
|
return node?.type === 'mcdoc:injection';
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
722
|
+
}
|
|
723
|
+
InjectionNode.is = is;
|
|
724
|
+
})(InjectionNode || (InjectionNode = {}));
|
|
725
|
+
export var InjectionContentNode;
|
|
726
|
+
(function (InjectionContentNode) {
|
|
727
|
+
function is(node) {
|
|
586
728
|
return EnumInjectionNode.is(node) || StructInjectionNode.is(node);
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
729
|
+
}
|
|
730
|
+
InjectionContentNode.is = is;
|
|
731
|
+
})(InjectionContentNode || (InjectionContentNode = {}));
|
|
732
|
+
export var EnumInjectionNode;
|
|
733
|
+
(function (EnumInjectionNode) {
|
|
734
|
+
function is(node) {
|
|
735
|
+
return (node?.type ===
|
|
736
|
+
'mcdoc:injection/enum');
|
|
737
|
+
}
|
|
738
|
+
EnumInjectionNode.is = is;
|
|
739
|
+
})(EnumInjectionNode || (EnumInjectionNode = {}));
|
|
740
|
+
export var StructInjectionNode;
|
|
741
|
+
(function (StructInjectionNode) {
|
|
742
|
+
function is(node) {
|
|
596
743
|
return (node?.type ===
|
|
597
744
|
'mcdoc:injection/struct');
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
745
|
+
}
|
|
746
|
+
StructInjectionNode.is = is;
|
|
747
|
+
})(StructInjectionNode || (StructInjectionNode = {}));
|
|
748
|
+
export var TypeAliasNode;
|
|
749
|
+
(function (TypeAliasNode) {
|
|
750
|
+
function destruct(node) {
|
|
602
751
|
return {
|
|
603
752
|
attributes: node.children.filter(AttributeNode.is),
|
|
604
753
|
docComments: node.children.find(DocCommentsNode.is),
|
|
@@ -607,20 +756,25 @@ export const TypeAliasNode = Object.freeze({
|
|
|
607
756
|
typeParams: node.children.find(TypeParamBlockNode.is),
|
|
608
757
|
rhs: node.children.find(TypeNode.is),
|
|
609
758
|
};
|
|
610
|
-
}
|
|
611
|
-
|
|
759
|
+
}
|
|
760
|
+
TypeAliasNode.destruct = destruct;
|
|
761
|
+
function is(node) {
|
|
612
762
|
return node?.type === 'mcdoc:type_alias';
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
763
|
+
}
|
|
764
|
+
TypeAliasNode.is = is;
|
|
765
|
+
})(TypeAliasNode || (TypeAliasNode = {}));
|
|
766
|
+
export var UseStatementNode;
|
|
767
|
+
(function (UseStatementNode) {
|
|
768
|
+
function destruct(node) {
|
|
617
769
|
return {
|
|
618
770
|
binding: node.children.find(IdentifierNode.is),
|
|
619
771
|
path: node.children.find(PathNode.is),
|
|
620
772
|
};
|
|
621
|
-
}
|
|
622
|
-
|
|
773
|
+
}
|
|
774
|
+
UseStatementNode.destruct = destruct;
|
|
775
|
+
function is(node) {
|
|
623
776
|
return (node?.type === 'mcdoc:use_statement');
|
|
624
|
-
}
|
|
625
|
-
|
|
777
|
+
}
|
|
778
|
+
UseStatementNode.is = is;
|
|
779
|
+
})(UseStatementNode || (UseStatementNode = {}));
|
|
626
780
|
//# sourceMappingURL=index.js.map
|