@spyglassmc/mcdoc 0.3.3 → 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/node/index.js CHANGED
@@ -1,11 +1,14 @@
1
1
  import { atArray, CommentNode, FloatNode, ResourceLocationNode, StringNode, } from '@spyglassmc/core';
2
- export const ModuleNode = Object.freeze({
3
- is(node) {
2
+ export var ModuleNode;
3
+ (function (ModuleNode) {
4
+ function is(node) {
4
5
  return node?.type === 'mcdoc:module';
5
- },
6
- });
7
- export const TopLevelNode = Object.freeze({
8
- is(node) {
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
- export const DispatchStatementNode = Object.freeze({
19
- destruct(node) {
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
- is(node) {
32
+ }
33
+ DispatchStatementNode.destruct = destruct;
34
+ function is(node) {
29
35
  return (node?.type ===
30
36
  'mcdoc:dispatch_statement');
31
- },
32
- });
33
- export const LiteralNode = Object.freeze({
34
- is(node) {
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
- export const IndexBodyNode = Object.freeze({
39
- destruct(node) {
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
- is(node) {
53
+ }
54
+ IndexBodyNode.destruct = destruct;
55
+ function is(node) {
45
56
  return node?.type === 'mcdoc:index_body';
46
- },
47
- });
48
- export const IndexNode = Object.freeze({
49
- is(node) {
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
- export const StaticIndexNode = Object.freeze({
54
- is(node) {
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
- export const IdentifierNode = Object.freeze({
62
- is(node) {
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
- export const DynamicIndexNode = Object.freeze({
67
- destruct(node) {
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
- is(node) {
90
+ }
91
+ DynamicIndexNode.destruct = destruct;
92
+ function is(node) {
73
93
  return (node?.type === 'mcdoc:dynamic_index');
74
- },
75
- });
76
- export const AccessorKeyNode = Object.freeze({
77
- is(node) {
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
- export const TypeNode = Object.freeze({
82
- is(node) {
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
- export const TypeBaseNode = Object.freeze({
99
- destruct(node) {
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
- export const AttributeNode = Object.freeze({
107
- destruct(node) {
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
- is(node) {
140
+ }
141
+ AttributeNode.destruct = destruct;
142
+ function is(node) {
114
143
  return node?.type === 'mcdoc:attribute';
115
- },
116
- });
117
- export const AttributeValueNode = Object.freeze({
118
- is(node) {
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
- export const AttributeTreeNode = Object.freeze({
123
- destruct(node) {
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
- is(node) {
161
+ }
162
+ AttributeTreeNode.destruct = destruct;
163
+ function is(node) {
130
164
  return (node?.type ===
131
165
  'mcdoc:attribute/tree');
132
- },
133
- });
134
- export const AttributeTreePosValuesNode = Object.freeze({
135
- destruct(node) {
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
- is(node) {
175
+ }
176
+ AttributeTreePosValuesNode.destruct = destruct;
177
+ function is(node) {
141
178
  return (node?.type ===
142
179
  'mcdoc:attribute/tree/pos');
143
- },
144
- });
145
- export const AttributeTreeNamedValuesNode = Object.freeze({
146
- destruct(node) {
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
- is(node) {
203
+ }
204
+ AttributeTreeNamedValuesNode.destruct = destruct;
205
+ function is(node) {
166
206
  return (node?.type ===
167
207
  'mcdoc:attribute/tree/named');
168
- },
169
- });
170
- export const TypeArgBlockNode = Object.freeze({
171
- destruct(node) {
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
- is(node) {
217
+ }
218
+ TypeArgBlockNode.destruct = destruct;
219
+ function is(node) {
177
220
  return (node?.type === 'mcdoc:type_arg_block');
178
- },
179
- });
180
- export const AnyTypeNode = Object.freeze({
181
- is(node) {
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
- export const BooleanTypeNode = Object.freeze({
186
- is(node) {
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
- export const IntRangeNode = Object.freeze({
192
- destruct(node) {
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
- is(node) {
243
+ }
244
+ IntRangeNode.destruct = destruct;
245
+ function is(node) {
196
246
  return node?.type === 'mcdoc:int_range';
197
- },
198
- });
199
- export const LiteralTypeNode = Object.freeze({
200
- destruct(node) {
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
- is(node) {
256
+ }
257
+ LiteralTypeNode.destruct = destruct;
258
+ function is(node) {
206
259
  return node?.type ===
207
260
  'mcdoc:type/literal';
208
- },
209
- });
210
- export const LiteralTypeValueNode = Object.freeze({
211
- is(node) {
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
- export const TypedNumberNode = Object.freeze({
216
- destruct(node) {
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
- is(node) {
278
+ }
279
+ TypedNumberNode.destruct = destruct;
280
+ function is(node) {
223
281
  return node?.type ===
224
282
  'mcdoc:typed_number';
225
- },
226
- });
227
- export const NumericTypeNode = Object.freeze({
228
- destruct(node) {
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
- is(node) {
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 const FloatRangeNode = Object.freeze({
288
- destruct(node) {
349
+ export var FloatRangeNode;
350
+ (function (FloatRangeNode) {
351
+ function destruct(node) {
289
352
  return destructRangeNode(node);
290
- },
291
- is(node) {
353
+ }
354
+ FloatRangeNode.destruct = destruct;
355
+ function is(node) {
292
356
  return node?.type === 'mcdoc:float_range';
293
- },
294
- });
295
- export const PrimitiveArrayTypeNode = Object.freeze({
296
- destruct(node) {
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
- is(node) {
384
+ }
385
+ PrimitiveArrayTypeNode.destruct = destruct;
386
+ function is(node) {
320
387
  return (node?.type ===
321
388
  'mcdoc:type/primitive_array');
322
- },
323
- });
324
- export const ListTypeNode = Object.freeze({
325
- destruct(node) {
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
- is(node) {
399
+ }
400
+ ListTypeNode.destruct = destruct;
401
+ function is(node) {
332
402
  return node?.type === 'mcdoc:type/list';
333
- },
334
- });
335
- export const StringTypeNode = Object.freeze({
336
- destruct(node) {
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
- is(node) {
412
+ }
413
+ StringTypeNode.destruct = destruct;
414
+ function is(node) {
342
415
  return node?.type === 'mcdoc:type/string';
343
- },
344
- });
345
- export const TupleTypeNode = Object.freeze({
346
- destruct(node) {
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
- is(node) {
425
+ }
426
+ TupleTypeNode.destruct = destruct;
427
+ function is(node) {
352
428
  return node?.type === 'mcdoc:type/tuple';
353
- },
354
- });
355
- const EnumKinds = new Set([
356
- 'byte',
357
- 'short',
358
- 'int',
359
- 'long',
360
- 'float',
361
- 'double',
362
- 'string',
363
- ]);
364
- export const EnumNode = Object.freeze({
365
- kinds: EnumKinds,
366
- destruct(node) {
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 (EnumKinds.has(literal.value)) {
453
+ if (EnumNode.Kinds.has(literal.value)) {
377
454
  return literal.value;
378
455
  }
379
456
  }
380
457
  return undefined;
381
458
  }
382
- },
383
- is(node) {
459
+ }
460
+ EnumNode.destruct = destruct;
461
+ function is(node) {
384
462
  return node?.type === 'mcdoc:enum';
385
- },
386
- });
387
- export const DocCommentsNode = Object.freeze({
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
- is(node) {
485
+ }
486
+ DocCommentsNode.asText = asText;
487
+ function is(node) {
407
488
  return node?.type ===
408
489
  'mcdoc:doc_comments';
409
- },
410
- });
411
- export const EnumBlockNode = Object.freeze({
412
- destruct(node) {
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
- is(node) {
499
+ }
500
+ EnumBlockNode.destruct = destruct;
501
+ function is(node) {
418
502
  return node?.type === 'mcdoc:enum/block';
419
- },
420
- });
421
- export const EnumFieldNode = Object.freeze({
422
- destruct(node) {
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
- is(node) {
514
+ }
515
+ EnumFieldNode.destruct = destruct;
516
+ function is(node) {
430
517
  return node?.type === 'mcdoc:enum/field';
431
- },
432
- });
433
- export const EnumValueNode = Object.freeze({
434
- is(node) {
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
- export const PrelimNode = Object.freeze({
439
- is(node) {
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
- export const StructNode = Object.freeze({
444
- destruct(node) {
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
- is(node) {
544
+ }
545
+ StructNode.destruct = destruct;
546
+ function is(node) {
453
547
  return node?.type === 'mcdoc:struct';
454
- },
455
- });
456
- export const ReferenceTypeNode = Object.freeze({
457
- destruct(node) {
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
- is(node) {
557
+ }
558
+ ReferenceTypeNode.destruct = destruct;
559
+ function is(node) {
463
560
  return (node?.type ===
464
561
  'mcdoc:type/reference');
465
- },
466
- });
467
- export const TypeParamBlockNode = Object.freeze({
468
- destruct(node) {
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
- is(node) {
571
+ }
572
+ TypeParamBlockNode.destruct = destruct;
573
+ function is(node) {
474
574
  return (node?.type ===
475
575
  'mcdoc:type_param_block');
476
- },
477
- });
478
- export const TypeParamNode = Object.freeze({
479
- destruct(node) {
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
- is(node) {
586
+ }
587
+ TypeParamNode.destruct = destruct;
588
+ function is(node) {
486
589
  return node?.type === 'mcdoc:type_param';
487
- },
488
- });
489
- export const PathNode = Object.freeze({
490
- destruct(node) {
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
- is(node) {
602
+ }
603
+ PathNode.destruct = destruct;
604
+ function is(node) {
499
605
  return node?.type === 'mcdoc:path';
500
- },
501
- });
502
- export const StructBlockNode = Object.freeze({
503
- destruct(node) {
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
- is(node) {
615
+ }
616
+ StructBlockNode.destruct = destruct;
617
+ function is(node) {
509
618
  return node?.type ===
510
619
  'mcdoc:struct/block';
511
- },
512
- });
513
- export const StructFieldNode = Object.freeze({
514
- is(node) {
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
- export const StructPairFieldNode = Object.freeze({
519
- destruct(node) {
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
- is(node) {
639
+ }
640
+ StructPairFieldNode.destruct = destruct;
641
+ function is(node) {
528
642
  return (node?.type ===
529
643
  'mcdoc:struct/field/pair');
530
- },
531
- });
532
- export const StructKeyNode = Object.freeze({
533
- is(node) {
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
- export const StructMapKeyNode = Object.freeze({
540
- destruct(node) {
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
- is(node) {
662
+ }
663
+ StructMapKeyNode.destruct = destruct;
664
+ function is(node) {
546
665
  return (node?.type === 'mcdoc:struct/map_key');
547
- },
548
- });
549
- export const StructSpreadFieldNode = Object.freeze({
550
- destruct(node) {
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
- is(node) {
676
+ }
677
+ StructSpreadFieldNode.destruct = destruct;
678
+ function is(node) {
557
679
  return (node?.type ===
558
680
  'mcdoc:struct/field/spread');
559
- },
560
- });
561
- export const DispatcherTypeNode = Object.freeze({
562
- destruct(node) {
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
- is(node) {
691
+ }
692
+ DispatcherTypeNode.destruct = destruct;
693
+ function is(node) {
569
694
  return (node?.type ===
570
695
  'mcdoc:type/dispatcher');
571
- },
572
- });
573
- export const UnionTypeNode = Object.freeze({
574
- destruct(node) {
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
- is(node) {
705
+ }
706
+ UnionTypeNode.destruct = destruct;
707
+ function is(node) {
580
708
  return node?.type === 'mcdoc:type/union';
581
- },
582
- });
583
- export const InjectionNode = Object.freeze({
584
- destruct(node) {
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
- is(node) {
718
+ }
719
+ InjectionNode.destruct = destruct;
720
+ function is(node) {
590
721
  return node?.type === 'mcdoc:injection';
591
- },
592
- });
593
- export const InjectionContentNode = Object.freeze({
594
- is(node) {
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
- export const EnumInjectionNode = Object.freeze({
599
- is(node) {
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
- export const StructInjectionNode = Object.freeze({
605
- is(node) {
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
- export const TypeAliasNode = Object.freeze({
611
- destruct(node) {
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
- is(node) {
759
+ }
760
+ TypeAliasNode.destruct = destruct;
761
+ function is(node) {
622
762
  return node?.type === 'mcdoc:type_alias';
623
- },
624
- });
625
- export const UseStatementNode = Object.freeze({
626
- destruct(node) {
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
- is(node) {
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