@spyglassmc/mcdoc 0.3.7 → 0.3.9
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.js +122 -191
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -4
- package/lib/node/index.d.ts +9 -4
- package/lib/node/index.js +77 -131
- package/lib/parser/index.d.ts +13 -1
- package/lib/parser/index.js +112 -190
- package/lib/runtime/attribute/builtin.d.ts +3 -0
- package/lib/runtime/attribute/builtin.js +130 -0
- package/lib/runtime/attribute/index.d.ts +22 -0
- package/lib/runtime/attribute/index.js +22 -0
- package/lib/runtime/attribute/validator.d.ts +16 -0
- package/lib/runtime/attribute/validator.js +85 -0
- package/lib/runtime/checker/context.d.ts +34 -0
- package/lib/runtime/checker/context.js +17 -0
- package/lib/runtime/checker/error.d.ts +70 -0
- package/lib/runtime/checker/error.js +352 -0
- package/lib/runtime/checker/index.d.ts +80 -0
- package/lib/runtime/checker/index.js +914 -0
- package/lib/runtime/completer/index.d.ts +20 -0
- package/lib/runtime/completer/index.js +123 -0
- package/lib/runtime/index.d.ts +5 -0
- package/lib/runtime/index.js +5 -0
- package/lib/type/index.d.ts +73 -92
- package/lib/type/index.js +341 -422
- package/lib/uri_processors.js +2 -8
- package/package.json +3 -3
package/lib/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { atArray, CommentNode, FloatNode, ResourceLocationNode, StringNode, } from '@spyglassmc/core';
|
|
1
|
+
import { atArray, CommentNode, FloatNode, IntegerNode, ResourceLocationNode, StringNode, } from '@spyglassmc/core';
|
|
2
2
|
export var ModuleNode;
|
|
3
3
|
(function (ModuleNode) {
|
|
4
4
|
function is(node) {
|
|
@@ -9,13 +9,13 @@ export var ModuleNode;
|
|
|
9
9
|
export var TopLevelNode;
|
|
10
10
|
(function (TopLevelNode) {
|
|
11
11
|
function is(node) {
|
|
12
|
-
return (CommentNode.is(node)
|
|
13
|
-
DispatchStatementNode.is(node)
|
|
14
|
-
EnumNode.is(node)
|
|
15
|
-
InjectionNode.is(node)
|
|
16
|
-
StructNode.is(node)
|
|
17
|
-
TypeAliasNode.is(node)
|
|
18
|
-
UseStatementNode.is(node));
|
|
12
|
+
return (CommentNode.is(node)
|
|
13
|
+
|| DispatchStatementNode.is(node)
|
|
14
|
+
|| EnumNode.is(node)
|
|
15
|
+
|| InjectionNode.is(node)
|
|
16
|
+
|| StructNode.is(node)
|
|
17
|
+
|| TypeAliasNode.is(node)
|
|
18
|
+
|| UseStatementNode.is(node));
|
|
19
19
|
}
|
|
20
20
|
TopLevelNode.is = is;
|
|
21
21
|
})(TopLevelNode || (TopLevelNode = {}));
|
|
@@ -32,8 +32,7 @@ export var DispatchStatementNode;
|
|
|
32
32
|
}
|
|
33
33
|
DispatchStatementNode.destruct = destruct;
|
|
34
34
|
function is(node) {
|
|
35
|
-
return (node?.type ===
|
|
36
|
-
'mcdoc:dispatch_statement');
|
|
35
|
+
return (node?.type === 'mcdoc:dispatch_statement');
|
|
37
36
|
}
|
|
38
37
|
DispatchStatementNode.is = is;
|
|
39
38
|
})(DispatchStatementNode || (DispatchStatementNode = {}));
|
|
@@ -47,9 +46,7 @@ export var LiteralNode;
|
|
|
47
46
|
export var IndexBodyNode;
|
|
48
47
|
(function (IndexBodyNode) {
|
|
49
48
|
function destruct(node) {
|
|
50
|
-
return {
|
|
51
|
-
parallelIndices: node.children.filter(IndexNode.is),
|
|
52
|
-
};
|
|
49
|
+
return { parallelIndices: node.children.filter(IndexNode.is) };
|
|
53
50
|
}
|
|
54
51
|
IndexBodyNode.destruct = destruct;
|
|
55
52
|
function is(node) {
|
|
@@ -67,10 +64,10 @@ export var IndexNode;
|
|
|
67
64
|
export var StaticIndexNode;
|
|
68
65
|
(function (StaticIndexNode) {
|
|
69
66
|
function is(node) {
|
|
70
|
-
return (LiteralNode.is(node)
|
|
71
|
-
IdentifierNode.is(node)
|
|
72
|
-
StringNode.is(node)
|
|
73
|
-
ResourceLocationNode.is(node));
|
|
67
|
+
return (LiteralNode.is(node)
|
|
68
|
+
|| IdentifierNode.is(node)
|
|
69
|
+
|| StringNode.is(node)
|
|
70
|
+
|| ResourceLocationNode.is(node));
|
|
74
71
|
}
|
|
75
72
|
StaticIndexNode.is = is;
|
|
76
73
|
})(StaticIndexNode || (StaticIndexNode = {}));
|
|
@@ -84,9 +81,7 @@ export var IdentifierNode;
|
|
|
84
81
|
export var DynamicIndexNode;
|
|
85
82
|
(function (DynamicIndexNode) {
|
|
86
83
|
function destruct(node) {
|
|
87
|
-
return {
|
|
88
|
-
keys: node.children.filter(AccessorKeyNode.is),
|
|
89
|
-
};
|
|
84
|
+
return { keys: node.children.filter(AccessorKeyNode.is) };
|
|
90
85
|
}
|
|
91
86
|
DynamicIndexNode.destruct = destruct;
|
|
92
87
|
function is(node) {
|
|
@@ -104,19 +99,19 @@ export var AccessorKeyNode;
|
|
|
104
99
|
export var TypeNode;
|
|
105
100
|
(function (TypeNode) {
|
|
106
101
|
function is(node) {
|
|
107
|
-
return (AnyTypeNode.is(node)
|
|
108
|
-
BooleanTypeNode.is(node)
|
|
109
|
-
StringTypeNode.is(node)
|
|
110
|
-
LiteralTypeNode.is(node)
|
|
111
|
-
NumericTypeNode.is(node)
|
|
112
|
-
PrimitiveArrayTypeNode.is(node)
|
|
113
|
-
ListTypeNode.is(node)
|
|
114
|
-
TupleTypeNode.is(node)
|
|
115
|
-
EnumNode.is(node)
|
|
116
|
-
StructNode.is(node)
|
|
117
|
-
ReferenceTypeNode.is(node)
|
|
118
|
-
DispatcherTypeNode.is(node)
|
|
119
|
-
UnionTypeNode.is(node));
|
|
102
|
+
return (AnyTypeNode.is(node)
|
|
103
|
+
|| BooleanTypeNode.is(node)
|
|
104
|
+
|| StringTypeNode.is(node)
|
|
105
|
+
|| LiteralTypeNode.is(node)
|
|
106
|
+
|| NumericTypeNode.is(node)
|
|
107
|
+
|| PrimitiveArrayTypeNode.is(node)
|
|
108
|
+
|| ListTypeNode.is(node)
|
|
109
|
+
|| TupleTypeNode.is(node)
|
|
110
|
+
|| EnumNode.is(node)
|
|
111
|
+
|| StructNode.is(node)
|
|
112
|
+
|| ReferenceTypeNode.is(node)
|
|
113
|
+
|| DispatcherTypeNode.is(node)
|
|
114
|
+
|| UnionTypeNode.is(node));
|
|
120
115
|
}
|
|
121
116
|
TypeNode.is = is;
|
|
122
117
|
})(TypeNode || (TypeNode = {}));
|
|
@@ -161,31 +156,25 @@ export var AttributeTreeNode;
|
|
|
161
156
|
}
|
|
162
157
|
AttributeTreeNode.destruct = destruct;
|
|
163
158
|
function is(node) {
|
|
164
|
-
return (node?.type ===
|
|
165
|
-
'mcdoc:attribute/tree');
|
|
159
|
+
return (node?.type === 'mcdoc:attribute/tree');
|
|
166
160
|
}
|
|
167
161
|
AttributeTreeNode.is = is;
|
|
168
162
|
})(AttributeTreeNode || (AttributeTreeNode = {}));
|
|
169
163
|
export var AttributeTreePosValuesNode;
|
|
170
164
|
(function (AttributeTreePosValuesNode) {
|
|
171
165
|
function destruct(node) {
|
|
172
|
-
return {
|
|
173
|
-
values: node.children.filter(AttributeValueNode.is),
|
|
174
|
-
};
|
|
166
|
+
return { values: node.children.filter(AttributeValueNode.is) };
|
|
175
167
|
}
|
|
176
168
|
AttributeTreePosValuesNode.destruct = destruct;
|
|
177
169
|
function is(node) {
|
|
178
|
-
return (node?.type ===
|
|
179
|
-
'mcdoc:attribute/tree/pos');
|
|
170
|
+
return (node?.type === 'mcdoc:attribute/tree/pos');
|
|
180
171
|
}
|
|
181
172
|
AttributeTreePosValuesNode.is = is;
|
|
182
173
|
})(AttributeTreePosValuesNode || (AttributeTreePosValuesNode = {}));
|
|
183
174
|
export var AttributeTreeNamedValuesNode;
|
|
184
175
|
(function (AttributeTreeNamedValuesNode) {
|
|
185
176
|
function destruct(node) {
|
|
186
|
-
const ans = {
|
|
187
|
-
values: [],
|
|
188
|
-
};
|
|
177
|
+
const ans = { values: [] };
|
|
189
178
|
let key;
|
|
190
179
|
for (const child of node.children) {
|
|
191
180
|
if (CommentNode.is(child)) {
|
|
@@ -203,17 +192,15 @@ export var AttributeTreeNamedValuesNode;
|
|
|
203
192
|
}
|
|
204
193
|
AttributeTreeNamedValuesNode.destruct = destruct;
|
|
205
194
|
function is(node) {
|
|
206
|
-
return (node?.type
|
|
207
|
-
'mcdoc:attribute/tree/named');
|
|
195
|
+
return (node?.type
|
|
196
|
+
=== 'mcdoc:attribute/tree/named');
|
|
208
197
|
}
|
|
209
198
|
AttributeTreeNamedValuesNode.is = is;
|
|
210
199
|
})(AttributeTreeNamedValuesNode || (AttributeTreeNamedValuesNode = {}));
|
|
211
200
|
export var TypeArgBlockNode;
|
|
212
201
|
(function (TypeArgBlockNode) {
|
|
213
202
|
function destruct(node) {
|
|
214
|
-
return {
|
|
215
|
-
args: node.children.filter(TypeNode.is),
|
|
216
|
-
};
|
|
203
|
+
return { args: node.children.filter(TypeNode.is) };
|
|
217
204
|
}
|
|
218
205
|
TypeArgBlockNode.destruct = destruct;
|
|
219
206
|
function is(node) {
|
|
@@ -231,8 +218,7 @@ export var AnyTypeNode;
|
|
|
231
218
|
export var BooleanTypeNode;
|
|
232
219
|
(function (BooleanTypeNode) {
|
|
233
220
|
function is(node) {
|
|
234
|
-
return node?.type ===
|
|
235
|
-
'mcdoc:type/boolean';
|
|
221
|
+
return node?.type === 'mcdoc:type/boolean';
|
|
236
222
|
}
|
|
237
223
|
BooleanTypeNode.is = is;
|
|
238
224
|
})(BooleanTypeNode || (BooleanTypeNode = {}));
|
|
@@ -250,14 +236,11 @@ export var IntRangeNode;
|
|
|
250
236
|
export var LiteralTypeNode;
|
|
251
237
|
(function (LiteralTypeNode) {
|
|
252
238
|
function destruct(node) {
|
|
253
|
-
return {
|
|
254
|
-
value: node.children.find(LiteralTypeValueNode.is),
|
|
255
|
-
};
|
|
239
|
+
return { value: node.children.find(LiteralTypeValueNode.is) };
|
|
256
240
|
}
|
|
257
241
|
LiteralTypeNode.destruct = destruct;
|
|
258
242
|
function is(node) {
|
|
259
|
-
return node?.type ===
|
|
260
|
-
'mcdoc:type/literal';
|
|
243
|
+
return node?.type === 'mcdoc:type/literal';
|
|
261
244
|
}
|
|
262
245
|
LiteralTypeNode.is = is;
|
|
263
246
|
})(LiteralTypeNode || (LiteralTypeNode = {}));
|
|
@@ -272,14 +255,13 @@ export var TypedNumberNode;
|
|
|
272
255
|
(function (TypedNumberNode) {
|
|
273
256
|
function destruct(node) {
|
|
274
257
|
return {
|
|
275
|
-
value: node.children.find(FloatNode.is),
|
|
258
|
+
value: node.children.find(FloatNode.is) ?? node.children.find(IntegerNode.is),
|
|
276
259
|
suffix: node.children.find(LiteralNode.is),
|
|
277
260
|
};
|
|
278
261
|
}
|
|
279
262
|
TypedNumberNode.destruct = destruct;
|
|
280
263
|
function is(node) {
|
|
281
|
-
return node?.type ===
|
|
282
|
-
'mcdoc:typed_number';
|
|
264
|
+
return node?.type === 'mcdoc:typed_number';
|
|
283
265
|
}
|
|
284
266
|
TypedNumberNode.is = is;
|
|
285
267
|
})(TypedNumberNode || (TypedNumberNode = {}));
|
|
@@ -288,18 +270,27 @@ export var NumericTypeNode;
|
|
|
288
270
|
function destruct(node) {
|
|
289
271
|
return {
|
|
290
272
|
numericKind: node.children.find(LiteralNode.is),
|
|
291
|
-
valueRange: node.children.find(FloatRangeNode.is) ||
|
|
292
|
-
node.children.find(IntRangeNode.is),
|
|
273
|
+
valueRange: node.children.find(FloatRangeNode.is) || node.children.find(IntRangeNode.is),
|
|
293
274
|
};
|
|
294
275
|
}
|
|
295
276
|
NumericTypeNode.destruct = destruct;
|
|
296
277
|
function is(node) {
|
|
297
|
-
return (node?.type ===
|
|
298
|
-
'mcdoc:type/numeric_type');
|
|
278
|
+
return (node?.type === 'mcdoc:type/numeric_type');
|
|
299
279
|
}
|
|
300
280
|
NumericTypeNode.is = is;
|
|
301
281
|
})(NumericTypeNode || (NumericTypeNode = {}));
|
|
302
282
|
export const RangeExclusiveChar = '<';
|
|
283
|
+
export var RangeKind;
|
|
284
|
+
(function (RangeKind) {
|
|
285
|
+
function isLeftExclusive(rangeKind) {
|
|
286
|
+
return (rangeKind & 0b10) !== 0;
|
|
287
|
+
}
|
|
288
|
+
RangeKind.isLeftExclusive = isLeftExclusive;
|
|
289
|
+
function isRightExclusive(rangeKind) {
|
|
290
|
+
return (rangeKind & 0b01) !== 0;
|
|
291
|
+
}
|
|
292
|
+
RangeKind.isRightExclusive = isRightExclusive;
|
|
293
|
+
})(RangeKind || (RangeKind = {}));
|
|
303
294
|
export function getRangeDelimiter(kind) {
|
|
304
295
|
const prefix = kind & 0b10 ? RangeExclusiveChar : '';
|
|
305
296
|
const suffix = kind & 0b01 ? RangeExclusiveChar : '';
|
|
@@ -330,11 +321,7 @@ function destructRangeNode(node) {
|
|
|
330
321
|
kind = getKind(node.children[1]);
|
|
331
322
|
min = node.children[0];
|
|
332
323
|
}
|
|
333
|
-
return {
|
|
334
|
-
kind,
|
|
335
|
-
min,
|
|
336
|
-
max,
|
|
337
|
-
};
|
|
324
|
+
return { kind, min, max };
|
|
338
325
|
function getKind(delimiter) {
|
|
339
326
|
let ans = 0b00;
|
|
340
327
|
if (delimiter.value.startsWith(RangeExclusiveChar)) {
|
|
@@ -376,16 +363,11 @@ export var PrimitiveArrayTypeNode;
|
|
|
376
363
|
}
|
|
377
364
|
}
|
|
378
365
|
}
|
|
379
|
-
return {
|
|
380
|
-
arrayKind: node.children.find(LiteralNode.is),
|
|
381
|
-
lengthRange,
|
|
382
|
-
valueRange,
|
|
383
|
-
};
|
|
366
|
+
return { arrayKind: node.children.find(LiteralNode.is), lengthRange, valueRange };
|
|
384
367
|
}
|
|
385
368
|
PrimitiveArrayTypeNode.destruct = destruct;
|
|
386
369
|
function is(node) {
|
|
387
|
-
return (node?.type ===
|
|
388
|
-
'mcdoc:type/primitive_array');
|
|
370
|
+
return (node?.type === 'mcdoc:type/primitive_array');
|
|
389
371
|
}
|
|
390
372
|
PrimitiveArrayTypeNode.is = is;
|
|
391
373
|
})(PrimitiveArrayTypeNode || (PrimitiveArrayTypeNode = {}));
|
|
@@ -406,9 +388,7 @@ export var ListTypeNode;
|
|
|
406
388
|
export var StringTypeNode;
|
|
407
389
|
(function (StringTypeNode) {
|
|
408
390
|
function destruct(node) {
|
|
409
|
-
return {
|
|
410
|
-
lengthRange: node.children.find(IntRangeNode.is),
|
|
411
|
-
};
|
|
391
|
+
return { lengthRange: node.children.find(IntRangeNode.is) };
|
|
412
392
|
}
|
|
413
393
|
StringTypeNode.destruct = destruct;
|
|
414
394
|
function is(node) {
|
|
@@ -419,9 +399,7 @@ export var StringTypeNode;
|
|
|
419
399
|
export var TupleTypeNode;
|
|
420
400
|
(function (TupleTypeNode) {
|
|
421
401
|
function destruct(node) {
|
|
422
|
-
return {
|
|
423
|
-
items: node.children.filter(TypeNode.is),
|
|
424
|
-
};
|
|
402
|
+
return { items: node.children.filter(TypeNode.is) };
|
|
425
403
|
}
|
|
426
404
|
TupleTypeNode.destruct = destruct;
|
|
427
405
|
function is(node) {
|
|
@@ -431,15 +409,7 @@ export var TupleTypeNode;
|
|
|
431
409
|
})(TupleTypeNode || (TupleTypeNode = {}));
|
|
432
410
|
export var EnumNode;
|
|
433
411
|
(function (EnumNode) {
|
|
434
|
-
EnumNode.Kinds = new Set([
|
|
435
|
-
'byte',
|
|
436
|
-
'short',
|
|
437
|
-
'int',
|
|
438
|
-
'long',
|
|
439
|
-
'float',
|
|
440
|
-
'double',
|
|
441
|
-
'string',
|
|
442
|
-
]);
|
|
412
|
+
EnumNode.Kinds = new Set(['byte', 'short', 'int', 'long', 'float', 'double', 'string']);
|
|
443
413
|
function destruct(node) {
|
|
444
414
|
return {
|
|
445
415
|
block: node.children.find(EnumBlockNode.is),
|
|
@@ -485,17 +455,14 @@ export var DocCommentsNode;
|
|
|
485
455
|
}
|
|
486
456
|
DocCommentsNode.asText = asText;
|
|
487
457
|
function is(node) {
|
|
488
|
-
return node?.type ===
|
|
489
|
-
'mcdoc:doc_comments';
|
|
458
|
+
return node?.type === 'mcdoc:doc_comments';
|
|
490
459
|
}
|
|
491
460
|
DocCommentsNode.is = is;
|
|
492
461
|
})(DocCommentsNode || (DocCommentsNode = {}));
|
|
493
462
|
export var EnumBlockNode;
|
|
494
463
|
(function (EnumBlockNode) {
|
|
495
464
|
function destruct(node) {
|
|
496
|
-
return {
|
|
497
|
-
fields: node.children.filter(EnumFieldNode.is),
|
|
498
|
-
};
|
|
465
|
+
return { fields: node.children.filter(EnumFieldNode.is) };
|
|
499
466
|
}
|
|
500
467
|
EnumBlockNode.destruct = destruct;
|
|
501
468
|
function is(node) {
|
|
@@ -551,28 +518,22 @@ export var StructNode;
|
|
|
551
518
|
export var ReferenceTypeNode;
|
|
552
519
|
(function (ReferenceTypeNode) {
|
|
553
520
|
function destruct(node) {
|
|
554
|
-
return {
|
|
555
|
-
path: node.children.find(PathNode.is),
|
|
556
|
-
};
|
|
521
|
+
return { path: node.children.find(PathNode.is) };
|
|
557
522
|
}
|
|
558
523
|
ReferenceTypeNode.destruct = destruct;
|
|
559
524
|
function is(node) {
|
|
560
|
-
return (node?.type ===
|
|
561
|
-
'mcdoc:type/reference');
|
|
525
|
+
return (node?.type === 'mcdoc:type/reference');
|
|
562
526
|
}
|
|
563
527
|
ReferenceTypeNode.is = is;
|
|
564
528
|
})(ReferenceTypeNode || (ReferenceTypeNode = {}));
|
|
565
529
|
export var TypeParamBlockNode;
|
|
566
530
|
(function (TypeParamBlockNode) {
|
|
567
531
|
function destruct(node) {
|
|
568
|
-
return {
|
|
569
|
-
params: node.children.filter(TypeParamNode.is),
|
|
570
|
-
};
|
|
532
|
+
return { params: node.children.filter(TypeParamNode.is) };
|
|
571
533
|
}
|
|
572
534
|
TypeParamBlockNode.destruct = destruct;
|
|
573
535
|
function is(node) {
|
|
574
|
-
return (node?.type ===
|
|
575
|
-
'mcdoc:type_param_block');
|
|
536
|
+
return (node?.type === 'mcdoc:type_param_block');
|
|
576
537
|
}
|
|
577
538
|
TypeParamBlockNode.is = is;
|
|
578
539
|
})(TypeParamBlockNode || (TypeParamBlockNode = {}));
|
|
@@ -609,14 +570,11 @@ export var PathNode;
|
|
|
609
570
|
export var StructBlockNode;
|
|
610
571
|
(function (StructBlockNode) {
|
|
611
572
|
function destruct(node) {
|
|
612
|
-
return {
|
|
613
|
-
fields: node.children.filter(StructFieldNode.is),
|
|
614
|
-
};
|
|
573
|
+
return { fields: node.children.filter(StructFieldNode.is) };
|
|
615
574
|
}
|
|
616
575
|
StructBlockNode.destruct = destruct;
|
|
617
576
|
function is(node) {
|
|
618
|
-
return node?.type ===
|
|
619
|
-
'mcdoc:struct/block';
|
|
577
|
+
return node?.type === 'mcdoc:struct/block';
|
|
620
578
|
}
|
|
621
579
|
StructBlockNode.is = is;
|
|
622
580
|
})(StructBlockNode || (StructBlockNode = {}));
|
|
@@ -632,6 +590,7 @@ export var StructPairFieldNode;
|
|
|
632
590
|
function destruct(node) {
|
|
633
591
|
return {
|
|
634
592
|
attributes: node.children.filter(AttributeNode.is),
|
|
593
|
+
docComments: node.children.find(DocCommentsNode.is),
|
|
635
594
|
key: node.children.find(StructKeyNode.is),
|
|
636
595
|
type: node.children.find(TypeNode.is),
|
|
637
596
|
isOptional: node.isOptional,
|
|
@@ -639,26 +598,21 @@ export var StructPairFieldNode;
|
|
|
639
598
|
}
|
|
640
599
|
StructPairFieldNode.destruct = destruct;
|
|
641
600
|
function is(node) {
|
|
642
|
-
return (node?.type ===
|
|
643
|
-
'mcdoc:struct/field/pair');
|
|
601
|
+
return (node?.type === 'mcdoc:struct/field/pair');
|
|
644
602
|
}
|
|
645
603
|
StructPairFieldNode.is = is;
|
|
646
604
|
})(StructPairFieldNode || (StructPairFieldNode = {}));
|
|
647
605
|
export var StructKeyNode;
|
|
648
606
|
(function (StructKeyNode) {
|
|
649
607
|
function is(node) {
|
|
650
|
-
return (StringNode.is(node) ||
|
|
651
|
-
IdentifierNode.is(node) ||
|
|
652
|
-
StructMapKeyNode.is(node));
|
|
608
|
+
return (StringNode.is(node) || IdentifierNode.is(node) || StructMapKeyNode.is(node));
|
|
653
609
|
}
|
|
654
610
|
StructKeyNode.is = is;
|
|
655
611
|
})(StructKeyNode || (StructKeyNode = {}));
|
|
656
612
|
export var StructMapKeyNode;
|
|
657
613
|
(function (StructMapKeyNode) {
|
|
658
614
|
function destruct(node) {
|
|
659
|
-
return {
|
|
660
|
-
type: node.children.find(TypeNode.is),
|
|
661
|
-
};
|
|
615
|
+
return { type: node.children.find(TypeNode.is) };
|
|
662
616
|
}
|
|
663
617
|
StructMapKeyNode.destruct = destruct;
|
|
664
618
|
function is(node) {
|
|
@@ -676,8 +630,7 @@ export var StructSpreadFieldNode;
|
|
|
676
630
|
}
|
|
677
631
|
StructSpreadFieldNode.destruct = destruct;
|
|
678
632
|
function is(node) {
|
|
679
|
-
return (node?.type ===
|
|
680
|
-
'mcdoc:struct/field/spread');
|
|
633
|
+
return (node?.type === 'mcdoc:struct/field/spread');
|
|
681
634
|
}
|
|
682
635
|
StructSpreadFieldNode.is = is;
|
|
683
636
|
})(StructSpreadFieldNode || (StructSpreadFieldNode = {}));
|
|
@@ -691,17 +644,14 @@ export var DispatcherTypeNode;
|
|
|
691
644
|
}
|
|
692
645
|
DispatcherTypeNode.destruct = destruct;
|
|
693
646
|
function is(node) {
|
|
694
|
-
return (node?.type ===
|
|
695
|
-
'mcdoc:type/dispatcher');
|
|
647
|
+
return (node?.type === 'mcdoc:type/dispatcher');
|
|
696
648
|
}
|
|
697
649
|
DispatcherTypeNode.is = is;
|
|
698
650
|
})(DispatcherTypeNode || (DispatcherTypeNode = {}));
|
|
699
651
|
export var UnionTypeNode;
|
|
700
652
|
(function (UnionTypeNode) {
|
|
701
653
|
function destruct(node) {
|
|
702
|
-
return {
|
|
703
|
-
members: node.children.filter(TypeNode.is),
|
|
704
|
-
};
|
|
654
|
+
return { members: node.children.filter(TypeNode.is) };
|
|
705
655
|
}
|
|
706
656
|
UnionTypeNode.destruct = destruct;
|
|
707
657
|
function is(node) {
|
|
@@ -712,9 +662,7 @@ export var UnionTypeNode;
|
|
|
712
662
|
export var InjectionNode;
|
|
713
663
|
(function (InjectionNode) {
|
|
714
664
|
function destruct(node) {
|
|
715
|
-
return {
|
|
716
|
-
injection: node.children.find(InjectionContentNode.is),
|
|
717
|
-
};
|
|
665
|
+
return { injection: node.children.find(InjectionContentNode.is) };
|
|
718
666
|
}
|
|
719
667
|
InjectionNode.destruct = destruct;
|
|
720
668
|
function is(node) {
|
|
@@ -732,16 +680,14 @@ export var InjectionContentNode;
|
|
|
732
680
|
export var EnumInjectionNode;
|
|
733
681
|
(function (EnumInjectionNode) {
|
|
734
682
|
function is(node) {
|
|
735
|
-
return (node?.type ===
|
|
736
|
-
'mcdoc:injection/enum');
|
|
683
|
+
return (node?.type === 'mcdoc:injection/enum');
|
|
737
684
|
}
|
|
738
685
|
EnumInjectionNode.is = is;
|
|
739
686
|
})(EnumInjectionNode || (EnumInjectionNode = {}));
|
|
740
687
|
export var StructInjectionNode;
|
|
741
688
|
(function (StructInjectionNode) {
|
|
742
689
|
function is(node) {
|
|
743
|
-
return (node?.type ===
|
|
744
|
-
'mcdoc:injection/struct');
|
|
690
|
+
return (node?.type === 'mcdoc:injection/struct');
|
|
745
691
|
}
|
|
746
692
|
StructInjectionNode.is = is;
|
|
747
693
|
})(StructInjectionNode || (StructInjectionNode = {}));
|
package/lib/parser/index.d.ts
CHANGED
|
@@ -21,6 +21,19 @@ export declare const docComment: Parser<CommentNode>;
|
|
|
21
21
|
export declare const docComments: InfallibleParser<DocCommentsNode>;
|
|
22
22
|
export declare const dispatchStatement: Parser<DispatchStatementNode>;
|
|
23
23
|
export declare const float: InfallibleParser<FloatNode>;
|
|
24
|
+
export declare const integer: InfallibleParser<IntegerNode>;
|
|
25
|
+
export declare const LiteralIntSuffixes: readonly ["b", "s", "l"];
|
|
26
|
+
export type LiteralIntSuffix = (typeof LiteralIntSuffixes)[number];
|
|
27
|
+
export declare const LiteralIntCaseInsensitiveSuffixes: readonly ["b", "s", "l", "B", "S", "L"];
|
|
28
|
+
export type LiteralIntCaseInsensitiveSuffix = (typeof LiteralIntCaseInsensitiveSuffixes)[number];
|
|
29
|
+
export declare const LiteralFloatSuffixes: readonly ["f", "d"];
|
|
30
|
+
export type LiteralFloatSuffix = (typeof LiteralFloatSuffixes)[number];
|
|
31
|
+
export declare const LiteralFloatCaseInsensitiveSuffixes: readonly ["f", "d", "F", "D"];
|
|
32
|
+
export type LiteralFloatCaseInsensitiveSuffix = (typeof LiteralFloatCaseInsensitiveSuffixes)[number];
|
|
33
|
+
export declare const LiteralNumberSuffixes: readonly ["b", "s", "l", "f", "d"];
|
|
34
|
+
export type LiteralNumberSuffix = (typeof LiteralNumberSuffixes)[number];
|
|
35
|
+
export declare const LiteralNumberCaseInsensitiveSuffixes: readonly ["b", "s", "l", "f", "d", "b", "s", "l", "B", "S", "L", "f", "d", "F", "D"];
|
|
36
|
+
export type LiteralNumberCaseInsensitiveSuffix = (typeof LiteralNumberCaseInsensitiveSuffixes)[number];
|
|
24
37
|
export declare const typedNumber: InfallibleParser<TypedNumberNode>;
|
|
25
38
|
export declare const enum_: Parser<EnumNode>;
|
|
26
39
|
export declare const struct: Parser<StructNode>;
|
|
@@ -30,7 +43,6 @@ export declare const useStatement: Parser<UseStatementNode>;
|
|
|
30
43
|
export declare const module_: Parser<ModuleNode>;
|
|
31
44
|
export declare const anyType: Parser<AnyTypeNode>;
|
|
32
45
|
export declare const booleanType: Parser<BooleanTypeNode>;
|
|
33
|
-
export declare const integer: InfallibleParser<IntegerNode>;
|
|
34
46
|
export declare const intRange: InfallibleParser<IntRangeNode>;
|
|
35
47
|
export declare const stringType: Parser<StringTypeNode>;
|
|
36
48
|
export declare const literalType: Parser<LiteralTypeNode>;
|