@openrewrite/rewrite 0.24.0 → 0.25.0

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 (63) hide show
  1. package/LICENSE.md +87 -0
  2. package/dist/src/core/parser.js +17 -7
  3. package/dist/src/core/parser.js.map +1 -1
  4. package/dist/src/core/tree.d.ts +1 -1
  5. package/dist/src/core/tree.d.ts.map +1 -1
  6. package/dist/src/java/markers.d.ts +2 -2
  7. package/dist/src/java/markers.d.ts.map +1 -1
  8. package/dist/src/java/remote/receiver.js +17 -7
  9. package/dist/src/java/remote/receiver.js.map +1 -1
  10. package/dist/src/java/remote/sender.js +17 -7
  11. package/dist/src/java/remote/sender.js.map +1 -1
  12. package/dist/src/java/tree/support_types.d.ts +1 -1
  13. package/dist/src/java/tree/support_types.d.ts.map +1 -1
  14. package/dist/src/java/tree/tree.d.ts +70 -70
  15. package/dist/src/java/tree/tree.d.ts.map +1 -1
  16. package/dist/src/java/tree/tree.js +17 -7
  17. package/dist/src/java/tree/tree.js.map +1 -1
  18. package/dist/src/java/visitor.js +17 -7
  19. package/dist/src/java/visitor.js.map +1 -1
  20. package/dist/src/javascript/extensions.js +17 -7
  21. package/dist/src/javascript/extensions.js.map +1 -1
  22. package/dist/src/javascript/parser.d.ts +5 -3
  23. package/dist/src/javascript/parser.d.ts.map +1 -1
  24. package/dist/src/javascript/parser.js +67 -21
  25. package/dist/src/javascript/parser.js.map +1 -1
  26. package/dist/src/javascript/parserUtils.d.ts +1 -1
  27. package/dist/src/javascript/parserUtils.js +17 -7
  28. package/dist/src/javascript/parserUtils.js.map +1 -1
  29. package/dist/src/javascript/projectParser.js +17 -7
  30. package/dist/src/javascript/projectParser.js.map +1 -1
  31. package/dist/src/javascript/remote/receiver.d.ts.map +1 -1
  32. package/dist/src/javascript/remote/receiver.js +71 -14
  33. package/dist/src/javascript/remote/receiver.js.map +1 -1
  34. package/dist/src/javascript/remote/remote_extensions.js +17 -7
  35. package/dist/src/javascript/remote/remote_extensions.js.map +1 -1
  36. package/dist/src/javascript/remote/sender.d.ts.map +1 -1
  37. package/dist/src/javascript/remote/sender.js +56 -11
  38. package/dist/src/javascript/remote/sender.js.map +1 -1
  39. package/dist/src/javascript/tree/extensions.js +17 -7
  40. package/dist/src/javascript/tree/extensions.js.map +1 -1
  41. package/dist/src/javascript/tree/support_types.d.ts +21 -7
  42. package/dist/src/javascript/tree/support_types.d.ts.map +1 -1
  43. package/dist/src/javascript/tree/support_types.js +31 -7
  44. package/dist/src/javascript/tree/support_types.js.map +1 -1
  45. package/dist/src/javascript/tree/tree.d.ts +288 -77
  46. package/dist/src/javascript/tree/tree.d.ts.map +1 -1
  47. package/dist/src/javascript/tree/tree.js +348 -44
  48. package/dist/src/javascript/tree/tree.js.map +1 -1
  49. package/dist/src/javascript/typeMapping.js +17 -7
  50. package/dist/src/javascript/typeMapping.js.map +1 -1
  51. package/dist/src/javascript/visitor.d.ts +5 -1
  52. package/dist/src/javascript/visitor.d.ts.map +1 -1
  53. package/dist/src/javascript/visitor.js +71 -10
  54. package/dist/src/javascript/visitor.js.map +1 -1
  55. package/dist/src/json/tree.d.ts +1 -1
  56. package/dist/src/json/tree.d.ts.map +1 -1
  57. package/dist/src/json/visitor.js +17 -7
  58. package/dist/src/json/visitor.js.map +1 -1
  59. package/dist/src/yaml/tree/support_types.d.ts +1 -1
  60. package/dist/src/yaml/tree/support_types.d.ts.map +1 -1
  61. package/dist/src/yaml/tree/tree.d.ts +11 -11
  62. package/package.json +1 -1
  63. package/LICENSE +0 -201
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -306,7 +316,8 @@ class JavaScriptParserVisitor {
306
316
  }
307
317
  for (let heritageClause of node.heritageClauses) {
308
318
  if (heritageClause.token == ts.SyntaxKind.ExtendsKeyword) {
309
- return this.leftPadded(this.prefix(heritageClause.getFirstToken()), this.visit(heritageClause.types[0]));
319
+ const expression = this.visit(heritageClause.types[0]);
320
+ return this.leftPadded(this.prefix(heritageClause.getFirstToken()), new _1.TypeTreeExpression((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, expression));
310
321
  }
311
322
  }
312
323
  return null;
@@ -380,6 +391,12 @@ class JavaScriptParserVisitor {
380
391
  visitNeverKeyword(node) {
381
392
  return this.mapIdentifier(node, 'never');
382
393
  }
394
+ visitSymbolKeyword(node) {
395
+ return this.mapIdentifier(node, 'symbol');
396
+ }
397
+ visitBigIntKeyword(node) {
398
+ return this.mapIdentifier(node, 'bigint');
399
+ }
383
400
  mapLiteral(node, value) {
384
401
  return new J.Literal((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, value, node.getText(), null, this.mapPrimitiveType(node));
385
402
  }
@@ -470,12 +487,21 @@ class JavaScriptParserVisitor {
470
487
  if (node.questionToken) {
471
488
  return new JS.JSVariableDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), this.mapTypeInfo(node), null, [this.rightPadded(new JS.JSVariableDeclarations.JSNamedVariable((0, core_1.randomId)(), this.prefix(node.name), core_1.Markers.EMPTY, this.getOptionalUnary(node), [], null, this.mapVariableType(node)), java_1.Space.EMPTY)]);
472
489
  }
473
- return new J.VariableDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), this.mapTypeInfo(node), null, [], [this.rightPadded(new J.VariableDeclarations.NamedVariable((0, core_1.randomId)(), this.prefix(node.name), core_1.Markers.EMPTY, this.visit(node.name), [], null, this.mapVariableType(node)), java_1.Space.EMPTY)]);
490
+ const nameExpression = this.visit(node.name);
491
+ if (nameExpression instanceof J.Identifier) {
492
+ return new J.VariableDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), this.mapTypeInfo(node), null, [], [this.rightPadded(new J.VariableDeclarations.NamedVariable((0, core_1.randomId)(), this.prefix(node.name), core_1.Markers.EMPTY, nameExpression, [], null, this.mapVariableType(node)), java_1.Space.EMPTY)]);
493
+ }
494
+ else {
495
+ return new JS.JSVariableDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), this.mapTypeInfo(node), null, [this.rightPadded(new JS.JSVariableDeclarations.JSNamedVariable((0, core_1.randomId)(), this.prefix(node.name), core_1.Markers.EMPTY, nameExpression, [], null, this.mapVariableType(node)), java_1.Space.EMPTY)]);
496
+ }
474
497
  }
475
498
  visitPropertyDeclaration(node) {
476
499
  if (node.questionToken) {
477
500
  return new JS.JSVariableDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), this.mapTypeInfo(node), null, [this.rightPadded(new JS.JSVariableDeclarations.JSNamedVariable((0, core_1.randomId)(), this.prefix(node.name), core_1.Markers.EMPTY, this.getOptionalUnary(node), [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildren().indexOf(node.initializer) - 1)), this.visit(node.initializer)) : null, this.mapVariableType(node)), java_1.Space.EMPTY)]);
478
501
  }
502
+ if (node.exclamationToken) {
503
+ return new JS.JSVariableDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), this.mapTypeInfo(node), null, [this.rightPadded(new JS.JSVariableDeclarations.JSNamedVariable((0, core_1.randomId)(), this.prefix(node.name), core_1.Markers.EMPTY, new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(this.suffix(node.name), JS.Unary.Type.Exclamation), this.visit(node.name), this.mapType(node)), [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildren().indexOf(node.initializer) - 1)), this.visit(node.initializer)) : null, this.mapVariableType(node)), java_1.Space.EMPTY)]);
504
+ }
479
505
  const nameExpression = this.visit(node.name);
480
506
  if (nameExpression instanceof J.Identifier) {
481
507
  return new J.VariableDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), this.mapTypeInfo(node), null, [], [this.rightPadded(new J.VariableDeclarations.NamedVariable((0, core_1.randomId)(), this.prefix(node.name), core_1.Markers.EMPTY, nameExpression, [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildren().indexOf(node.initializer) - 1)), this.visit(node.initializer)) : null, this.mapVariableType(node)), this.suffix(node.name))]);
@@ -492,8 +518,12 @@ class JavaScriptParserVisitor {
492
518
  return new J.MethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], this.mapTypeParametersAsObject(node), this.mapTypeInfo(node), new J.MethodDeclaration.IdentifierWithAnnotations(node.name ? this.visit(node.name) : this.mapIdentifier(node, ""), []), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, null, null, this.mapMethodType(node));
493
519
  }
494
520
  visitMethodDeclaration(node) {
495
- if (node.questionToken) {
496
- return new JS.JSMethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), this.mapTypeParametersAsObject(node), this.mapTypeInfo(node), this.getOptionalUnary(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
521
+ if (node.questionToken || node.asteriskToken) {
522
+ let methodName = node.questionToken ? this.getOptionalUnary(node) : this.visit(node.name);
523
+ if (node.asteriskToken) {
524
+ methodName = new JS.Unary((0, core_1.randomId)(), this.prefix(node.asteriskToken), core_1.Markers.EMPTY, this.leftPadded(this.prefix(node.name), JS.Unary.Type.Asterisk), methodName, this.mapType(node));
525
+ }
526
+ return new JS.JSMethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), this.mapTypeParametersAsObject(node), this.mapTypeInfo(node), methodName, this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
497
527
  }
498
528
  const name = node.name ? this.visit(node.name) : this.mapIdentifier(node, "");
499
529
  if (!(name instanceof J.Identifier)) {
@@ -600,15 +630,27 @@ class JavaScriptParserVisitor {
600
630
  return JS.TypeOperator.Type.KeyOf;
601
631
  case ts.SyntaxKind.ReadonlyKeyword:
602
632
  return JS.TypeOperator.Type.ReadOnly;
633
+ case ts.SyntaxKind.UniqueKeyword:
634
+ return JS.TypeOperator.Type.Unique;
603
635
  }
604
636
  }
605
637
  return new JS.TypeOperator((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, mapTypeOperator(node.operator), this.leftPadded(this.prefix(node.type), this.visit(node.type)));
606
638
  }
607
639
  visitIndexedAccessType(node) {
608
- return new JS.IndexedAccessType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.objectType), this.rightPadded(new JS.IndexedAccessType.IndexType((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBracketToken)), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.indexType), this.suffix(node.indexType)), this.mapType(node.indexType)), this.suffix(this.findChildNode(node, ts.SyntaxKind.CloseBracketToken))), this.mapType(node));
640
+ return new JS.IndexedAccessType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.objectType), new JS.IndexedAccessType.IndexType((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBracketToken)), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.indexType), this.suffix(node.indexType)), this.mapType(node.indexType)), this.mapType(node));
609
641
  }
610
642
  visitMappedType(node) {
611
- return this.visitUnknown(node);
643
+ function hasPrefixToken(readonlyToken) {
644
+ return !!(readonlyToken && (readonlyToken.kind == ts.SyntaxKind.PlusToken || readonlyToken.kind == ts.SyntaxKind.MinusToken));
645
+ }
646
+ function hasSuffixToken(questionToken) {
647
+ return !!(questionToken && (questionToken.kind == ts.SyntaxKind.PlusToken || questionToken.kind == ts.SyntaxKind.MinusToken));
648
+ }
649
+ return new JS.MappedType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, hasPrefixToken(node.readonlyToken) ? this.leftPadded(this.prefix(node.readonlyToken), new J.Literal((0, core_1.randomId)(), this.prefix(node.readonlyToken), core_1.Markers.EMPTY, null, node.readonlyToken.getText(), null, this.mapPrimitiveType(node.readonlyToken))) : null, node.readonlyToken ? this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.ReadonlyKeyword)), true) : this.leftPadded(java_1.Space.EMPTY, false), new JS.MappedType.KeysRemapping((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBracketToken)), core_1.Markers.EMPTY, this.rightPadded(new JS.MappedType.MappedTypeParameter((0, core_1.randomId)(), this.prefix(node.typeParameter), core_1.Markers.EMPTY, this.visit(node.typeParameter.name), this.leftPadded(this.suffix(node.typeParameter.name), this.visit(node.typeParameter.constraint))), this.suffix(node.typeParameter)), node.nameType ? this.rightPadded(this.visit(node.nameType), this.suffix(node.nameType)) : null), hasSuffixToken(node.questionToken) ? this.leftPadded(this.prefix(node.questionToken), new J.Literal((0, core_1.randomId)(), this.prefix(node.questionToken), core_1.Markers.EMPTY, null, node.questionToken.getText(), null, this.mapPrimitiveType(node.questionToken))) : null, node.questionToken ? this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.QuestionToken)), true) : this.leftPadded(java_1.Space.EMPTY, false), new java_1.JContainer(this.prefix(this.findChildNode(node, ts.SyntaxKind.ColonToken)), [this.rightPadded(this.visit(node.type), this.suffix(node.type)),
650
+ this.findChildNode(node, ts.SyntaxKind.SemicolonToken) ?
651
+ this.rightPadded(this.newJEmpty(java_1.Space.EMPTY, core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())])), this.prefix(node.getLastToken()))
652
+ : this.rightPadded(this.newJEmpty(), this.prefix(node.getLastToken()))
653
+ ], core_1.Markers.EMPTY), this.mapType(node));
612
654
  }
613
655
  visitLiteralType(node) {
614
656
  return new JS.LiteralType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.literal), this.mapType(node));
@@ -690,7 +732,7 @@ class JavaScriptParserVisitor {
690
732
  return this.mapIdentifier(node, node.getText());
691
733
  }
692
734
  visitNewExpression(node) {
693
- return new J.NewClass((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, null, java_1.Space.EMPTY, this.visit(node.expression), this.mapCommaSeparatedList(node.arguments ? node.getChildren(this.sourceFile).slice(2) : []), null, this.mapMethodType(node));
735
+ return new J.NewClass((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, null, java_1.Space.EMPTY, node.typeArguments ? new J.ParameterizedType((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.visit(node.expression), this.mapTypeArguments(this.prefix(this.findChildNode(node, ts.SyntaxKind.LessThanToken)), node.typeArguments), null) : this.visit(node.expression), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, this.mapMethodType(node));
694
736
  }
695
737
  visitTaggedTemplateExpression(node) {
696
738
  return new JS.TaggedTemplateExpression((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.tag), this.suffix(node.tag)), node.typeArguments ? this.mapTypeArguments(java_1.Space.EMPTY, node.typeArguments) : null, this.visit(node.template), this.mapType(node));
@@ -699,7 +741,7 @@ class JavaScriptParserVisitor {
699
741
  return new J.TypeCast((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new J.ControlParentheses((0, core_1.randomId)(), this.prefix(node.getFirstToken()), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.type), this.prefix(node.getChildAt(2, this.sourceFile)))), this.convert(node.expression));
700
742
  }
701
743
  visitParenthesizedExpression(node) {
702
- return new J.ParenthesizedTypeTree((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], new J.Parentheses((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.expression), this.prefix(node.getLastToken()))));
744
+ return new J.Parentheses((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.expression), this.prefix(node.getLastToken())));
703
745
  }
704
746
  visitFunctionExpression(node) {
705
747
  return new JS.FunctionDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.FunctionKeyword)), !!node.asteriskToken), this.leftPadded(node.asteriskToken ? this.prefix(node.asteriskToken) : java_1.Space.EMPTY, node.name ? this.visit(node.name) : new J.Identifier((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], "", null, null)), this.mapTypeParametersAsObject(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), this.mapTypeInfo(node), this.convert(node.body), this.mapMethodType(node));
@@ -710,7 +752,7 @@ class JavaScriptParserVisitor {
710
752
  return new JS.ArrowFunction((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), node.typeParameters ? this.mapTypeParametersAsObject(node) : null, new java_1.Lambda.Parameters((0, core_1.randomId)(), isParenthesized ? this.prefix(openParenToken) : java_1.Space.EMPTY, core_1.Markers.EMPTY, isParenthesized, node.parameters.length > 0 ?
711
753
  node.parameters.map(p => this.rightPadded(this.convert(p), this.suffix(p)))
712
754
  .concat(node.parameters.hasTrailingComma ? this.rightPadded(this.newJEmpty(), this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseParenToken))) : []) :
713
- isParenthesized ? [this.rightPadded(this.newJEmpty(), this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseParenToken)))] : []), this.mapTypeInfo(node), this.prefix(node.equalsGreaterThanToken), this.convert(node.body), this.mapType(node));
755
+ isParenthesized ? [this.rightPadded(this.newJEmpty(), this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseParenToken)))] : []), this.mapTypeInfo(node), this.leftPadded(this.prefix(node.equalsGreaterThanToken), this.convert(node.body)), this.mapType(node));
714
756
  }
715
757
  visitDeleteExpression(node) {
716
758
  return new JS.Delete((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.expression), this.mapType(node));
@@ -806,6 +848,9 @@ class JavaScriptParserVisitor {
806
848
  case ts.SyntaxKind.BarBarEqualsToken:
807
849
  assignmentOperation = JS.JsAssignmentOperation.Type.Or;
808
850
  break;
851
+ case ts.SyntaxKind.AsteriskAsteriskToken:
852
+ assignmentOperation = JS.JsAssignmentOperation.Type.Power;
853
+ break;
809
854
  }
810
855
  if (assignmentOperation !== undefined) {
811
856
  return new JS.JsAssignmentOperation((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.left), this.leftPadded(this.prefix(node.operatorToken), assignmentOperation), this.convert(node.right), this.mapType(node));
@@ -895,7 +940,7 @@ class JavaScriptParserVisitor {
895
940
  return new JS.TemplateExpression((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.head), node.templateSpans.map(s => this.rightPadded(this.visit(s), this.suffix(s))), this.mapType(node));
896
941
  }
897
942
  visitYieldExpression(node) {
898
- return new JS.Yield((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, false, node.expression ? this.visit(node.expression) : null, this.mapType(node));
943
+ return new JS.Yield((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.asteriskToken ? this.leftPadded(this.prefix(node.asteriskToken), true) : this.leftPadded(java_1.Space.EMPTY, false), node.expression ? this.visit(node.expression) : null, this.mapType(node));
899
944
  }
900
945
  visitSpreadElement(node) {
901
946
  return new JS.Unary((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.leftPadded(java_1.Space.EMPTY, JS.Unary.Type.Spread), this.convert(node.expression), this.mapType(node));
@@ -955,9 +1000,10 @@ class JavaScriptParserVisitor {
955
1000
  return new JS.ExpressionStatement((0, core_1.randomId)(), expression);
956
1001
  }
957
1002
  visitIfStatement(node) {
958
- var _a;
1003
+ var _a, _b, _c;
959
1004
  const semicolonAfterThen = ((_a = node.thenStatement.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) == ts.SyntaxKind.SemicolonToken;
960
- return new J.If((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new J.ControlParentheses((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.expression), this.suffix(node.expression))), this.rightPadded(this.convert(node.thenStatement), semicolonAfterThen ? this.prefix(node.thenStatement.getLastToken()) : java_1.Space.EMPTY, semicolonAfterThen ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY), node.elseStatement ? new J.If.Else((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.ElseKeyword)), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.elseStatement), semicolonAfterThen ? this.prefix(node.elseStatement.getLastToken()) : java_1.Space.EMPTY, semicolonAfterThen ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY)) : null);
1005
+ const semicolonAfterElse = ((_c = (_b = node.elseStatement) === null || _b === void 0 ? void 0 : _b.getLastToken()) === null || _c === void 0 ? void 0 : _c.kind) == ts.SyntaxKind.SemicolonToken;
1006
+ return new J.If((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new J.ControlParentheses((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.expression), this.suffix(node.expression))), this.rightPadded(this.convert(node.thenStatement), semicolonAfterThen ? this.prefix(node.thenStatement.getLastToken()) : java_1.Space.EMPTY, semicolonAfterThen ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY), node.elseStatement ? new J.If.Else((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.ElseKeyword)), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.elseStatement), semicolonAfterElse ? this.prefix(node.elseStatement.getLastToken()) : java_1.Space.EMPTY, semicolonAfterElse ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY)) : null);
961
1007
  }
962
1008
  visitDoStatement(node) {
963
1009
  return new J.DoWhileLoop((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.statement), this.suffix(node.statement)), this.leftPadded(java_1.Space.EMPTY, new J.ControlParentheses((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.expression), this.suffix(node.expression)))));
@@ -1008,7 +1054,7 @@ class JavaScriptParserVisitor {
1008
1054
  return new J.Try((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, null, this.visit(node.tryBlock), node.catchClause ? [this.visit(node.catchClause)] : [], node.finallyBlock ? this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.FinallyKeyword)), this.visit(node.finallyBlock)) : null);
1009
1055
  }
1010
1056
  visitDebuggerStatement(node) {
1011
- return this.visitUnknown(node);
1057
+ return new _1.ExpressionStatement((0, core_1.randomId)(), this.mapIdentifier(node, 'debugger'));
1012
1058
  }
1013
1059
  visitVariableDeclaration(node) {
1014
1060
  const nameExpression = this.visit(node.name);
@@ -1031,7 +1077,7 @@ class JavaScriptParserVisitor {
1031
1077
  }));
1032
1078
  }
1033
1079
  visitFunctionDeclaration(node) {
1034
- return new JS.FunctionDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.FunctionKeyword)), !!node.asteriskToken), this.leftPadded(node.asteriskToken ? this.prefix(node.asteriskToken) : java_1.Space.EMPTY, node.name ? this.visit(node.name) : new J.Identifier((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], "", null, null)), this.mapTypeParametersAsObject(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), this.mapTypeInfo(node), this.convert(node.body), this.mapMethodType(node));
1080
+ return new JS.FunctionDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.FunctionKeyword)), !!node.asteriskToken), this.leftPadded(node.asteriskToken ? this.prefix(node.asteriskToken) : java_1.Space.EMPTY, node.name ? this.visit(node.name) : new J.Identifier((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], "", null, null)), this.mapTypeParametersAsObject(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), this.mapTypeInfo(node), node.body ? this.convert(node.body) : null, this.mapMethodType(node));
1035
1081
  }
1036
1082
  getParameterListNodes(node, openToken = ts.SyntaxKind.OpenParenToken) {
1037
1083
  const children = node.getChildren(this.sourceFile);