@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/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,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
- 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) {
130
- return (node?.type === 'mcdoc:attribute/tree');
131
- },
132
- });
133
- export const AttributeTreePosValuesNode = Object.freeze({
134
- destruct(node) {
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
- is(node) {
175
+ }
176
+ AttributeTreePosValuesNode.destruct = destruct;
177
+ function is(node) {
140
178
  return (node?.type ===
141
179
  'mcdoc:attribute/tree/pos');
142
- },
143
- });
144
- export const AttributeTreeNamedValuesNode = Object.freeze({
145
- destruct(node) {
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
- is(node) {
203
+ }
204
+ AttributeTreeNamedValuesNode.destruct = destruct;
205
+ function is(node) {
165
206
  return (node?.type ===
166
207
  'mcdoc:attribute/tree/named');
167
- },
168
- });
169
- export const TypeArgBlockNode = Object.freeze({
170
- destruct(node) {
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
- is(node) {
217
+ }
218
+ TypeArgBlockNode.destruct = destruct;
219
+ function is(node) {
176
220
  return (node?.type === 'mcdoc:type_arg_block');
177
- },
178
- });
179
- export const AnyTypeNode = Object.freeze({
180
- is(node) {
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
- export const BooleanTypeNode = Object.freeze({
185
- is(node) {
186
- return node?.type === 'mcdoc:type/boolean';
187
- },
188
- });
189
- export const IntRangeNode = Object.freeze({
190
- destruct(node) {
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
- is(node) {
243
+ }
244
+ IntRangeNode.destruct = destruct;
245
+ function is(node) {
194
246
  return node?.type === 'mcdoc:int_range';
195
- },
196
- });
197
- export const LiteralTypeNode = Object.freeze({
198
- destruct(node) {
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
- is(node) {
204
- return node?.type === 'mcdoc:type/literal';
205
- },
206
- });
207
- export const LiteralTypeValueNode = Object.freeze({
208
- is(node) {
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
- export const TypedNumberNode = Object.freeze({
213
- destruct(node) {
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
- is(node) {
220
- return node?.type === 'mcdoc:typed_number';
221
- },
222
- });
223
- export const NumericTypeNode = Object.freeze({
224
- destruct(node) {
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
- is(node) {
232
- return (node?.type === 'mcdoc:type/numeric_type');
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 const FloatRangeNode = Object.freeze({
283
- destruct(node) {
349
+ export var FloatRangeNode;
350
+ (function (FloatRangeNode) {
351
+ function destruct(node) {
284
352
  return destructRangeNode(node);
285
- },
286
- is(node) {
353
+ }
354
+ FloatRangeNode.destruct = destruct;
355
+ function is(node) {
287
356
  return node?.type === 'mcdoc:float_range';
288
- },
289
- });
290
- export const PrimitiveArrayTypeNode = Object.freeze({
291
- destruct(node) {
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
- is(node) {
384
+ }
385
+ PrimitiveArrayTypeNode.destruct = destruct;
386
+ function is(node) {
315
387
  return (node?.type ===
316
388
  'mcdoc:type/primitive_array');
317
- },
318
- });
319
- export const ListTypeNode = Object.freeze({
320
- destruct(node) {
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
- is(node) {
399
+ }
400
+ ListTypeNode.destruct = destruct;
401
+ function is(node) {
327
402
  return node?.type === 'mcdoc:type/list';
328
- },
329
- });
330
- export const StringTypeNode = Object.freeze({
331
- destruct(node) {
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
- is(node) {
412
+ }
413
+ StringTypeNode.destruct = destruct;
414
+ function is(node) {
337
415
  return node?.type === 'mcdoc:type/string';
338
- },
339
- });
340
- export const TupleTypeNode = Object.freeze({
341
- destruct(node) {
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
- is(node) {
425
+ }
426
+ TupleTypeNode.destruct = destruct;
427
+ function is(node) {
347
428
  return node?.type === 'mcdoc:type/tuple';
348
- },
349
- });
350
- const EnumKinds = new Set([
351
- 'byte',
352
- 'short',
353
- 'int',
354
- 'long',
355
- 'float',
356
- 'double',
357
- 'string',
358
- ]);
359
- export const EnumNode = Object.freeze({
360
- kinds: EnumKinds,
361
- 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) {
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 (EnumKinds.has(literal.value)) {
453
+ if (EnumNode.Kinds.has(literal.value)) {
372
454
  return literal.value;
373
455
  }
374
456
  }
375
457
  return undefined;
376
458
  }
377
- },
378
- is(node) {
459
+ }
460
+ EnumNode.destruct = destruct;
461
+ function is(node) {
379
462
  return node?.type === 'mcdoc:enum';
380
- },
381
- });
382
- export const DocCommentsNode = Object.freeze({
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
- is(node) {
402
- return node?.type === 'mcdoc:doc_comments';
403
- },
404
- });
405
- export const EnumBlockNode = Object.freeze({
406
- destruct(node) {
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
- is(node) {
499
+ }
500
+ EnumBlockNode.destruct = destruct;
501
+ function is(node) {
412
502
  return node?.type === 'mcdoc:enum/block';
413
- },
414
- });
415
- export const EnumFieldNode = Object.freeze({
416
- destruct(node) {
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
- is(node) {
514
+ }
515
+ EnumFieldNode.destruct = destruct;
516
+ function is(node) {
424
517
  return node?.type === 'mcdoc:enum/field';
425
- },
426
- });
427
- export const EnumValueNode = Object.freeze({
428
- is(node) {
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
- export const PrelimNode = Object.freeze({
433
- is(node) {
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
- export const StructNode = Object.freeze({
438
- destruct(node) {
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
- is(node) {
544
+ }
545
+ StructNode.destruct = destruct;
546
+ function is(node) {
447
547
  return node?.type === 'mcdoc:struct';
448
- },
449
- });
450
- export const ReferenceTypeNode = Object.freeze({
451
- destruct(node) {
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
- is(node) {
457
- return (node?.type === 'mcdoc:type/reference');
458
- },
459
- });
460
- export const TypeParamBlockNode = Object.freeze({
461
- destruct(node) {
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
- is(node) {
571
+ }
572
+ TypeParamBlockNode.destruct = destruct;
573
+ function is(node) {
467
574
  return (node?.type ===
468
575
  'mcdoc:type_param_block');
469
- },
470
- });
471
- export const TypeParamNode = Object.freeze({
472
- destruct(node) {
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
- is(node) {
586
+ }
587
+ TypeParamNode.destruct = destruct;
588
+ function is(node) {
479
589
  return node?.type === 'mcdoc:type_param';
480
- },
481
- });
482
- export const PathNode = Object.freeze({
483
- destruct(node) {
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
- is(node) {
602
+ }
603
+ PathNode.destruct = destruct;
604
+ function is(node) {
492
605
  return node?.type === 'mcdoc:path';
493
- },
494
- });
495
- export const StructBlockNode = Object.freeze({
496
- destruct(node) {
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
- is(node) {
502
- return node?.type === 'mcdoc:struct/block';
503
- },
504
- });
505
- export const StructFieldNode = Object.freeze({
506
- is(node) {
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
- export const StructPairFieldNode = Object.freeze({
511
- destruct(node) {
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
- is(node) {
639
+ }
640
+ StructPairFieldNode.destruct = destruct;
641
+ function is(node) {
520
642
  return (node?.type ===
521
643
  'mcdoc:struct/field/pair');
522
- },
523
- });
524
- export const StructKeyNode = Object.freeze({
525
- is(node) {
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
- export const StructMapKeyNode = Object.freeze({
532
- destruct(node) {
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
- is(node) {
662
+ }
663
+ StructMapKeyNode.destruct = destruct;
664
+ function is(node) {
538
665
  return (node?.type === 'mcdoc:struct/map_key');
539
- },
540
- });
541
- export const StructSpreadFieldNode = Object.freeze({
542
- destruct(node) {
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
- is(node) {
676
+ }
677
+ StructSpreadFieldNode.destruct = destruct;
678
+ function is(node) {
549
679
  return (node?.type ===
550
680
  'mcdoc:struct/field/spread');
551
- },
552
- });
553
- export const DispatcherTypeNode = Object.freeze({
554
- destruct(node) {
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
- is(node) {
561
- return (node?.type === 'mcdoc:type/dispatcher');
562
- },
563
- });
564
- export const UnionTypeNode = Object.freeze({
565
- destruct(node) {
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
- is(node) {
705
+ }
706
+ UnionTypeNode.destruct = destruct;
707
+ function is(node) {
571
708
  return node?.type === 'mcdoc:type/union';
572
- },
573
- });
574
- export const InjectionNode = Object.freeze({
575
- destruct(node) {
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
- is(node) {
718
+ }
719
+ InjectionNode.destruct = destruct;
720
+ function is(node) {
581
721
  return node?.type === 'mcdoc:injection';
582
- },
583
- });
584
- export const InjectionContentNode = Object.freeze({
585
- is(node) {
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
- export const EnumInjectionNode = Object.freeze({
590
- is(node) {
591
- return (node?.type === 'mcdoc:injection/enum');
592
- },
593
- });
594
- export const StructInjectionNode = Object.freeze({
595
- is(node) {
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
- export const TypeAliasNode = Object.freeze({
601
- destruct(node) {
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
- is(node) {
759
+ }
760
+ TypeAliasNode.destruct = destruct;
761
+ function is(node) {
612
762
  return node?.type === 'mcdoc:type_alias';
613
- },
614
- });
615
- export const UseStatementNode = Object.freeze({
616
- destruct(node) {
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
- is(node) {
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