@openrewrite/rewrite 0.21.0 → 0.22.1

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.
@@ -228,10 +228,16 @@ class JavaScriptParserVisitor {
228
228
  ]), node.getFullText()));
229
229
  }
230
230
  mapModifiers(node) {
231
- var _a, _b, _c;
232
- if (ts.isVariableStatement(node) || ts.isModuleDeclaration(node) || ts.isClassDeclaration(node) || ts.isEnumDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isFunctionDeclaration(node) || ts.isParameter(node) || ts.isMethodDeclaration(node) || ts.isConstructorDeclaration(node)) {
231
+ var _a, _b, _c, _d;
232
+ if (ts.isVariableStatement(node) || ts.isModuleDeclaration(node) || ts.isClassDeclaration(node) || ts.isEnumDeclaration(node)
233
+ || ts.isInterfaceDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)
234
+ || ts.isMethodDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isArrowFunction(node) || ts.isIndexSignatureDeclaration(node)) {
233
235
  return node.modifiers ? (_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.filter(ts.isModifier).map(this.mapModifier) : [];
234
236
  }
237
+ else if (ts.isFunctionDeclaration(node)) {
238
+ return [...node.modifiers ? (_b = node.modifiers) === null || _b === void 0 ? void 0 : _b.filter(ts.isModifier).map(this.mapModifier) : [],
239
+ new J.Modifier((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.FunctionKeyword)), core_1.Markers.EMPTY, null, J.Modifier.Type.LanguageExtension, [])];
240
+ }
235
241
  else if (ts.isVariableDeclarationList(node)) {
236
242
  let modifier;
237
243
  if ((node.flags & ts.NodeFlags.Let) !== 0) {
@@ -246,10 +252,10 @@ class JavaScriptParserVisitor {
246
252
  return modifier ? [new J.Modifier((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, "let", J.Modifier.Type.LanguageExtension, [])] : [];
247
253
  }
248
254
  else if (ts.isGetAccessorDeclaration(node)) {
249
- return (node.modifiers ? (_b = node.modifiers) === null || _b === void 0 ? void 0 : _b.filter(ts.isModifier).map(this.mapModifier) : []).concat(new J.Modifier((0, core_1.randomId)(), this.prefix(node.getChildren().find(c => c.getText() === 'get')), core_1.Markers.EMPTY, 'get', J.Modifier.Type.LanguageExtension, []));
255
+ return (node.modifiers ? (_c = node.modifiers) === null || _c === void 0 ? void 0 : _c.filter(ts.isModifier).map(this.mapModifier) : []).concat(new J.Modifier((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.GetKeyword)), core_1.Markers.EMPTY, 'get', J.Modifier.Type.LanguageExtension, []));
250
256
  }
251
257
  else if (ts.isSetAccessorDeclaration(node)) {
252
- return (node.modifiers ? (_c = node.modifiers) === null || _c === void 0 ? void 0 : _c.filter(ts.isModifier).map(this.mapModifier) : []).concat(new J.Modifier((0, core_1.randomId)(), this.prefix(node.getChildren().find(c => c.getText() === 'set')), core_1.Markers.EMPTY, 'set', J.Modifier.Type.LanguageExtension, []));
258
+ return (node.modifiers ? (_d = node.modifiers) === null || _d === void 0 ? void 0 : _d.filter(ts.isModifier).map(this.mapModifier) : []).concat(new J.Modifier((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.SetKeyword)), core_1.Markers.EMPTY, 'set', J.Modifier.Type.LanguageExtension, []));
253
259
  }
254
260
  throw new Error(`Cannot get modifiers from ${node}`);
255
261
  }
@@ -279,7 +285,7 @@ class JavaScriptParserVisitor {
279
285
  return nodes.map(n => this.leftPadded(before(n), this.convert(n), markers === null || markers === void 0 ? void 0 : markers(n)));
280
286
  }
281
287
  visitClassDeclaration(node) {
282
- return new J.ClassDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), new J.ClassDeclaration.Kind((0, core_1.randomId)(), node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node), core_1.Markers.EMPTY, [], J.ClassDeclaration.Kind.Type.Class), node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), this.mapTypeParametersAsJContainer(node), null, this.mapExtends(node), this.mapImplements(node), null, new J.Block((0, core_1.randomId)(), this.prefix(node.getChildren().find(v => v.kind === ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, new java_1.JRightPadded(false, java_1.Space.EMPTY, core_1.Markers.EMPTY), node.members.map((ce) => {
288
+ return new J.ClassDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), new J.ClassDeclaration.Kind((0, core_1.randomId)(), node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node), core_1.Markers.EMPTY, [], J.ClassDeclaration.Kind.Type.Class), node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), this.mapTypeParametersAsJContainer(node), null, this.mapExtends(node), this.mapImplements(node), null, new J.Block((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, new java_1.JRightPadded(false, java_1.Space.EMPTY, core_1.Markers.EMPTY), node.members.map((ce) => {
283
289
  var _a, _b;
284
290
  return new java_1.JRightPadded(this.convert(ce), ((_a = ce.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) === ts.SyntaxKind.SemicolonToken ? this.prefix(ce.getLastToken()) : java_1.Space.EMPTY, ((_b = ce.getLastToken()) === null || _b === void 0 ? void 0 : _b.kind) === ts.SyntaxKind.SemicolonToken ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY);
285
291
  }), this.prefix(node.getLastToken())), this.mapType(node));
@@ -346,6 +352,9 @@ class JavaScriptParserVisitor {
346
352
  visitAnyKeyword(node) {
347
353
  return this.mapIdentifier(node, 'any');
348
354
  }
355
+ visitObjectKeyword(node) {
356
+ return this.mapIdentifier(node, 'object');
357
+ }
349
358
  visitUnknownKeyword(node) {
350
359
  return this.mapIdentifier(node, 'unknown');
351
360
  }
@@ -402,29 +411,30 @@ class JavaScriptParserVisitor {
402
411
  return this.mapIdentifier(node, node.text);
403
412
  }
404
413
  visitQualifiedName(node) {
405
- const fieldAccess = new J.FieldAccess((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.left), new java_1.JLeftPadded(this.suffix(node.left), this.convert(node.right), core_1.Markers.EMPTY), this.mapType(node));
406
- const parent = node.parent;
407
- if (parent.typeArguments) {
408
- return new J.ParameterizedType((0, core_1.randomId)(), this.prefix(parent), core_1.Markers.EMPTY, fieldAccess, this.mapTypeArguments(this.suffix(parent.typeName), parent.typeArguments), this.mapType(parent));
409
- }
410
- else {
411
- return fieldAccess;
412
- }
414
+ return new J.FieldAccess((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.left), this.leftPadded(this.suffix(node.left), this.convert(node.right)), this.mapType(node));
413
415
  }
414
416
  visitComputedPropertyName(node) {
415
417
  return new J.NewArray((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, null, [], new java_1.JContainer(java_1.Space.EMPTY, [this.rightPadded(this.convert(node.expression), this.suffix(node.expression))], core_1.Markers.EMPTY), this.mapType(node));
416
418
  }
417
419
  visitTypeParameter(node) {
418
- if (node.constraint || (node.modifiers && node.modifiers.length) || node.default) {
419
- return this.visitUnknown(node);
420
- }
421
- return new J.TypeParameter((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], this.visit(node.name), null);
420
+ var _a;
421
+ return new J.TypeParameter((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], this.visit(node.name), (node.constraint || node.default) ?
422
+ new java_1.JContainer(this.prefix((_a = this.findChildNode(node, ts.SyntaxKind.ExtendsKeyword)) !== null && _a !== void 0 ? _a : this.findChildNode(node, ts.SyntaxKind.EqualsToken)), [node.constraint ? this.rightPadded(this.visit(node.constraint), this.suffix(node.constraint)) : this.rightPadded(this.newJEmpty(), java_1.Space.EMPTY),
423
+ node.default ? this.rightPadded(this.visit(node.default), this.suffix(node.default)) : this.rightPadded(this.newJEmpty(), java_1.Space.EMPTY)], core_1.Markers.EMPTY)
424
+ : null);
422
425
  }
423
426
  visitParameter(node) {
424
427
  if (node.questionToken) {
425
- 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), [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildCount(this.sourceFile) - 2)), this.visit(node.initializer)) : null, this.mapVariableType(node)), this.suffix(node.name))]);
428
+ 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), [], 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))]);
429
+ }
430
+ if (node.dotDotDotToken) {
431
+ 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)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(java_1.Space.EMPTY, JS.Unary.Type.Spread), 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)), this.suffix(node.name))]);
426
432
  }
427
- 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), [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildCount(this.sourceFile) - 2)), this.visit(node.initializer)) : null, this.mapVariableType(node)), this.suffix(node.name))]);
433
+ const nameExpression = this.visit(node.name);
434
+ if (nameExpression instanceof J.Identifier) {
435
+ 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, [], 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))]);
436
+ }
437
+ 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, [], 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))]);
428
438
  }
429
439
  visitDecorator(node) {
430
440
  let annotationType;
@@ -456,19 +466,27 @@ class JavaScriptParserVisitor {
456
466
  if (node.questionToken) {
457
467
  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), [], 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)]);
458
468
  }
459
- 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), [], 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)]);
469
+ const nameExpression = this.visit(node.name);
470
+ if (nameExpression instanceof J.Identifier) {
471
+ 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, [], 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))]);
472
+ }
473
+ 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.visit(node.name), [], 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)]);
460
474
  }
461
475
  visitMethodSignature(node) {
462
476
  if (node.questionToken) {
463
477
  return new JS.JSMethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], this.mapTypeParametersAsObject(node), this.mapTypeInfo(node), this.getOptionalUnary(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, null, null, this.mapMethodType(node));
464
478
  }
479
+ if (ts.isComputedPropertyName(node.name)) {
480
+ return new JS.JSMethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], this.mapTypeParametersAsObject(node), this.mapTypeInfo(node), this.convert(node.name), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, null, null, this.mapMethodType(node));
481
+ }
465
482
  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));
466
483
  }
467
484
  visitMethodDeclaration(node) {
468
485
  if (node.questionToken) {
469
- return new JS.JSMethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), node.typeParameters
470
- ? new J.TypeParameters((0, core_1.randomId)(), this.suffix(node.name), core_1.Markers.EMPTY, [], node.typeParameters.map(tp => this.rightPadded(this.visit(tp), this.suffix(tp))))
471
- : null, this.mapTypeInfo(node), this.getOptionalUnary(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
486
+ 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));
487
+ }
488
+ if (ts.isComputedPropertyName(node.name)) {
489
+ 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.convert(node.name), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
472
490
  }
473
491
  return new J.MethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), 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, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
474
492
  }
@@ -497,49 +515,52 @@ class JavaScriptParserVisitor {
497
515
  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(new J.Identifier((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], 'new', null, null), []), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, null, null, this.mapMethodType(node));
498
516
  }
499
517
  visitIndexSignature(node) {
500
- return this.visitUnknown(node);
518
+ return new JS.IndexSignatureDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapModifiers(node), this.mapCommaSeparatedList(this.getParameterListNodes(node, ts.SyntaxKind.OpenBracketToken)), this.leftPadded(this.prefix(node.getChildAt(node.getChildren().indexOf(node.type) - 1)), this.convert(node.type)), this.mapType(node));
501
519
  }
502
520
  visitTypePredicate(node) {
503
521
  return this.visitUnknown(node);
504
522
  }
505
523
  visitTypeReference(node) {
506
524
  if (node.typeArguments) {
507
- if (ts.isQualifiedName(node.typeName)) {
508
- return this.visit(node.typeName);
509
- }
510
- return this.visitUnknown(node);
525
+ return new J.ParameterizedType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.typeName), this.mapTypeArguments(this.suffix(node.typeName), node.typeArguments), this.mapType(node));
511
526
  }
512
527
  return this.visit(node.typeName);
513
528
  }
514
529
  visitFunctionType(node) {
515
- return new JS.FunctionType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new java_1.JContainer(this.prefix(node), node.parameters.map(p => this.rightPadded(this.visit(p), this.suffix(p))), core_1.Markers.EMPTY), this.prefix(node.getChildren().find(v => v.kind === ts.SyntaxKind.EqualsGreaterThanToken)), this.convert(node.type), null);
530
+ return new JS.FunctionType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), new java_1.JContainer(this.prefix(node), node.parameters.map(p => this.rightPadded(this.visit(p), this.suffix(p))), core_1.Markers.EMPTY), this.prefix(this.findChildNode(node, ts.SyntaxKind.EqualsGreaterThanToken)), this.convert(node.type), null);
516
531
  }
517
532
  visitConstructorType(node) {
518
- return this.visitUnknown(node);
533
+ return new JS.FunctionType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(true, this.suffix(this.findChildNode(node, ts.SyntaxKind.NewKeyword))), new java_1.JContainer(this.prefix(node), node.parameters.map(p => this.rightPadded(this.visit(p), this.suffix(p))), core_1.Markers.EMPTY), this.prefix(this.findChildNode(node, ts.SyntaxKind.EqualsGreaterThanToken)), this.convert(node.type), null);
519
534
  }
520
535
  visitTypeQuery(node) {
521
- return this.visitUnknown(node);
536
+ return new JS.TypeQuery((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.exprName), this.mapType(node));
522
537
  }
523
538
  visitTypeLiteral(node) {
524
- return this.visitUnknown(node);
539
+ return new JS.TypeLiteral((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new J.Block((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), node.members.map(te => {
540
+ var _a, _b, _c, _d;
541
+ return new java_1.JRightPadded(this.convert(te), (((_a = te.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) === ts.SyntaxKind.SemicolonToken) || (((_b = te.getLastToken()) === null || _b === void 0 ? void 0 : _b.kind) === ts.SyntaxKind.CommaToken) ? this.prefix(te.getLastToken()) : java_1.Space.EMPTY, (((_c = te.getLastToken()) === null || _c === void 0 ? void 0 : _c.kind) === ts.SyntaxKind.SemicolonToken) || (((_d = te.getLastToken()) === null || _d === void 0 ? void 0 : _d.kind) === ts.SyntaxKind.CommaToken) ? core_1.Markers.build([this.convertToken(te.getLastToken())]) : core_1.Markers.EMPTY);
542
+ }), this.prefix(node.getLastToken())), this.mapType(node));
525
543
  }
526
544
  visitArrayType(node) {
527
- return this.visitUnknown(node);
545
+ return new J.ArrayType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.elementType), null, this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBracketToken)), this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseBracketToken))), this.mapType(node));
528
546
  }
529
547
  visitTupleType(node) {
530
- return this.visitUnknown(node);
548
+ return new JS.Tuple((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new java_1.JContainer(java_1.Space.EMPTY, node.elements.length > 0 ?
549
+ node.elements.map(p => this.rightPadded(this.convert(p), this.suffix(p)))
550
+ .concat(node.elements.hasTrailingComma ? this.rightPadded(this.newJEmpty(), this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseBracketToken))) : [])
551
+ : [this.rightPadded(this.newJEmpty(this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseBracketToken))), java_1.Space.EMPTY)], core_1.Markers.EMPTY), this.mapType(node));
531
552
  }
532
553
  visitOptionalType(node) {
533
- return this.visitUnknown(node);
554
+ return new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(this.suffix(node.type), JS.Unary.Type.Optional), this.visit(node.type), this.mapType(node));
534
555
  }
535
556
  visitRestType(node) {
536
- return this.visitUnknown(node);
557
+ 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.type), this.mapType(node));
537
558
  }
538
559
  visitUnionType(node) {
539
560
  return new JS.Union((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPaddedList([...node.types], (n) => this.keywordPrefix(ts.SyntaxKind.BarToken)(n)), this.mapType(node));
540
561
  }
541
562
  visitIntersectionType(node) {
542
- return this.visitUnknown(node);
563
+ return new JS.Intersection((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPaddedList([...node.types], (n) => this.keywordPrefix(ts.SyntaxKind.AmpersandToken)(n)), this.mapType(node));
543
564
  }
544
565
  visitConditionalType(node) {
545
566
  return this.visitUnknown(node);
@@ -554,7 +575,15 @@ class JavaScriptParserVisitor {
554
575
  return this.visitUnknown(node);
555
576
  }
556
577
  visitTypeOperator(node) {
557
- return this.visitUnknown(node);
578
+ function mapTypeOperator(operator) {
579
+ switch (operator) {
580
+ case ts.SyntaxKind.KeyOfKeyword:
581
+ return JS.TypeOperator.Type.KeyOf;
582
+ case ts.SyntaxKind.ReadonlyKeyword:
583
+ return JS.TypeOperator.Type.ReadOnly;
584
+ }
585
+ }
586
+ 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)));
558
587
  }
559
588
  visitIndexedAccessType(node) {
560
589
  return this.visitUnknown(node);
@@ -578,13 +607,13 @@ class JavaScriptParserVisitor {
578
607
  return this.visitUnknown(node);
579
608
  }
580
609
  visitObjectBindingPattern(node) {
581
- return this.visitUnknown(node);
610
+ return new JS.ObjectBindingDeclarations((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], null, this.mapCommaSeparatedList(node.getChildren(this.sourceFile)), null);
582
611
  }
583
612
  visitArrayBindingPattern(node) {
584
- return this.visitUnknown(node);
613
+ return new JS.ArrayBindingPattern((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapCommaSeparatedList(node.getChildren(this.sourceFile)), this.mapType(node));
585
614
  }
586
615
  visitBindingElement(node) {
587
- return this.visitUnknown(node);
616
+ return new JS.BindingElement((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.propertyName ? this.rightPadded(this.convert(node.propertyName), this.suffix(node.propertyName)) : null, node.dotDotDotToken ? new JS.Unary((0, core_1.randomId)(), this.prefix(node.dotDotDotToken), core_1.Markers.EMPTY, this.leftPadded(java_1.Space.EMPTY, JS.Unary.Type.Spread), this.convert(node.name), null) : this.convert(node.name), node.initializer ? this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.EqualsToken)), this.convert(node.initializer)) : null, this.mapVariableType(node));
588
617
  }
589
618
  visitArrayLiteralExpression(node) {
590
619
  return new J.NewArray((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, null, [], this.mapCommaSeparatedList(node.getChildren(this.sourceFile)), this.mapType(node));
@@ -603,21 +632,32 @@ class JavaScriptParserVisitor {
603
632
  new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(this.suffix(node.expression), JS.Unary.Type.QuestionDot), this.visit(node.expression), this.mapType(node)) : this.convert(node.expression), this.leftPadded(this.prefix(node.getChildAt(1, this.sourceFile)), this.convert(node.name)), this.mapType(node));
604
633
  }
605
634
  visitElementAccessExpression(node) {
606
- return this.visitUnknown(node);
635
+ return new J.ArrayAccess((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.questionDotToken ?
636
+ new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(this.suffix(node.expression), JS.Unary.Type.QuestionDotWithDot), this.visit(node.expression), this.mapType(node)) :
637
+ this.convert(node.expression), new J.ArrayDimension((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBracketToken)), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.argumentExpression), this.suffix(node.argumentExpression))), this.mapType(node));
607
638
  }
608
639
  visitCallExpression(node) {
609
640
  const prefix = this.prefix(node);
641
+ const typeArguments = node.typeArguments ? this.mapTypeArguments(this.prefix(this.findChildNode(node, ts.SyntaxKind.LessThanToken)), node.typeArguments) : null;
642
+ if (ts.isParenthesizedExpression(node.expression)) {
643
+ return new JS.JSMethodInvocation((0, core_1.randomId)(), prefix, core_1.Markers.EMPTY, null, typeArguments, this.convert(node.expression), this.mapCommaSeparatedList(node.getChildren(this.sourceFile).slice(-3)), this.mapMethodType(node));
644
+ }
645
+ if (node.questionDotToken) {
646
+ return new JS.JSMethodInvocation((0, core_1.randomId)(), prefix, core_1.Markers.EMPTY, null, typeArguments, new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(this.suffix(node.expression), JS.Unary.Type.QuestionDotWithDot), this.visit(node.expression), this.mapType(node)), this.mapCommaSeparatedList(node.getChildren(this.sourceFile).slice(-3)), this.mapMethodType(node));
647
+ }
610
648
  let select;
611
649
  let name;
612
650
  if (ts.isPropertyAccessExpression(node.expression)) {
613
- select = this.rightPadded(this.convert(node.expression.expression), this.prefix(node.expression.getChildAt(1, this.sourceFile)));
651
+ select = this.rightPadded(node.expression.questionDotToken ?
652
+ new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(this.suffix(node.expression.expression), JS.Unary.Type.QuestionDot), this.visit(node.expression.expression), this.mapType(node)) :
653
+ this.convert(node.expression.expression), this.prefix(node.expression.getChildAt(1, this.sourceFile)));
614
654
  name = this.convert(node.expression.name);
615
655
  }
616
656
  else {
617
657
  select = null;
618
658
  name = this.convert(node.expression);
619
659
  }
620
- return new J.MethodInvocation((0, core_1.randomId)(), prefix, core_1.Markers.EMPTY, select, null, name, this.mapCommaSeparatedList(node.getChildren(this.sourceFile).slice(-3)), this.mapMethodType(node));
660
+ return new J.MethodInvocation((0, core_1.randomId)(), prefix, core_1.Markers.EMPTY, select, typeArguments, name, this.mapCommaSeparatedList(node.getChildren(this.sourceFile).slice(-3)), this.mapMethodType(node));
621
661
  }
622
662
  visitNewExpression(node) {
623
663
  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));
@@ -629,15 +669,16 @@ class JavaScriptParserVisitor {
629
669
  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));
630
670
  }
631
671
  visitParenthesizedExpression(node) {
632
- 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())));
672
+ 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()))));
633
673
  }
634
674
  visitFunctionExpression(node) {
635
- return this.visitUnknown(node);
675
+ return new JS.FunctionDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], node.name ? this.visit(node.name) : null, this.mapTypeParametersAsObject(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), this.mapTypeInfo(node), this.convert(node.body), this.mapMethodType(node));
636
676
  }
637
677
  visitArrowFunction(node) {
638
- return new JS.ArrowFunction((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], new java_1.Lambda.Parameters((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, true, node.parameters.length > 0 ?
639
- node.parameters.map(p => this.rightPadded(this.convert(p), this.suffix(p))) :
640
- [this.rightPadded(this.newJEmpty(), this.prefix(node.getChildren().find(n => n.kind === ts.SyntaxKind.CloseParenToken)))]), this.mapTypeInfo(node), this.prefix(node.equalsGreaterThanToken), node.body ? this.convert(node.body) : this.newJEmpty(), null);
678
+ 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)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, true, node.parameters.length > 0 ?
679
+ node.parameters.map(p => this.rightPadded(this.convert(p), this.suffix(p)))
680
+ .concat(node.parameters.hasTrailingComma ? this.rightPadded(this.newJEmpty(), this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseParenToken))) : []) :
681
+ [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));
641
682
  }
642
683
  visitDeleteExpression(node) {
643
684
  return new JS.Delete((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.expression), this.mapType(node));
@@ -716,7 +757,11 @@ class JavaScriptParserVisitor {
716
757
  }
717
758
  binaryOperator = this.mapBinaryOperator(node);
718
759
  if (binaryOperator === undefined) {
719
- return this.visitUnknown(node);
760
+ const assignmentOperation = this.mapAssignmentOperation(node);
761
+ if (assignmentOperation === undefined) {
762
+ return this.visitUnknown(node);
763
+ }
764
+ return new J.AssignmentOperation((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));
720
765
  }
721
766
  return new J.Binary((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.left), this.leftPadded(this.prefix(node.operatorToken), binaryOperator), this.convert(node.right), this.mapType(node));
722
767
  }
@@ -763,6 +808,33 @@ class JavaScriptParserVisitor {
763
808
  }
764
809
  return undefined;
765
810
  }
811
+ mapAssignmentOperation(node) {
812
+ switch (node.operatorToken.kind) {
813
+ case ts.SyntaxKind.PlusEqualsToken:
814
+ return J.AssignmentOperation.Type.Addition;
815
+ case ts.SyntaxKind.MinusEqualsToken:
816
+ return J.AssignmentOperation.Type.Subtraction;
817
+ case ts.SyntaxKind.AsteriskEqualsToken:
818
+ return J.AssignmentOperation.Type.Multiplication;
819
+ case ts.SyntaxKind.SlashEqualsToken:
820
+ return J.AssignmentOperation.Type.Division;
821
+ case ts.SyntaxKind.PercentEqualsToken:
822
+ return J.AssignmentOperation.Type.Modulo;
823
+ case ts.SyntaxKind.LessThanLessThanEqualsToken:
824
+ return J.AssignmentOperation.Type.LeftShift;
825
+ case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:
826
+ return J.AssignmentOperation.Type.RightShift;
827
+ case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
828
+ return J.AssignmentOperation.Type.UnsignedRightShift;
829
+ case ts.SyntaxKind.AmpersandEqualsToken:
830
+ return J.AssignmentOperation.Type.BitAnd;
831
+ case ts.SyntaxKind.BarEqualsToken:
832
+ return J.AssignmentOperation.Type.BitOr;
833
+ case ts.SyntaxKind.CaretEqualsToken:
834
+ return J.AssignmentOperation.Type.BitXor;
835
+ }
836
+ return undefined;
837
+ }
766
838
  visitConditionalExpression(node) {
767
839
  return new J.Ternary((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.condition), this.leftPadded(this.suffix(node.condition), this.convert(node.whenTrue)), this.leftPadded(this.suffix(node.whenTrue), this.convert(node.whenFalse)), this.mapType(node));
768
840
  }
@@ -776,14 +848,19 @@ class JavaScriptParserVisitor {
776
848
  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));
777
849
  }
778
850
  visitClassExpression(node) {
779
- return this.visitUnknown(node);
851
+ return new JS.StatementExpression((0, core_1.randomId)(), new J.ClassDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], [], new J.ClassDeclaration.Kind((0, core_1.randomId)(), node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node), core_1.Markers.EMPTY, [], J.ClassDeclaration.Kind.Type.Class), node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), this.mapTypeParametersAsJContainer(node), null, this.mapExtends(node), this.mapImplements(node), null, new J.Block((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), node.members.map(ce => {
852
+ var _a, _b;
853
+ return new java_1.JRightPadded(this.convert(ce), ((_a = ce.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) === ts.SyntaxKind.SemicolonToken ? this.prefix(ce.getLastToken()) : java_1.Space.EMPTY, ((_b = ce.getLastToken()) === null || _b === void 0 ? void 0 : _b.kind) === ts.SyntaxKind.SemicolonToken ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY);
854
+ }), this.prefix(node.getLastToken())), this.mapType(node)));
780
855
  }
781
856
  visitOmittedExpression(node) {
782
- return this.visitUnknown(node);
857
+ return this.newJEmpty(this.prefix(node));
783
858
  }
784
859
  visitExpressionWithTypeArguments(node) {
785
860
  if (node.typeArguments) {
786
- return this.visitUnknown(node);
861
+ if (node.typeArguments) {
862
+ return new J.ParameterizedType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.expression), this.mapTypeArguments(this.suffix(node.expression), node.typeArguments), this.mapType(node));
863
+ }
787
864
  }
788
865
  return this.visit(node.expression);
789
866
  }
@@ -806,7 +883,7 @@ class JavaScriptParserVisitor {
806
883
  return this.visitUnknown(node);
807
884
  }
808
885
  visitSemicolonClassElement(node) {
809
- return this.visitUnknown(node);
886
+ return this.newJEmpty(this.semicolonPrefix(node));
810
887
  }
811
888
  visitBlock(node) {
812
889
  return new J.Block((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), this.semicolonPaddedStatementList(node.statements), this.prefix(node.getLastToken()));
@@ -832,31 +909,34 @@ class JavaScriptParserVisitor {
832
909
  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);
833
910
  }
834
911
  visitDoStatement(node) {
835
- return this.visitUnknown(node);
912
+ 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)))));
836
913
  }
837
914
  visitWhileStatement(node) {
838
- return this.visitUnknown(node);
915
+ var _a;
916
+ return new J.WhileLoop((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.statement), this.semicolonPrefix(node.statement), ((_a = node.statement.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) == ts.SyntaxKind.SemicolonToken ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY));
839
917
  }
840
918
  visitForStatement(node) {
841
919
  var _a;
842
- return new J.ForLoop((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new J.ForLoop.Control((0, core_1.randomId)(), this.prefix(node.getChildAt(1)), core_1.Markers.EMPTY, [node.initializer ?
920
+ return new J.ForLoop((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new J.ForLoop.Control((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, [node.initializer ?
843
921
  (ts.isVariableDeclarationList(node.initializer) ? this.rightPadded(this.visit(node.initializer), java_1.Space.EMPTY) :
844
922
  this.rightPadded(this.convert(node.initializer), this.suffix(node.initializer.getLastToken()))) :
845
- this.rightPadded(this.newJEmpty(), java_1.Space.EMPTY)], node.condition ? this.rightPadded(this.convert(node.condition), this.suffix(node.condition.getLastToken())) :
846
- this.rightPadded(this.newJEmpty(), java_1.Space.EMPTY), [node.incrementor ? this.rightPadded(this.convert(node.incrementor), this.suffix(node.incrementor.getLastToken())) :
847
- this.rightPadded(this.newJEmpty(), java_1.Space.EMPTY)]), this.rightPadded(this.convert(node.statement), this.semicolonPrefix(node.statement), ((_a = node.statement.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) == ts.SyntaxKind.SemicolonToken ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY));
923
+ this.rightPadded(this.newJEmpty(), this.suffix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)))], node.condition ? this.rightPadded(this.convert(node.condition), this.suffix(node.condition.getLastToken())) :
924
+ this.rightPadded(this.newJEmpty(), this.suffix(this.findChildNode(node, ts.SyntaxKind.SemicolonToken))), [node.incrementor ? this.rightPadded(this.convert(node.incrementor), this.suffix(node.incrementor.getLastToken())) :
925
+ this.rightPadded(this.newJEmpty(this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseParenToken))), java_1.Space.EMPTY)]), this.rightPadded(this.convert(node.statement), this.semicolonPrefix(node.statement), ((_a = node.statement.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) == ts.SyntaxKind.SemicolonToken ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY));
848
926
  }
849
927
  visitForInStatement(node) {
850
- return this.visitUnknown(node);
928
+ var _a;
929
+ return new JS.JSForInLoop((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, new JS.JSForInOfLoopControl((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.initializer), this.prefix(node.initializer)), this.rightPadded(this.visit(node.expression), this.suffix(node.expression))), this.rightPadded(this.convert(node.statement), this.semicolonPrefix(node.statement), ((_a = node.statement.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) == ts.SyntaxKind.SemicolonToken ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY));
851
930
  }
852
931
  visitForOfStatement(node) {
853
- return this.visitUnknown(node);
932
+ var _a;
933
+ return new JS.JSForOfLoop((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.awaitModifier ? this.leftPadded(this.prefix(node.awaitModifier), true) : this.leftPadded(java_1.Space.EMPTY, false), new JS.JSForInOfLoopControl((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.initializer), this.prefix(node.initializer)), this.rightPadded(this.visit(node.expression), this.suffix(node.expression))), this.rightPadded(this.convert(node.statement), this.semicolonPrefix(node.statement), ((_a = node.statement.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) == ts.SyntaxKind.SemicolonToken ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY));
854
934
  }
855
935
  visitContinueStatement(node) {
856
- return this.visitUnknown(node);
936
+ return new J.Continue((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.label ? this.visit(node.label) : null);
857
937
  }
858
938
  visitBreakStatement(node) {
859
- return this.visitUnknown(node);
939
+ return new J.Break((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.label ? this.visit(node.label) : null);
860
940
  }
861
941
  visitReturnStatement(node) {
862
942
  return new J.Return((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.expression ? this.convert(node.expression) : null);
@@ -865,25 +945,26 @@ class JavaScriptParserVisitor {
865
945
  return this.visitUnknown(node);
866
946
  }
867
947
  visitSwitchStatement(node) {
868
- return this.visitUnknown(node);
948
+ return new J.Switch((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.visit(node.caseBlock));
869
949
  }
870
950
  visitLabeledStatement(node) {
871
- return this.visitUnknown(node);
951
+ return new J.Label((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.label), this.suffix(node.label)), this.visit(node.statement));
872
952
  }
873
953
  visitThrowStatement(node) {
874
954
  return new J.Throw((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.expression));
875
955
  }
876
956
  visitTryStatement(node) {
877
- var _a;
878
- return new J.Try((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, null, this.visit(node.tryBlock), node.catchClause ?
879
- [new J.Try.Catch((0, core_1.randomId)(), this.prefix(node.catchClause.getFirstToken()), core_1.Markers.EMPTY, new J.ControlParentheses((0, core_1.randomId)(), this.suffix(node.catchClause.getFirstToken()), core_1.Markers.EMPTY, this.rightPadded(new J.VariableDeclarations((0, core_1.randomId)(), this.prefix(node.catchClause.variableDeclaration), core_1.Markers.EMPTY, [], [], this.mapTypeInfo(node.catchClause.variableDeclaration), null, [], [this.rightPadded(this.visit(node.catchClause.variableDeclaration), java_1.Space.EMPTY)]), this.suffix(node.catchClause.variableDeclaration))), this.visit((_a = node.catchClause) === null || _a === void 0 ? void 0 : _a.block))] : [], node.finallyBlock ? this.leftPadded(this.prefix(node.getChildren().find(n => n.kind === ts.SyntaxKind.FinallyKeyword)), this.visit(node.finallyBlock))
880
- : null);
957
+ 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);
881
958
  }
882
959
  visitDebuggerStatement(node) {
883
960
  return this.visitUnknown(node);
884
961
  }
885
962
  visitVariableDeclaration(node) {
886
- return new J.VariableDeclarations.NamedVariable((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.name), [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildCount(this.sourceFile) - 2)), this.visit(node.initializer)) : null, this.mapVariableType(node));
963
+ const nameExpression = this.visit(node.name);
964
+ if (nameExpression instanceof J.Identifier) {
965
+ return new J.VariableDeclarations.NamedVariable((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, nameExpression, [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildCount(this.sourceFile) - 2)), this.visit(node.initializer)) : null, this.mapVariableType(node));
966
+ }
967
+ return new JS.JSVariableDeclarations.JSNamedVariable((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, nameExpression, [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildCount(this.sourceFile) - 2)), this.visit(node.initializer)) : null, this.mapVariableType(node));
887
968
  }
888
969
  visitVariableDeclarationList(node) {
889
970
  const kind = node.getFirstToken(this.sourceFile);
@@ -892,48 +973,35 @@ class JavaScriptParserVisitor {
892
973
  : (kind === null || kind === void 0 ? void 0 : kind.kind) === ts.SyntaxKind.ConstKeyword
893
974
  ? JS.ScopedVariableDeclarations.Scope.Const
894
975
  : JS.ScopedVariableDeclarations.Scope.Var), node.declarations.map((declaration) => {
895
- return this.rightPadded(new J.VariableDeclarations((0, core_1.randomId)(), this.prefix(declaration), core_1.Markers.EMPTY, [], [], this.mapTypeInfo(declaration), null, [], [this.rightPadded(this.visit(declaration), java_1.Space.EMPTY)]), this.suffix(declaration));
976
+ const declarationExpression = this.visit(declaration);
977
+ return this.rightPadded(JS.isJavaScript(declarationExpression)
978
+ ? new JS.JSVariableDeclarations((0, core_1.randomId)(), this.prefix(declaration), core_1.Markers.EMPTY, [], [], this.mapTypeInfo(declaration), null, [this.rightPadded(declarationExpression, java_1.Space.EMPTY)])
979
+ : new J.VariableDeclarations((0, core_1.randomId)(), this.prefix(declaration), core_1.Markers.EMPTY, [], [], this.mapTypeInfo(declaration), null, [], [this.rightPadded(declarationExpression, java_1.Space.EMPTY)]), this.suffix(declaration));
896
980
  }));
897
981
  }
898
982
  visitFunctionDeclaration(node) {
899
- return new J.MethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), [new J.Modifier((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.FunctionKeyword)), core_1.Markers.EMPTY, node.getChildAt(1, this.sourceFile).kind == ts.SyntaxKind.AsteriskToken ? "function*" : "function", J.Modifier.Type.LanguageExtension, []), ...this.mapModifiers(node)], 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, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
983
+ return new JS.FunctionDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapModifiers(node), this.visit(node.name), this.mapTypeParametersAsObject(node), this.mapCommaSeparatedList(this.getParameterListNodes(node)), this.mapTypeInfo(node), this.convert(node.body), this.mapMethodType(node));
900
984
  }
901
- getParameterListNodes(node) {
985
+ getParameterListNodes(node, openToken = ts.SyntaxKind.OpenParenToken) {
902
986
  const children = node.getChildren(this.sourceFile);
903
987
  for (let i = 0; i < children.length; i++) {
904
- if (children[i].kind == ts.SyntaxKind.OpenParenToken) {
988
+ if (children[i].kind == openToken) {
905
989
  return children.slice(i, i + 3);
906
990
  }
907
991
  }
908
992
  return [];
909
993
  }
910
994
  visitInterfaceDeclaration(node) {
911
- return new J.ClassDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), new J.ClassDeclaration.Kind((0, core_1.randomId)(), node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node), core_1.Markers.EMPTY, [], J.ClassDeclaration.Kind.Type.Interface), node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), this.mapTypeParametersAsJContainer(node), null, null, this.mapInterfaceExtends(node), null, new J.Block((0, core_1.randomId)(), this.prefix(node.getChildren().find(v => v.kind === ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, new java_1.JRightPadded(false, java_1.Space.EMPTY, core_1.Markers.EMPTY), node.members.map(te => {
995
+ return new J.ClassDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), new J.ClassDeclaration.Kind((0, core_1.randomId)(), node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node), core_1.Markers.EMPTY, [], J.ClassDeclaration.Kind.Type.Interface), node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), this.mapTypeParametersAsJContainer(node), null, null, this.mapInterfaceExtends(node), null, new J.Block((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), node.members.map(te => {
912
996
  var _a, _b, _c, _d;
913
997
  return new java_1.JRightPadded(this.convert(te), (((_a = te.getLastToken()) === null || _a === void 0 ? void 0 : _a.kind) === ts.SyntaxKind.SemicolonToken) || (((_b = te.getLastToken()) === null || _b === void 0 ? void 0 : _b.kind) === ts.SyntaxKind.CommaToken) ? this.prefix(te.getLastToken()) : java_1.Space.EMPTY, (((_c = te.getLastToken()) === null || _c === void 0 ? void 0 : _c.kind) === ts.SyntaxKind.SemicolonToken) || (((_d = te.getLastToken()) === null || _d === void 0 ? void 0 : _d.kind) === ts.SyntaxKind.CommaToken) ? core_1.Markers.build([this.convertToken(te.getLastToken())]) : core_1.Markers.EMPTY);
914
998
  }), this.prefix(node.getLastToken())), this.mapType(node));
915
999
  }
916
1000
  visitTypeAliasDeclaration(node) {
917
- return this.visitUnknown(node);
1001
+ return new JS.TypeDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.visit(node.name), node.typeParameters ? this.mapTypeParametersAsObject(node) : null, this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.EqualsToken)), this.convert(node.type)), this.mapType(node));
918
1002
  }
919
1003
  visitEnumDeclaration(node) {
920
- return new J.ClassDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), new J.ClassDeclaration.Kind((0, core_1.randomId)(), node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node), core_1.Markers.EMPTY, [], J.ClassDeclaration.Kind.Type.Enum), node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), null, null, null, null, null, new J.Block((0, core_1.randomId)(), this.prefix(node.getChildren().find(v => v.kind === ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, new java_1.JRightPadded(false, java_1.Space.EMPTY, core_1.Markers.EMPTY), this.convertEnumBlock(node), this.prefix(node.getLastToken())), this.mapType(node));
921
- }
922
- convertEnumBlock(enumDeclaration) {
923
- if (enumDeclaration.members.length == 0) {
924
- return [];
925
- }
926
- const node = enumDeclaration.getChildren()[enumDeclaration.getChildCount() - 2];
927
- const children = node.getChildren();
928
- const childCount = children.length;
929
- const enumMembers = [];
930
- for (let i = 0; i < childCount; i++) {
931
- if (children[i].kind === ts.SyntaxKind.EnumMember) {
932
- const rp = new java_1.JRightPadded(this.convert(children[i]), i + 1 < childCount ? this.prefix(children[i + 1]) : java_1.Space.EMPTY, i + 1 < childCount ? core_1.Markers.build([new java_1.TrailingComma((0, core_1.randomId)(), java_1.Space.EMPTY)]) : core_1.Markers.EMPTY);
933
- enumMembers.push(rp);
934
- }
935
- }
936
- return enumMembers;
1004
+ return new J.ClassDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), new J.ClassDeclaration.Kind((0, core_1.randomId)(), node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node), core_1.Markers.EMPTY, [], J.ClassDeclaration.Kind.Type.Enum), node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), null, null, null, null, null, new J.Block((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenBraceToken)), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), [this.rightPadded(new J.EnumValueSet((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, node.members.map(em => this.rightPadded(this.visit(em), this.suffix(em))), node.members.hasTrailingComma), java_1.Space.EMPTY)], this.prefix(node.getLastToken())), this.mapType(node));
937
1005
  }
938
1006
  visitModuleDeclaration(node) {
939
1007
  const body = this.visit(node.body);
@@ -941,17 +1009,25 @@ class JavaScriptParserVisitor {
941
1009
  const keywordType = namespaceKeyword ? JS.NamespaceDeclaration.KeywordType.Namespace : JS.NamespaceDeclaration.KeywordType.Module;
942
1010
  namespaceKeyword !== null && namespaceKeyword !== void 0 ? namespaceKeyword : (namespaceKeyword = this.findChildNode(node, ts.SyntaxKind.ModuleKeyword));
943
1011
  if (body instanceof JS.NamespaceDeclaration) {
944
- return new JS.NamespaceDeclaration((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(namespaceKeyword ? this.prefix(namespaceKeyword) : java_1.Space.EMPTY, keywordType), this.rightPadded(new J.FieldAccess((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.name), new J.JLeftPadded(this.suffix(node.name), body.name, core_1.Markers.EMPTY), null), java_1.Space.EMPTY), body.body);
1012
+ return new JS.NamespaceDeclaration((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(namespaceKeyword ? this.prefix(namespaceKeyword) : java_1.Space.EMPTY, keywordType), this.rightPadded((body.name instanceof J.FieldAccess)
1013
+ ? this.remapFieldAccess(body.name, node.name)
1014
+ : new J.FieldAccess((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.visit(node.name), new J.JLeftPadded(this.suffix(node.name), body.name, core_1.Markers.EMPTY), null), body.padding.name.after), body.body);
945
1015
  }
946
1016
  else {
947
- return new JS.NamespaceDeclaration((0, core_1.randomId)(), node.parent.kind === ts.SyntaxKind.ModuleBlock ? this.prefix(node) : java_1.Space.EMPTY, core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(namespaceKeyword ? this.prefix(namespaceKeyword) : java_1.Space.EMPTY, keywordType), this.rightPadded(this.convert(node.name), this.prefix(node)), body);
1017
+ return new JS.NamespaceDeclaration((0, core_1.randomId)(), node.parent.kind === ts.SyntaxKind.ModuleBlock ? this.prefix(node) : java_1.Space.EMPTY, core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(namespaceKeyword ? this.prefix(namespaceKeyword) : java_1.Space.EMPTY, keywordType), this.rightPadded(this.convert(node.name), this.suffix(node.name)), body);
948
1018
  }
949
1019
  }
1020
+ remapFieldAccess(fa, name) {
1021
+ if (fa.target instanceof J.Identifier) {
1022
+ return new J.FieldAccess((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, new J.FieldAccess((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.visit(name), this.leftPadded(this.suffix(name), fa.target), null), fa.padding.name, null);
1023
+ }
1024
+ return new J.FieldAccess((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.remapFieldAccess(fa.target, name), fa.padding.name, null);
1025
+ }
950
1026
  visitModuleBlock(node) {
951
1027
  return new J.Block((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), this.semicolonPaddedStatementList(node.statements), this.prefix(node.getLastToken()));
952
1028
  }
953
1029
  visitCaseBlock(node) {
954
- return this.visitUnknown(node);
1030
+ return new J.Block((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(false, java_1.Space.EMPTY), node.clauses.map(clause => this.rightPadded(this.visit(clause), this.suffix(clause))), this.prefix(node.getLastToken()));
955
1031
  }
956
1032
  visitNamespaceExportDeclaration(node) {
957
1033
  return this.visitUnknown(node);
@@ -963,11 +1039,11 @@ class JavaScriptParserVisitor {
963
1039
  return this.mapIdentifier(node, 'import');
964
1040
  }
965
1041
  visitImportDeclaration(node) {
966
- var _a, _b, _c;
1042
+ var _a, _b, _c, _d;
967
1043
  const children = node.getChildren(this.sourceFile);
968
1044
  const _default = !!((_a = node.importClause) === null || _a === void 0 ? void 0 : _a.name);
969
1045
  const onlyDefault = _default && node.importClause.namedBindings == undefined;
970
- return new JS.JsImport((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, _default ? this.rightPadded(this.visit((_b = node.importClause) === null || _b === void 0 ? void 0 : _b.name), this.suffix((_c = node.importClause) === null || _c === void 0 ? void 0 : _c.name)) : null, node.importClause && !onlyDefault ? this.visit(node.importClause) : null, children[children.indexOf(node.moduleSpecifier) - 1].kind == ts.SyntaxKind.FromKeyword ? this.prefix(children[children.indexOf(node.moduleSpecifier) - 1]) : null, this.convert(node.moduleSpecifier), null);
1046
+ return new JS.JsImport((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, _default ? this.rightPadded(this.visit((_b = node.importClause) === null || _b === void 0 ? void 0 : _b.name), this.suffix((_c = node.importClause) === null || _c === void 0 ? void 0 : _c.name)) : null, ((_d = node.importClause) === null || _d === void 0 ? void 0 : _d.isTypeOnly) ? this.leftPadded(this.prefix(this.findChildNode(node.importClause, ts.SyntaxKind.TypeKeyword)), node.importClause.isTypeOnly) : this.leftPadded(java_1.Space.EMPTY, false), node.importClause && !onlyDefault ? this.visit(node.importClause) : null, children[children.indexOf(node.moduleSpecifier) - 1].kind == ts.SyntaxKind.FromKeyword ? this.prefix(children[children.indexOf(node.moduleSpecifier) - 1]) : null, this.convert(node.moduleSpecifier), null);
971
1047
  }
972
1048
  visitImportClause(node) {
973
1049
  var _a;
@@ -983,7 +1059,9 @@ class JavaScriptParserVisitor {
983
1059
  return this.visitUnknown(node);
984
1060
  }
985
1061
  visitImportSpecifier(node) {
986
- return this.mapIdentifier(node, node.name.text, false);
1062
+ return new JS.JsImportSpecifier((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.leftPadded(node.isTypeOnly ? this.prefix(this.findChildNode(node, ts.SyntaxKind.TypeKeyword)) : java_1.Space.EMPTY, node.isTypeOnly), node.propertyName
1063
+ ? new JS.Alias((0, core_1.randomId)(), this.prefix(node.propertyName), core_1.Markers.EMPTY, this.rightPadded(this.convert(node.propertyName), this.suffix(node.propertyName)), this.convert(node.name))
1064
+ : this.convert(node.name), this.mapType(node));
987
1065
  }
988
1066
  visitExportAssignment(node) {
989
1067
  return this.visitUnknown(node);
@@ -1043,16 +1121,18 @@ class JavaScriptParserVisitor {
1043
1121
  return this.visitUnknown(node);
1044
1122
  }
1045
1123
  visitCaseClause(node) {
1046
- return this.visitUnknown(node);
1124
+ return new J.Case((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, J.Case.Type.Statement, new java_1.JContainer(this.prefix(node.expression), [this.rightPadded(this.visit(node.expression), this.suffix(node.expression))], core_1.Markers.EMPTY), new java_1.JContainer(this.prefix(node), this.semicolonPaddedStatementList(node.statements), core_1.Markers.EMPTY), null);
1047
1125
  }
1048
1126
  visitDefaultClause(node) {
1049
- return this.visitUnknown(node);
1127
+ return new J.Case((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, J.Case.Type.Statement, new java_1.JContainer(this.prefix(node), [this.rightPadded(this.mapIdentifier(node, 'default'), this.suffix(this.findChildNode(node, ts.SyntaxKind.DefaultKeyword)))], core_1.Markers.EMPTY), new java_1.JContainer(this.prefix(node), this.semicolonPaddedStatementList(node.statements), core_1.Markers.EMPTY), null);
1050
1128
  }
1051
1129
  visitHeritageClause(node) {
1052
1130
  return this.convert(node.types[0]);
1053
1131
  }
1054
1132
  visitCatchClause(node) {
1055
- return this.visitUnknown(node);
1133
+ return new J.Try.Catch((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.variableDeclaration ?
1134
+ new J.ControlParentheses((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)), core_1.Markers.EMPTY, this.rightPadded(new J.VariableDeclarations((0, core_1.randomId)(), this.prefix(node.variableDeclaration), core_1.Markers.EMPTY, [], [], this.mapTypeInfo(node.variableDeclaration), null, [], [this.rightPadded(this.visit(node.variableDeclaration), java_1.Space.EMPTY)]), this.suffix(node.variableDeclaration))) :
1135
+ new J.ControlParentheses((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.rightPadded(new J.VariableDeclarations((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], [], null, null, [], []), java_1.Space.EMPTY)), this.visit(node.block));
1056
1136
  }
1057
1137
  visitImportAttributes(node) {
1058
1138
  return this.visitUnknown(node);
@@ -1064,10 +1144,10 @@ class JavaScriptParserVisitor {
1064
1144
  return new JS.PropertyAssignment((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.name), this.suffix(node.name)), this.visit(node.initializer));
1065
1145
  }
1066
1146
  visitShorthandPropertyAssignment(node) {
1067
- return this.visitUnknown(node);
1147
+ return new JS.PropertyAssignment((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.name), this.suffix(node.name)), null);
1068
1148
  }
1069
1149
  visitSpreadAssignment(node) {
1070
- return this.visitUnknown(node);
1150
+ return new JS.PropertyAssignment((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(java_1.Space.EMPTY, JS.Unary.Type.Spread), this.visit(node.expression), this.mapType(node.expression)), this.suffix(node.expression)), null);
1071
1151
  }
1072
1152
  visitEnumMember(node) {
1073
1153
  return new J.EnumValue((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], node.name ? this.convert(node.name) : this.mapIdentifier(node, ""), node.initializer ? new J.NewClass((0, core_1.randomId)(), this.suffix(node.name), core_1.Markers.EMPTY, null, java_1.Space.EMPTY, null, new java_1.JContainer(java_1.Space.EMPTY, [this.rightPadded(this.visit(node.initializer), java_1.Space.EMPTY)], core_1.Markers.EMPTY), null, this.mapMethodType(node)) : null);
@@ -1303,6 +1383,12 @@ class JavaScriptParserVisitor {
1303
1383
  if (ts.isConstructSignatureDeclaration(node)) {
1304
1384
  ts_prefix = this.suffix(this.findChildNode(node, ts.SyntaxKind.NewKeyword));
1305
1385
  }
1386
+ else if (ts.isFunctionExpression(node)) {
1387
+ ts_prefix = this.suffix(this.findChildNode(node, ts.SyntaxKind.FunctionKeyword));
1388
+ }
1389
+ else if (ts.isTypeAliasDeclaration(node)) {
1390
+ ts_prefix = this.suffix(node.name);
1391
+ }
1306
1392
  else {
1307
1393
  ts_prefix = node.questionToken ? this.suffix(node.questionToken) : node.name ? this.suffix(node.name) : java_1.Space.EMPTY;
1308
1394
  }
@@ -1326,8 +1412,8 @@ class JavaScriptParserVisitor {
1326
1412
  return new java_1.Semicolon((0, core_1.randomId)());
1327
1413
  return null;
1328
1414
  }
1329
- newJEmpty(prefix = java_1.Space.EMPTY) {
1330
- return new J.Empty((0, core_1.randomId)(), prefix, core_1.Markers.EMPTY);
1415
+ newJEmpty(prefix = java_1.Space.EMPTY, markers) {
1416
+ return new J.Empty((0, core_1.randomId)(), prefix, markers !== null && markers !== void 0 ? markers : core_1.Markers.EMPTY);
1331
1417
  }
1332
1418
  getOptionalUnary(node) {
1333
1419
  return new JS.Unary((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.leftPadded(this.suffix(node.name), JS.Unary.Type.Optional), this.visit(node.name), this.mapType(node));