brighterscript 0.67.6 → 0.67.8

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +11 -0
  3. package/dist/ProgramBuilder.js +3 -1
  4. package/dist/ProgramBuilder.js.map +1 -1
  5. package/dist/astUtils/reflection.d.ts +5 -2
  6. package/dist/astUtils/reflection.js +17 -2
  7. package/dist/astUtils/reflection.js.map +1 -1
  8. package/dist/astUtils/visitors.js +1 -1
  9. package/dist/astUtils/visitors.js.map +1 -1
  10. package/dist/files/BrsFile.d.ts +1 -1
  11. package/dist/files/BrsFile.js +8 -0
  12. package/dist/files/BrsFile.js.map +1 -1
  13. package/dist/files/BrsFile.spec.js +31 -0
  14. package/dist/files/BrsFile.spec.js.map +1 -1
  15. package/dist/parser/AstNode.d.ts +12 -1
  16. package/dist/parser/AstNode.js +20 -0
  17. package/dist/parser/AstNode.js.map +1 -1
  18. package/dist/parser/AstNode.spec.js +1266 -0
  19. package/dist/parser/AstNode.spec.js.map +1 -1
  20. package/dist/parser/Expression.d.ts +27 -0
  21. package/dist/parser/Expression.js +131 -11
  22. package/dist/parser/Expression.js.map +1 -1
  23. package/dist/parser/Statement.d.ts +40 -1
  24. package/dist/parser/Statement.js +227 -6
  25. package/dist/parser/Statement.js.map +1 -1
  26. package/dist/parser/Statement.spec.js.map +1 -1
  27. package/dist/types/ArrayType.d.ts +1 -0
  28. package/dist/types/ArrayType.js +4 -0
  29. package/dist/types/ArrayType.js.map +1 -1
  30. package/dist/types/BooleanType.d.ts +1 -0
  31. package/dist/types/BooleanType.js +3 -0
  32. package/dist/types/BooleanType.js.map +1 -1
  33. package/dist/types/BscType.d.ts +1 -0
  34. package/dist/types/CustomType.d.ts +1 -0
  35. package/dist/types/CustomType.js +3 -0
  36. package/dist/types/CustomType.js.map +1 -1
  37. package/dist/types/DoubleType.d.ts +1 -0
  38. package/dist/types/DoubleType.js +3 -0
  39. package/dist/types/DoubleType.js.map +1 -1
  40. package/dist/types/DynamicType.d.ts +1 -0
  41. package/dist/types/DynamicType.js +3 -0
  42. package/dist/types/DynamicType.js.map +1 -1
  43. package/dist/types/FloatType.d.ts +1 -0
  44. package/dist/types/FloatType.js +3 -0
  45. package/dist/types/FloatType.js.map +1 -1
  46. package/dist/types/FunctionType.d.ts +1 -0
  47. package/dist/types/FunctionType.js +10 -0
  48. package/dist/types/FunctionType.js.map +1 -1
  49. package/dist/types/IntegerType.d.ts +1 -0
  50. package/dist/types/IntegerType.js +3 -0
  51. package/dist/types/IntegerType.js.map +1 -1
  52. package/dist/types/InterfaceType.d.ts +1 -0
  53. package/dist/types/InterfaceType.js +9 -0
  54. package/dist/types/InterfaceType.js.map +1 -1
  55. package/dist/types/InvalidType.d.ts +1 -0
  56. package/dist/types/InvalidType.js +3 -0
  57. package/dist/types/InvalidType.js.map +1 -1
  58. package/dist/types/LongIntegerType.d.ts +1 -0
  59. package/dist/types/LongIntegerType.js +3 -0
  60. package/dist/types/LongIntegerType.js.map +1 -1
  61. package/dist/types/ObjectType.d.ts +1 -0
  62. package/dist/types/ObjectType.js +3 -0
  63. package/dist/types/ObjectType.js.map +1 -1
  64. package/dist/types/StringType.d.ts +1 -0
  65. package/dist/types/StringType.js +3 -0
  66. package/dist/types/StringType.js.map +1 -1
  67. package/dist/types/UninitializedType.d.ts +1 -0
  68. package/dist/types/UninitializedType.js +3 -0
  69. package/dist/types/UninitializedType.js.map +1 -1
  70. package/dist/types/VoidType.d.ts +1 -0
  71. package/dist/types/VoidType.js +3 -0
  72. package/dist/types/VoidType.js.map +1 -1
  73. package/dist/util.d.ts +8 -0
  74. package/dist/util.js +33 -0
  75. package/dist/util.js.map +1 -1
  76. package/package.json +3 -3
@@ -26,6 +26,9 @@ class EmptyStatement extends AstNode_1.Statement {
26
26
  walk(visitor, options) {
27
27
  //nothing to walk
28
28
  }
29
+ clone() {
30
+ return this.finalizeClone(new EmptyStatement(util_1.util.cloneRange(this.range)));
31
+ }
29
32
  }
30
33
  exports.EmptyStatement = EmptyStatement;
31
34
  /**
@@ -87,6 +90,10 @@ class Body extends AstNode_1.Statement {
87
90
  (0, visitors_1.walkArray)(this.statements, visitor, options, this);
88
91
  }
89
92
  }
93
+ clone() {
94
+ var _a;
95
+ return this.finalizeClone(new Body((_a = this.statements) === null || _a === void 0 ? void 0 : _a.map(s => s === null || s === void 0 ? void 0 : s.clone())), ['statements']);
96
+ }
90
97
  }
91
98
  exports.Body = Body;
92
99
  class AssignmentStatement extends AstNode_1.Statement {
@@ -125,6 +132,10 @@ class AssignmentStatement extends AstNode_1.Statement {
125
132
  (0, visitors_1.walk)(this, 'value', visitor, options);
126
133
  }
127
134
  }
135
+ clone() {
136
+ var _a;
137
+ return this.finalizeClone(new AssignmentStatement(util_1.util.cloneToken(this.equals), util_1.util.cloneToken(this.name), (_a = this.value) === null || _a === void 0 ? void 0 : _a.clone()), ['value']);
138
+ }
128
139
  }
129
140
  exports.AssignmentStatement = AssignmentStatement;
130
141
  class Block extends AstNode_1.Statement {
@@ -163,13 +174,18 @@ class Block extends AstNode_1.Statement {
163
174
  (0, visitors_1.walkArray)(this.statements, visitor, options, this);
164
175
  }
165
176
  }
177
+ clone() {
178
+ var _a;
179
+ return this.finalizeClone(new Block((_a = this.statements) === null || _a === void 0 ? void 0 : _a.map(s => s === null || s === void 0 ? void 0 : s.clone()), util_1.util.cloneRange(this.startingRange)), ['statements']);
180
+ }
166
181
  }
167
182
  exports.Block = Block;
168
183
  class ExpressionStatement extends AstNode_1.Statement {
169
184
  constructor(expression) {
185
+ var _a;
170
186
  super();
171
187
  this.expression = expression;
172
- this.range = this.expression.range;
188
+ this.range = (_a = this.expression) === null || _a === void 0 ? void 0 : _a.range;
173
189
  }
174
190
  transpile(state) {
175
191
  return this.expression.transpile(state);
@@ -179,6 +195,10 @@ class ExpressionStatement extends AstNode_1.Statement {
179
195
  (0, visitors_1.walk)(this, 'expression', visitor, options);
180
196
  }
181
197
  }
198
+ clone() {
199
+ var _a;
200
+ return this.finalizeClone(new ExpressionStatement((_a = this.expression) === null || _a === void 0 ? void 0 : _a.clone()), ['expression']);
201
+ }
182
202
  }
183
203
  exports.ExpressionStatement = ExpressionStatement;
184
204
  class CommentStatement extends AstNode_1.Statement {
@@ -215,6 +235,10 @@ class CommentStatement extends AstNode_1.Statement {
215
235
  walk(visitor, options) {
216
236
  //nothing to walk
217
237
  }
238
+ clone() {
239
+ var _a;
240
+ return this.finalizeClone(new CommentStatement((_a = this.comments) === null || _a === void 0 ? void 0 : _a.map(x => util_1.util.cloneToken(x))), ['comments']);
241
+ }
218
242
  }
219
243
  exports.CommentStatement = CommentStatement;
220
244
  class ExitForStatement extends AstNode_1.Statement {
@@ -231,6 +255,11 @@ class ExitForStatement extends AstNode_1.Statement {
231
255
  walk(visitor, options) {
232
256
  //nothing to walk
233
257
  }
258
+ clone() {
259
+ return this.finalizeClone(new ExitForStatement({
260
+ exitFor: util_1.util.cloneToken(this.tokens.exitFor)
261
+ }));
262
+ }
234
263
  }
235
264
  exports.ExitForStatement = ExitForStatement;
236
265
  class ExitWhileStatement extends AstNode_1.Statement {
@@ -247,14 +276,20 @@ class ExitWhileStatement extends AstNode_1.Statement {
247
276
  walk(visitor, options) {
248
277
  //nothing to walk
249
278
  }
279
+ clone() {
280
+ return this.finalizeClone(new ExitWhileStatement({
281
+ exitWhile: util_1.util.cloneToken(this.tokens.exitWhile)
282
+ }));
283
+ }
250
284
  }
251
285
  exports.ExitWhileStatement = ExitWhileStatement;
252
286
  class FunctionStatement extends AstNode_1.Statement {
253
287
  constructor(name, func) {
288
+ var _a;
254
289
  super();
255
290
  this.name = name;
256
291
  this.func = func;
257
- this.range = this.func.range;
292
+ this.range = (_a = this.func) === null || _a === void 0 ? void 0 : _a.range;
258
293
  }
259
294
  /**
260
295
  * Get the name of this expression based on the parse mode
@@ -298,6 +333,10 @@ class FunctionStatement extends AstNode_1.Statement {
298
333
  (0, visitors_1.walk)(this, 'func', visitor, options);
299
334
  }
300
335
  }
336
+ clone() {
337
+ var _a;
338
+ return this.finalizeClone(new FunctionStatement(util_1.util.cloneToken(this.name), (_a = this.func) === null || _a === void 0 ? void 0 : _a.clone()), ['func']);
339
+ }
301
340
  }
302
341
  exports.FunctionStatement = FunctionStatement;
303
342
  class IfStatement extends AstNode_1.Statement {
@@ -384,6 +423,15 @@ class IfStatement extends AstNode_1.Statement {
384
423
  (0, visitors_1.walk)(this, 'elseBranch', visitor, options);
385
424
  }
386
425
  }
426
+ clone() {
427
+ var _a, _b, _c;
428
+ return this.finalizeClone(new IfStatement({
429
+ if: util_1.util.cloneToken(this.tokens.if),
430
+ else: util_1.util.cloneToken(this.tokens.else),
431
+ endIf: util_1.util.cloneToken(this.tokens.endIf),
432
+ then: util_1.util.cloneToken(this.tokens.then)
433
+ }, (_a = this.condition) === null || _a === void 0 ? void 0 : _a.clone(), (_b = this.thenBranch) === null || _b === void 0 ? void 0 : _b.clone(), (_c = this.elseBranch) === null || _c === void 0 ? void 0 : _c.clone(), this.isInline), ['condition', 'thenBranch', 'elseBranch']);
434
+ }
387
435
  }
388
436
  exports.IfStatement = IfStatement;
389
437
  class IncrementStatement extends AstNode_1.Statement {
@@ -404,6 +452,10 @@ class IncrementStatement extends AstNode_1.Statement {
404
452
  (0, visitors_1.walk)(this, 'value', visitor, options);
405
453
  }
406
454
  }
455
+ clone() {
456
+ var _a;
457
+ return this.finalizeClone(new IncrementStatement((_a = this.value) === null || _a === void 0 ? void 0 : _a.clone(), util_1.util.cloneToken(this.operator)), ['value']);
458
+ }
407
459
  }
408
460
  exports.IncrementStatement = IncrementStatement;
409
461
  /**
@@ -449,6 +501,19 @@ class PrintStatement extends AstNode_1.Statement {
449
501
  (0, visitors_1.walkArray)(this.expressions, visitor, options, this, (item) => (0, reflection_1.isExpression)(item));
450
502
  }
451
503
  }
504
+ clone() {
505
+ var _a;
506
+ return this.finalizeClone(new PrintStatement({
507
+ print: util_1.util.cloneToken(this.tokens.print)
508
+ }, (_a = this.expressions) === null || _a === void 0 ? void 0 : _a.map(e => {
509
+ if ((0, reflection_1.isExpression)(e)) {
510
+ return e.clone();
511
+ }
512
+ else {
513
+ return util_1.util.cloneToken(e);
514
+ }
515
+ })), ['expressions']);
516
+ }
452
517
  }
453
518
  exports.PrintStatement = PrintStatement;
454
519
  class DimStatement extends AstNode_1.Statement {
@@ -483,6 +548,10 @@ class DimStatement extends AstNode_1.Statement {
483
548
  (0, visitors_1.walkArray)(this.dimensions, visitor, options, this);
484
549
  }
485
550
  }
551
+ clone() {
552
+ var _a;
553
+ return this.finalizeClone(new DimStatement(util_1.util.cloneToken(this.dimToken), util_1.util.cloneToken(this.identifier), util_1.util.cloneToken(this.openingSquare), (_a = this.dimensions) === null || _a === void 0 ? void 0 : _a.map(e => e === null || e === void 0 ? void 0 : e.clone()), util_1.util.cloneToken(this.closingSquare)), ['dimensions']);
554
+ }
486
555
  }
487
556
  exports.DimStatement = DimStatement;
488
557
  class GotoStatement extends AstNode_1.Statement {
@@ -501,6 +570,12 @@ class GotoStatement extends AstNode_1.Statement {
501
570
  walk(visitor, options) {
502
571
  //nothing to walk
503
572
  }
573
+ clone() {
574
+ return this.finalizeClone(new GotoStatement({
575
+ goto: util_1.util.cloneToken(this.tokens.goto),
576
+ label: util_1.util.cloneToken(this.tokens.label)
577
+ }));
578
+ }
504
579
  }
505
580
  exports.GotoStatement = GotoStatement;
506
581
  class LabelStatement extends AstNode_1.Statement {
@@ -518,6 +593,12 @@ class LabelStatement extends AstNode_1.Statement {
518
593
  walk(visitor, options) {
519
594
  //nothing to walk
520
595
  }
596
+ clone() {
597
+ return this.finalizeClone(new LabelStatement({
598
+ identifier: util_1.util.cloneToken(this.tokens.identifier),
599
+ colon: util_1.util.cloneToken(this.tokens.colon)
600
+ }));
601
+ }
521
602
  }
522
603
  exports.LabelStatement = LabelStatement;
523
604
  class ReturnStatement extends AstNode_1.Statement {
@@ -541,6 +622,12 @@ class ReturnStatement extends AstNode_1.Statement {
541
622
  (0, visitors_1.walk)(this, 'value', visitor, options);
542
623
  }
543
624
  }
625
+ clone() {
626
+ var _a;
627
+ return this.finalizeClone(new ReturnStatement({
628
+ return: util_1.util.cloneToken(this.tokens.return)
629
+ }, (_a = this.value) === null || _a === void 0 ? void 0 : _a.clone()), ['value']);
630
+ }
544
631
  }
545
632
  exports.ReturnStatement = ReturnStatement;
546
633
  class EndStatement extends AstNode_1.Statement {
@@ -557,6 +644,11 @@ class EndStatement extends AstNode_1.Statement {
557
644
  walk(visitor, options) {
558
645
  //nothing to walk
559
646
  }
647
+ clone() {
648
+ return this.finalizeClone(new EndStatement({
649
+ end: util_1.util.cloneToken(this.tokens.end)
650
+ }));
651
+ }
560
652
  }
561
653
  exports.EndStatement = EndStatement;
562
654
  class StopStatement extends AstNode_1.Statement {
@@ -574,6 +666,11 @@ class StopStatement extends AstNode_1.Statement {
574
666
  walk(visitor, options) {
575
667
  //nothing to walk
576
668
  }
669
+ clone() {
670
+ return this.finalizeClone(new StopStatement({
671
+ stop: util_1.util.cloneToken(this.tokens.stop)
672
+ }));
673
+ }
577
674
  }
578
675
  exports.StopStatement = StopStatement;
579
676
  class ForStatement extends AstNode_1.Statement {
@@ -625,6 +722,10 @@ class ForStatement extends AstNode_1.Statement {
625
722
  (0, visitors_1.walk)(this, 'body', visitor, options);
626
723
  }
627
724
  }
725
+ clone() {
726
+ var _a, _b, _c, _d;
727
+ return this.finalizeClone(new ForStatement(util_1.util.cloneToken(this.forToken), (_a = this.counterDeclaration) === null || _a === void 0 ? void 0 : _a.clone(), util_1.util.cloneToken(this.toToken), (_b = this.finalValue) === null || _b === void 0 ? void 0 : _b.clone(), (_c = this.body) === null || _c === void 0 ? void 0 : _c.clone(), util_1.util.cloneToken(this.endForToken), util_1.util.cloneToken(this.stepToken), (_d = this.increment) === null || _d === void 0 ? void 0 : _d.clone()), ['counterDeclaration', 'finalValue', 'body', 'increment']);
728
+ }
628
729
  }
629
730
  exports.ForStatement = ForStatement;
630
731
  class ForEachStatement extends AstNode_1.Statement {
@@ -664,6 +765,14 @@ class ForEachStatement extends AstNode_1.Statement {
664
765
  (0, visitors_1.walk)(this, 'body', visitor, options);
665
766
  }
666
767
  }
768
+ clone() {
769
+ var _a, _b;
770
+ return this.finalizeClone(new ForEachStatement({
771
+ forEach: util_1.util.cloneToken(this.tokens.forEach),
772
+ in: util_1.util.cloneToken(this.tokens.in),
773
+ endFor: util_1.util.cloneToken(this.tokens.endFor)
774
+ }, util_1.util.cloneToken(this.item), (_a = this.target) === null || _a === void 0 ? void 0 : _a.clone(), (_b = this.body) === null || _b === void 0 ? void 0 : _b.clone()), ['target', 'body']);
775
+ }
667
776
  }
668
777
  exports.ForEachStatement = ForEachStatement;
669
778
  class WhileStatement extends AstNode_1.Statement {
@@ -698,6 +807,13 @@ class WhileStatement extends AstNode_1.Statement {
698
807
  (0, visitors_1.walk)(this, 'body', visitor, options);
699
808
  }
700
809
  }
810
+ clone() {
811
+ var _a, _b;
812
+ return this.finalizeClone(new WhileStatement({
813
+ while: util_1.util.cloneToken(this.tokens.while),
814
+ endWhile: util_1.util.cloneToken(this.tokens.endWhile)
815
+ }, (_a = this.condition) === null || _a === void 0 ? void 0 : _a.clone(), (_b = this.body) === null || _b === void 0 ? void 0 : _b.clone()), ['condition', 'body']);
816
+ }
701
817
  }
702
818
  exports.WhileStatement = WhileStatement;
703
819
  class DottedSetStatement extends AstNode_1.Statement {
@@ -734,6 +850,10 @@ class DottedSetStatement extends AstNode_1.Statement {
734
850
  (0, visitors_1.walk)(this, 'value', visitor, options);
735
851
  }
736
852
  }
853
+ clone() {
854
+ var _a, _b;
855
+ return this.finalizeClone(new DottedSetStatement((_a = this.obj) === null || _a === void 0 ? void 0 : _a.clone(), util_1.util.cloneToken(this.name), (_b = this.value) === null || _b === void 0 ? void 0 : _b.clone(), util_1.util.cloneToken(this.dot)), ['obj', 'value']);
856
+ }
737
857
  }
738
858
  exports.DottedSetStatement = DottedSetStatement;
739
859
  class IndexedSetStatement extends AstNode_1.Statement {
@@ -783,13 +903,18 @@ class IndexedSetStatement extends AstNode_1.Statement {
783
903
  (0, visitors_1.walk)(this, 'value', visitor, options);
784
904
  }
785
905
  }
906
+ clone() {
907
+ var _a, _b, _c, _d;
908
+ return this.finalizeClone(new IndexedSetStatement((_a = this.obj) === null || _a === void 0 ? void 0 : _a.clone(), (_b = this.index) === null || _b === void 0 ? void 0 : _b.clone(), (_c = this.value) === null || _c === void 0 ? void 0 : _c.clone(), util_1.util.cloneToken(this.openingSquare), util_1.util.cloneToken(this.closingSquare), (_d = this.additionalIndexes) === null || _d === void 0 ? void 0 : _d.map(e => e === null || e === void 0 ? void 0 : e.clone())), ['obj', 'index', 'value', 'additionalIndexes']);
909
+ }
786
910
  }
787
911
  exports.IndexedSetStatement = IndexedSetStatement;
788
912
  class LibraryStatement extends AstNode_1.Statement {
789
913
  constructor(tokens) {
914
+ var _a, _b;
790
915
  super();
791
916
  this.tokens = tokens;
792
- this.range = util_1.util.createBoundingRange(this.tokens.library, this.tokens.filePath);
917
+ this.range = util_1.util.createBoundingRange((_a = this.tokens) === null || _a === void 0 ? void 0 : _a.library, (_b = this.tokens) === null || _b === void 0 ? void 0 : _b.filePath);
793
918
  }
794
919
  transpile(state) {
795
920
  let result = [];
@@ -806,6 +931,13 @@ class LibraryStatement extends AstNode_1.Statement {
806
931
  walk(visitor, options) {
807
932
  //nothing to walk
808
933
  }
934
+ clone() {
935
+ var _a, _b;
936
+ return this.finalizeClone(new LibraryStatement(this.tokens === undefined ? undefined : {
937
+ library: util_1.util.cloneToken((_a = this.tokens) === null || _a === void 0 ? void 0 : _a.library),
938
+ filePath: util_1.util.cloneToken((_b = this.tokens) === null || _b === void 0 ? void 0 : _b.filePath)
939
+ }));
940
+ }
809
941
  }
810
942
  exports.LibraryStatement = LibraryStatement;
811
943
  class NamespaceStatement extends AstNode_1.Statement {
@@ -817,9 +949,14 @@ class NamespaceStatement extends AstNode_1.Statement {
817
949
  this.nameExpression = nameExpression;
818
950
  this.body = body;
819
951
  this.endKeyword = endKeyword;
820
- this.name = this.getName(Parser_1.ParseMode.BrighterScript);
821
952
  this.symbolTable = new SymbolTable_1.SymbolTable(`NamespaceStatement: '${this.name}'`, () => { var _a; return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable(); });
822
953
  }
954
+ /**
955
+ * The string name for this namespace
956
+ */
957
+ get name() {
958
+ return this.getName(Parser_1.ParseMode.BrighterScript);
959
+ }
823
960
  get range() {
824
961
  return this.cacheRange();
825
962
  }
@@ -830,8 +967,12 @@ class NamespaceStatement extends AstNode_1.Statement {
830
967
  return this._range;
831
968
  }
832
969
  getName(parseMode) {
970
+ var _a, _b;
833
971
  const parentNamespace = this.findAncestor(reflection_1.isNamespaceStatement);
834
- let name = this.nameExpression.getName(parseMode);
972
+ let name = (_b = (_a = this.nameExpression) === null || _a === void 0 ? void 0 : _a.getName) === null || _b === void 0 ? void 0 : _b.call(_a, parseMode);
973
+ if (!name) {
974
+ return name;
975
+ }
835
976
  if (parentNamespace) {
836
977
  const sep = parseMode === Parser_1.ParseMode.BrighterScript ? '.' : '_';
837
978
  name = parentNamespace.getName(parseMode) + sep + name;
@@ -862,6 +1003,12 @@ class NamespaceStatement extends AstNode_1.Statement {
862
1003
  (0, visitors_1.walk)(this, 'body', visitor, options);
863
1004
  }
864
1005
  }
1006
+ clone() {
1007
+ var _a, _b;
1008
+ const clone = this.finalizeClone(new NamespaceStatement(util_1.util.cloneToken(this.keyword), (_a = this.nameExpression) === null || _a === void 0 ? void 0 : _a.clone(), (_b = this.body) === null || _b === void 0 ? void 0 : _b.clone(), util_1.util.cloneToken(this.endKeyword)), ['nameExpression', 'body']);
1009
+ clone.cacheRange();
1010
+ return clone;
1011
+ }
865
1012
  }
866
1013
  exports.NamespaceStatement = NamespaceStatement;
867
1014
  class ImportStatement extends AstNode_1.Statement {
@@ -903,10 +1050,14 @@ class ImportStatement extends AstNode_1.Statement {
903
1050
  walk(visitor, options) {
904
1051
  //nothing to walk
905
1052
  }
1053
+ clone() {
1054
+ return this.finalizeClone(new ImportStatement(util_1.util.cloneToken(this.importToken), util_1.util.cloneToken(this.filePathToken)));
1055
+ }
906
1056
  }
907
1057
  exports.ImportStatement = ImportStatement;
908
1058
  class InterfaceStatement extends AstNode_1.Statement {
909
1059
  constructor(interfaceToken, name, extendsToken, parentInterfaceName, body, endInterfaceToken) {
1060
+ var _a;
910
1061
  super();
911
1062
  this.parentInterfaceName = parentInterfaceName;
912
1063
  this.body = body;
@@ -915,7 +1066,7 @@ class InterfaceStatement extends AstNode_1.Statement {
915
1066
  this.tokens.name = name;
916
1067
  this.tokens.extends = extendsToken;
917
1068
  this.tokens.endInterface = endInterfaceToken;
918
- this.range = util_1.util.createBoundingRange(this.tokens.interface, this.tokens.name, this.tokens.extends, this.parentInterfaceName, ...this.body, this.tokens.endInterface);
1069
+ this.range = util_1.util.createBoundingRange(this.tokens.interface, this.tokens.name, this.tokens.extends, this.parentInterfaceName, ...(_a = this.body) !== null && _a !== void 0 ? _a : [], this.tokens.endInterface);
919
1070
  }
920
1071
  /**
921
1072
  * Get the name of the wrapping namespace (if it exists)
@@ -1013,6 +1164,10 @@ class InterfaceStatement extends AstNode_1.Statement {
1013
1164
  (0, visitors_1.walkArray)(this.body, visitor, options, this);
1014
1165
  }
1015
1166
  }
1167
+ clone() {
1168
+ var _a, _b;
1169
+ return this.finalizeClone(new InterfaceStatement(util_1.util.cloneToken(this.tokens.interface), util_1.util.cloneToken(this.tokens.name), util_1.util.cloneToken(this.tokens.extends), (_a = this.parentInterfaceName) === null || _a === void 0 ? void 0 : _a.clone(), (_b = this.body) === null || _b === void 0 ? void 0 : _b.map(x => x === null || x === void 0 ? void 0 : x.clone()), util_1.util.cloneToken(this.tokens.endInterface)), ['parentInterfaceName', 'body']);
1170
+ }
1016
1171
  }
1017
1172
  exports.InterfaceStatement = InterfaceStatement;
1018
1173
  class InterfaceFieldStatement extends AstNode_1.Statement {
@@ -1053,6 +1208,10 @@ class InterfaceFieldStatement extends AstNode_1.Statement {
1053
1208
  }
1054
1209
  return result;
1055
1210
  }
1211
+ clone() {
1212
+ var _a;
1213
+ return this.finalizeClone(new InterfaceFieldStatement(util_1.util.cloneToken(this.tokens.name), util_1.util.cloneToken(this.tokens.as), util_1.util.cloneToken(this.tokens.type), (_a = this.type) === null || _a === void 0 ? void 0 : _a.clone(), util_1.util.cloneToken(this.tokens.optional)));
1214
+ }
1056
1215
  }
1057
1216
  exports.InterfaceFieldStatement = InterfaceFieldStatement;
1058
1217
  class InterfaceMethodStatement extends AstNode_1.Statement {
@@ -1111,6 +1270,10 @@ class InterfaceMethodStatement extends AstNode_1.Statement {
1111
1270
  }
1112
1271
  return result;
1113
1272
  }
1273
+ clone() {
1274
+ var _a, _b;
1275
+ return this.finalizeClone(new InterfaceMethodStatement(util_1.util.cloneToken(this.tokens.functionType), util_1.util.cloneToken(this.tokens.name), util_1.util.cloneToken(this.tokens.leftParen), (_a = this.params) === null || _a === void 0 ? void 0 : _a.map(p => p === null || p === void 0 ? void 0 : p.clone()), util_1.util.cloneToken(this.tokens.rightParen), util_1.util.cloneToken(this.tokens.as), util_1.util.cloneToken(this.tokens.returnType), (_b = this.returnType) === null || _b === void 0 ? void 0 : _b.clone(), util_1.util.cloneToken(this.tokens.optional)), ['params']);
1276
+ }
1114
1277
  }
1115
1278
  exports.InterfaceMethodStatement = InterfaceMethodStatement;
1116
1279
  class ClassStatement extends AstNode_1.Statement {
@@ -1407,6 +1570,10 @@ class ClassStatement extends AstNode_1.Statement {
1407
1570
  (0, visitors_1.walkArray)(this.body, visitor, options, this);
1408
1571
  }
1409
1572
  }
1573
+ clone() {
1574
+ var _a, _b;
1575
+ return this.finalizeClone(new ClassStatement(util_1.util.cloneToken(this.classKeyword), util_1.util.cloneToken(this.name), (_a = this.body) === null || _a === void 0 ? void 0 : _a.map(x => x === null || x === void 0 ? void 0 : x.clone()), util_1.util.cloneToken(this.end), util_1.util.cloneToken(this.extendsKeyword), (_b = this.parentClassName) === null || _b === void 0 ? void 0 : _b.clone()), ['body', 'parentClassName']);
1576
+ }
1410
1577
  }
1411
1578
  exports.ClassStatement = ClassStatement;
1412
1579
  const accessModifiers = [
@@ -1553,6 +1720,10 @@ class MethodStatement extends FunctionStatement {
1553
1720
  (0, visitors_1.walk)(this, 'func', visitor, options);
1554
1721
  }
1555
1722
  }
1723
+ clone() {
1724
+ var _a, _b;
1725
+ return this.finalizeClone(new MethodStatement((_a = this.modifiers) === null || _a === void 0 ? void 0 : _a.map(m => util_1.util.cloneToken(m)), util_1.util.cloneToken(this.name), (_b = this.func) === null || _b === void 0 ? void 0 : _b.clone(), util_1.util.cloneToken(this.override)), ['func']);
1726
+ }
1556
1727
  }
1557
1728
  exports.MethodStatement = MethodStatement;
1558
1729
  /**
@@ -1618,6 +1789,10 @@ class FieldStatement extends AstNode_1.Statement {
1618
1789
  (0, visitors_1.walk)(this, 'initialValue', visitor, options);
1619
1790
  }
1620
1791
  }
1792
+ clone() {
1793
+ var _a;
1794
+ return this.finalizeClone(new FieldStatement(util_1.util.cloneToken(this.accessModifier), util_1.util.cloneToken(this.name), util_1.util.cloneToken(this.as), util_1.util.cloneToken(this.type), util_1.util.cloneToken(this.equal), (_a = this.initialValue) === null || _a === void 0 ? void 0 : _a.clone(), util_1.util.cloneToken(this.optional)), ['initialValue']);
1795
+ }
1621
1796
  }
1622
1797
  exports.FieldStatement = FieldStatement;
1623
1798
  /**
@@ -1653,6 +1828,13 @@ class TryCatchStatement extends AstNode_1.Statement {
1653
1828
  (0, visitors_1.walk)(this, 'catchStatement', visitor, options);
1654
1829
  }
1655
1830
  }
1831
+ clone() {
1832
+ var _a, _b;
1833
+ return this.finalizeClone(new TryCatchStatement({
1834
+ try: util_1.util.cloneToken(this.tokens.try),
1835
+ endTry: util_1.util.cloneToken(this.tokens.endTry)
1836
+ }, (_a = this.tryBranch) === null || _a === void 0 ? void 0 : _a.clone(), (_b = this.catchStatement) === null || _b === void 0 ? void 0 : _b.clone()), ['tryBranch', 'catchStatement']);
1837
+ }
1656
1838
  }
1657
1839
  exports.TryCatchStatement = TryCatchStatement;
1658
1840
  class CatchStatement extends AstNode_1.Statement {
@@ -1677,6 +1859,12 @@ class CatchStatement extends AstNode_1.Statement {
1677
1859
  (0, visitors_1.walk)(this, 'catchBranch', visitor, options);
1678
1860
  }
1679
1861
  }
1862
+ clone() {
1863
+ var _a;
1864
+ return this.finalizeClone(new CatchStatement({
1865
+ catch: util_1.util.cloneToken(this.tokens.catch)
1866
+ }, util_1.util.cloneToken(this.exceptionVariable), (_a = this.catchBranch) === null || _a === void 0 ? void 0 : _a.clone()), ['catchBranch']);
1867
+ }
1680
1868
  }
1681
1869
  exports.CatchStatement = CatchStatement;
1682
1870
  class ThrowStatement extends AstNode_1.Statement {
@@ -1706,6 +1894,10 @@ class ThrowStatement extends AstNode_1.Statement {
1706
1894
  (0, visitors_1.walk)(this, 'expression', visitor, options);
1707
1895
  }
1708
1896
  }
1897
+ clone() {
1898
+ var _a;
1899
+ return this.finalizeClone(new ThrowStatement(util_1.util.cloneToken(this.throwToken), (_a = this.expression) === null || _a === void 0 ? void 0 : _a.clone()), ['expression']);
1900
+ }
1709
1901
  }
1710
1902
  exports.ThrowStatement = ThrowStatement;
1711
1903
  class EnumStatement extends AstNode_1.Statement {
@@ -1830,6 +2022,14 @@ class EnumStatement extends AstNode_1.Statement {
1830
2022
  (0, visitors_1.walkArray)(this.body, visitor, options, this);
1831
2023
  }
1832
2024
  }
2025
+ clone() {
2026
+ var _a;
2027
+ return this.finalizeClone(new EnumStatement({
2028
+ enum: util_1.util.cloneToken(this.tokens.enum),
2029
+ name: util_1.util.cloneToken(this.tokens.name),
2030
+ endEnum: util_1.util.cloneToken(this.tokens.endEnum)
2031
+ }, (_a = this.body) === null || _a === void 0 ? void 0 : _a.map(x => x === null || x === void 0 ? void 0 : x.clone())), ['body']);
2032
+ }
1833
2033
  }
1834
2034
  exports.EnumStatement = EnumStatement;
1835
2035
  class EnumMemberStatement extends AstNode_1.Statement {
@@ -1873,6 +2073,13 @@ class EnumMemberStatement extends AstNode_1.Statement {
1873
2073
  (0, visitors_1.walk)(this, 'value', visitor, options);
1874
2074
  }
1875
2075
  }
2076
+ clone() {
2077
+ var _a;
2078
+ return this.finalizeClone(new EnumMemberStatement({
2079
+ name: util_1.util.cloneToken(this.tokens.name),
2080
+ equal: util_1.util.cloneToken(this.tokens.equal)
2081
+ }, (_a = this.value) === null || _a === void 0 ? void 0 : _a.clone()), ['value']);
2082
+ }
1876
2083
  }
1877
2084
  exports.EnumMemberStatement = EnumMemberStatement;
1878
2085
  class ConstStatement extends AstNode_1.Statement {
@@ -1926,6 +2133,14 @@ class ConstStatement extends AstNode_1.Statement {
1926
2133
  (0, visitors_1.walk)(this, 'value', visitor, options);
1927
2134
  }
1928
2135
  }
2136
+ clone() {
2137
+ var _a;
2138
+ return this.finalizeClone(new ConstStatement({
2139
+ const: util_1.util.cloneToken(this.tokens.const),
2140
+ name: util_1.util.cloneToken(this.tokens.name),
2141
+ equals: util_1.util.cloneToken(this.tokens.equals)
2142
+ }, (_a = this.value) === null || _a === void 0 ? void 0 : _a.clone()), ['value']);
2143
+ }
1929
2144
  }
1930
2145
  exports.ConstStatement = ConstStatement;
1931
2146
  class ContinueStatement extends AstNode_1.Statement {
@@ -1945,6 +2160,12 @@ class ContinueStatement extends AstNode_1.Statement {
1945
2160
  walk(visitor, options) {
1946
2161
  //nothing to walk
1947
2162
  }
2163
+ clone() {
2164
+ return this.finalizeClone(new ContinueStatement({
2165
+ continue: util_1.util.cloneToken(this.tokens.continue),
2166
+ loopType: util_1.util.cloneToken(this.tokens.loopType)
2167
+ }));
2168
+ }
1948
2169
  }
1949
2170
  exports.ContinueStatement = ContinueStatement;
1950
2171
  //# sourceMappingURL=Statement.js.map