@openrewrite/rewrite 0.25.3 → 0.26.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.
- package/dist/src/java/markers.d.ts +7 -0
- package/dist/src/java/markers.d.ts.map +1 -1
- package/dist/src/java/markers.js +20 -3
- package/dist/src/java/markers.js.map +1 -1
- package/dist/src/java/remote/receiver.d.ts.map +1 -1
- package/dist/src/java/remote/receiver.js +10 -0
- package/dist/src/java/remote/receiver.js.map +1 -1
- package/dist/src/java/remote/sender.d.ts.map +1 -1
- package/dist/src/java/remote/sender.js +7 -0
- package/dist/src/java/remote/sender.js.map +1 -1
- package/dist/src/java/tree/support_types.d.ts +2 -1
- package/dist/src/java/tree/support_types.d.ts.map +1 -1
- package/dist/src/java/tree/support_types.js.map +1 -1
- package/dist/src/java/tree/tree.d.ts +39 -0
- package/dist/src/java/tree/tree.d.ts.map +1 -1
- package/dist/src/java/tree/tree.js +48 -2
- package/dist/src/java/tree/tree.js.map +1 -1
- package/dist/src/java/visitor.d.ts +2 -1
- package/dist/src/java/visitor.d.ts.map +1 -1
- package/dist/src/java/visitor.js +15 -0
- package/dist/src/java/visitor.js.map +1 -1
- package/dist/src/javascript/parser.d.ts +3 -3
- package/dist/src/javascript/parser.d.ts.map +1 -1
- package/dist/src/javascript/parser.js +61 -47
- package/dist/src/javascript/parser.js.map +1 -1
- package/dist/src/javascript/remote/receiver.d.ts.map +1 -1
- package/dist/src/javascript/remote/receiver.js +28 -4
- package/dist/src/javascript/remote/receiver.js.map +1 -1
- package/dist/src/javascript/remote/sender.d.ts.map +1 -1
- package/dist/src/javascript/remote/sender.js +19 -1
- package/dist/src/javascript/remote/sender.js.map +1 -1
- package/dist/src/javascript/tree/support_types.d.ts +14 -11
- package/dist/src/javascript/tree/support_types.d.ts.map +1 -1
- package/dist/src/javascript/tree/support_types.js +11 -8
- package/dist/src/javascript/tree/support_types.js.map +1 -1
- package/dist/src/javascript/tree/tree.d.ts +87 -20
- package/dist/src/javascript/tree/tree.d.ts.map +1 -1
- package/dist/src/javascript/tree/tree.js +124 -25
- package/dist/src/javascript/tree/tree.js.map +1 -1
- package/dist/src/javascript/visitor.d.ts +2 -1
- package/dist/src/javascript/visitor.d.ts.map +1 -1
- package/dist/src/javascript/visitor.js +19 -1
- package/dist/src/javascript/visitor.js.map +1 -1
- package/package.json +1 -1
|
@@ -248,7 +248,7 @@ class JavaScriptParserVisitor {
|
|
|
248
248
|
|| ts.isInterfaceDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)
|
|
249
249
|
|| ts.isMethodDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isArrowFunction(node)
|
|
250
250
|
|| ts.isIndexSignatureDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isExportDeclaration(node)
|
|
251
|
-
|| ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node)) {
|
|
251
|
+
|| ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isConstructorTypeNode(node) || ts.isTypeParameterDeclaration(node)) {
|
|
252
252
|
return node.modifiers ? (_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.filter(ts.isModifier).map(this.mapModifier) : [];
|
|
253
253
|
}
|
|
254
254
|
else if (ts.isExportAssignment(node)) {
|
|
@@ -445,7 +445,7 @@ class JavaScriptParserVisitor {
|
|
|
445
445
|
}
|
|
446
446
|
visitTypeParameter(node) {
|
|
447
447
|
var _a;
|
|
448
|
-
return new J.TypeParameter((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [],
|
|
448
|
+
return new J.TypeParameter((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.mapModifiers(node), this.visit(node.name), (node.constraint || node.default) ?
|
|
449
449
|
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),
|
|
450
450
|
node.default ? this.rightPadded(this.visit(node.default), this.suffix(node.default)) : this.rightPadded(this.newJEmpty(), java_1.Space.EMPTY)], core_1.Markers.EMPTY)
|
|
451
451
|
: null);
|
|
@@ -467,10 +467,8 @@ class JavaScriptParserVisitor {
|
|
|
467
467
|
let annotationType;
|
|
468
468
|
let _arguments = null;
|
|
469
469
|
if (ts.isCallExpression(node.expression)) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
new J.FieldAccess((0, core_1.randomId)(), callExpression.prefix, core_1.Markers.EMPTY, callExpression.select, this.leftPadded(callExpression.padding.select.after, callExpression.name), callExpression.type);
|
|
473
|
-
_arguments = callExpression.padding.arguments;
|
|
470
|
+
annotationType = new JS.ExpressionWithTypeArguments((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.convert(node.expression.expression), node.expression.typeArguments ? this.mapTypeArguments(this.suffix(node.expression.expression), node.expression.typeArguments) : null, null);
|
|
471
|
+
_arguments = this.mapCommaSeparatedList(node.expression.getChildren(this.sourceFile).slice(-3));
|
|
474
472
|
}
|
|
475
473
|
else if (ts.isIdentifier(node.expression)) {
|
|
476
474
|
annotationType = this.convert(node.expression);
|
|
@@ -544,10 +542,18 @@ class JavaScriptParserVisitor {
|
|
|
544
542
|
return new J.MethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), null, null, new J.MethodDeclaration.IdentifierWithAnnotations(this.mapIdentifier(node.getChildren().find(n => n.kind == ts.SyntaxKind.ConstructorKeyword), "constructor"), []), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
|
|
545
543
|
}
|
|
546
544
|
visitGetAccessor(node) {
|
|
547
|
-
|
|
545
|
+
const name = this.visit(node.name);
|
|
546
|
+
if (!(name instanceof J.Identifier)) {
|
|
547
|
+
return new JS.JSMethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), null, this.mapTypeInfo(node), name, this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
|
|
548
|
+
}
|
|
549
|
+
return new J.MethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), null, this.mapTypeInfo(node), new J.MethodDeclaration.IdentifierWithAnnotations(name, []), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
|
|
548
550
|
}
|
|
549
551
|
visitSetAccessor(node) {
|
|
550
|
-
|
|
552
|
+
const name = this.visit(node.name);
|
|
553
|
+
if (!(name instanceof J.Identifier)) {
|
|
554
|
+
return new JS.JSMethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), null, null, name, this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
|
|
555
|
+
}
|
|
556
|
+
return new J.MethodDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), null, null, new J.MethodDeclaration.IdentifierWithAnnotations(name, []), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, node.body ? this.convert(node.body) : null, null, this.mapMethodType(node));
|
|
551
557
|
}
|
|
552
558
|
visitCallSignature(node) {
|
|
553
559
|
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, [], "", null, null), []), this.mapCommaSeparatedList(this.getParameterListNodes(node)), null, null, null, this.mapMethodType(node));
|
|
@@ -568,13 +574,14 @@ class JavaScriptParserVisitor {
|
|
|
568
574
|
return this.visit(node.typeName);
|
|
569
575
|
}
|
|
570
576
|
visitFunctionType(node) {
|
|
571
|
-
return new JS.FunctionType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.
|
|
577
|
+
return new JS.FunctionType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], this.leftPadded(java_1.Space.EMPTY, false), this.mapTypeParametersAsObject(node), new java_1.JContainer(this.prefix(node.getChildAt(node.getChildren().findIndex(n => n.pos === node.parameters.pos) - 1)), node.parameters.map(p => this.rightPadded(this.visit(p), this.suffix(p)))
|
|
578
|
+
.concat(node.parameters.hasTrailingComma ? this.rightPadded(this.newJEmpty(), this.prefix(this.findChildNode(node, ts.SyntaxKind.CloseParenToken))) : []), core_1.Markers.EMPTY), this.prefix(this.findChildNode(node, ts.SyntaxKind.EqualsGreaterThanToken)), this.convert(node.type), null);
|
|
572
579
|
}
|
|
573
580
|
visitConstructorType(node) {
|
|
574
|
-
return new JS.FunctionType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.
|
|
581
|
+
return new JS.FunctionType((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.mapModifiers(node), this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.NewKeyword)), true), this.mapTypeParametersAsObject(node), new java_1.JContainer(this.prefix(node.getChildAt(node.getChildren().findIndex(n => n.pos === node.parameters.pos) - 1)), 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);
|
|
575
582
|
}
|
|
576
583
|
visitTypeQuery(node) {
|
|
577
|
-
return new JS.TypeQuery((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.exprName), this.mapType(node));
|
|
584
|
+
return new JS.TypeQuery((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.convert(node.exprName), node.typeArguments ? this.mapTypeArguments(this.suffix(node.exprName), node.typeArguments) : null, this.mapType(node));
|
|
578
585
|
}
|
|
579
586
|
visitTypeLiteral(node) {
|
|
580
587
|
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 => {
|
|
@@ -712,19 +719,11 @@ class JavaScriptParserVisitor {
|
|
|
712
719
|
select = null;
|
|
713
720
|
name = this.convert(node.expression);
|
|
714
721
|
}
|
|
715
|
-
else if (
|
|
716
|
-
select = this.rightPadded(node.expression.
|
|
717
|
-
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)) :
|
|
718
|
-
this.convert(node.expression.expression), this.prefix(node.expression.getChildAt(1, this.sourceFile)));
|
|
719
|
-
name = this.convert(node.expression.name);
|
|
722
|
+
else if (node.questionDotToken) {
|
|
723
|
+
select = this.rightPadded(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)), java_1.Space.EMPTY);
|
|
720
724
|
}
|
|
721
725
|
else {
|
|
722
|
-
|
|
723
|
-
select = this.rightPadded(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)), java_1.Space.EMPTY);
|
|
724
|
-
}
|
|
725
|
-
else {
|
|
726
|
-
select = this.rightPadded(this.visit(node.expression), this.suffix(node.expression));
|
|
727
|
-
}
|
|
726
|
+
select = this.rightPadded(this.visit(node.expression), this.suffix(node.expression));
|
|
728
727
|
}
|
|
729
728
|
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));
|
|
730
729
|
}
|
|
@@ -732,10 +731,10 @@ class JavaScriptParserVisitor {
|
|
|
732
731
|
return this.mapIdentifier(node, node.getText());
|
|
733
732
|
}
|
|
734
733
|
visitNewExpression(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));
|
|
734
|
+
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, new _1.TypeTreeExpression((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) : new _1.TypeTreeExpression((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.visit(node.expression)), node.arguments ? this.mapCommaSeparatedList(this.getParameterListNodes(node)) : java_1.JContainer.empty().withMarkers(core_1.Markers.build([(new J.OmitParentheses((0, core_1.randomId)()))])), null, this.mapMethodType(node));
|
|
736
735
|
}
|
|
737
736
|
visitTaggedTemplateExpression(node) {
|
|
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.
|
|
737
|
+
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.convert(node.template), this.mapType(node));
|
|
739
738
|
}
|
|
740
739
|
visitTypeAssertionExpression(node) {
|
|
741
740
|
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));
|
|
@@ -1001,12 +1000,12 @@ class JavaScriptParserVisitor {
|
|
|
1001
1000
|
}
|
|
1002
1001
|
visitIfStatement(node) {
|
|
1003
1002
|
var _a, _b, _c;
|
|
1004
|
-
const semicolonAfterThen = ((_a = node.thenStatement.
|
|
1005
|
-
const semicolonAfterElse = ((_c = (_b = node.elseStatement) === null || _b === void 0 ? void 0 : _b.
|
|
1003
|
+
const semicolonAfterThen = (((_a = node.thenStatement.getChildAt(node.thenStatement.getChildCount() - 1)) === null || _a === void 0 ? void 0 : _a.kind) == ts.SyntaxKind.SemicolonToken);
|
|
1004
|
+
const semicolonAfterElse = (((_c = (_b = node.elseStatement) === null || _b === void 0 ? void 0 : _b.getChildAt(node.elseStatement.getChildCount() - 1)) === null || _c === void 0 ? void 0 : _c.kind) == ts.SyntaxKind.SemicolonToken);
|
|
1006
1005
|
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);
|
|
1007
1006
|
}
|
|
1008
1007
|
visitDoStatement(node) {
|
|
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(
|
|
1008
|
+
return new J.DoWhileLoop((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.rightPadded(this.visit(node.statement), node.statement.kind === ts.SyntaxKind.ExpressionStatement ? this.prefix(node.statement.getLastToken()) : this.suffix(node.statement), node.statement.kind === ts.SyntaxKind.ExpressionStatement ? core_1.Markers.build([new java_1.Semicolon((0, core_1.randomId)())]) : core_1.Markers.EMPTY), this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.WhileKeyword)), 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)))));
|
|
1010
1009
|
}
|
|
1011
1010
|
visitWhileStatement(node) {
|
|
1012
1011
|
var _a;
|
|
@@ -1016,18 +1015,18 @@ class JavaScriptParserVisitor {
|
|
|
1016
1015
|
var _a;
|
|
1017
1016
|
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 ?
|
|
1018
1017
|
(ts.isVariableDeclarationList(node.initializer) ? this.rightPadded(this.visit(node.initializer), java_1.Space.EMPTY) :
|
|
1019
|
-
this.rightPadded(new _1.ExpressionStatement((0, core_1.randomId)(), this.visit(node.initializer)), this.suffix(node.initializer
|
|
1020
|
-
this.rightPadded(this.newJEmpty(), this.suffix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)))], node.condition ? this.rightPadded(ts.isStatement(node.condition) ? this.visit(node.condition) : new _1.ExpressionStatement((0, core_1.randomId)(), this.visit(node.condition)), this.suffix(node.condition
|
|
1021
|
-
this.rightPadded(this.newJEmpty(), this.suffix(this.findChildNode(node, ts.SyntaxKind.SemicolonToken))), [node.incrementor ? this.rightPadded(ts.isStatement(node.incrementor) ? this.visit(node.incrementor) : new _1.ExpressionStatement((0, core_1.randomId)(), this.visit(node.incrementor)), this.suffix(node.incrementor
|
|
1022
|
-
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.
|
|
1018
|
+
this.rightPadded(new _1.ExpressionStatement((0, core_1.randomId)(), this.visit(node.initializer)), this.suffix(node.initializer))) :
|
|
1019
|
+
this.rightPadded(this.newJEmpty(), this.suffix(this.findChildNode(node, ts.SyntaxKind.OpenParenToken)))], node.condition ? this.rightPadded(ts.isStatement(node.condition) ? this.visit(node.condition) : new _1.ExpressionStatement((0, core_1.randomId)(), this.visit(node.condition)), this.suffix(node.condition)) :
|
|
1020
|
+
this.rightPadded(this.newJEmpty(), this.suffix(this.findChildNode(node, ts.SyntaxKind.SemicolonToken))), [node.incrementor ? this.rightPadded(ts.isStatement(node.incrementor) ? this.visit(node.incrementor) : new _1.ExpressionStatement((0, core_1.randomId)(), this.visit(node.incrementor)), this.suffix(node.incrementor)) :
|
|
1021
|
+
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.getChildAt(node.statement.getChildCount() - 1)) === 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));
|
|
1023
1022
|
}
|
|
1024
1023
|
visitForInStatement(node) {
|
|
1025
1024
|
var _a;
|
|
1026
|
-
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.suffix(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.
|
|
1025
|
+
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.suffix(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.getChildAt(node.statement.getChildCount() - 1)) === 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));
|
|
1027
1026
|
}
|
|
1028
1027
|
visitForOfStatement(node) {
|
|
1029
1028
|
var _a;
|
|
1030
|
-
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.suffix(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.
|
|
1029
|
+
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.suffix(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.getChildAt(node.statement.getChildCount() - 1)) === 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));
|
|
1031
1030
|
}
|
|
1032
1031
|
visitContinueStatement(node) {
|
|
1033
1032
|
return new J.Continue((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.label ? this.visit(node.label) : null);
|
|
@@ -1045,7 +1044,8 @@ class JavaScriptParserVisitor {
|
|
|
1045
1044
|
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));
|
|
1046
1045
|
}
|
|
1047
1046
|
visitLabeledStatement(node) {
|
|
1048
|
-
|
|
1047
|
+
var _a;
|
|
1048
|
+
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)), new JS.TrailingTokenStatement((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, this.rightPadded(this.visit(node.statement), this.semicolonPrefix(node.statement), ((_a = node.statement.getChildAt(node.statement.getChildCount() - 1)) === 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), this.mapType(node.statement)));
|
|
1049
1049
|
}
|
|
1050
1050
|
visitThrowStatement(node) {
|
|
1051
1051
|
return new J.Throw((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, this.visit(node.expression));
|
|
@@ -1058,10 +1058,10 @@ class JavaScriptParserVisitor {
|
|
|
1058
1058
|
}
|
|
1059
1059
|
visitVariableDeclaration(node) {
|
|
1060
1060
|
const nameExpression = this.visit(node.name);
|
|
1061
|
-
if (nameExpression instanceof J.Identifier) {
|
|
1061
|
+
if (nameExpression instanceof J.Identifier && !node.exclamationToken) {
|
|
1062
1062
|
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));
|
|
1063
1063
|
}
|
|
1064
|
-
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));
|
|
1064
|
+
return new JS.JSVariableDeclarations.JSNamedVariable((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, node.exclamationToken ? 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), nameExpression, this.mapType(node)) : nameExpression, [], node.initializer ? this.leftPadded(this.prefix(node.getChildAt(node.getChildCount(this.sourceFile) - 2)), this.visit(node.initializer)) : null, this.mapVariableType(node));
|
|
1065
1065
|
}
|
|
1066
1066
|
visitVariableDeclarationList(node) {
|
|
1067
1067
|
const kind = node.getFirstToken(this.sourceFile);
|
|
@@ -1101,10 +1101,19 @@ class JavaScriptParserVisitor {
|
|
|
1101
1101
|
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));
|
|
1102
1102
|
}
|
|
1103
1103
|
visitModuleDeclaration(node) {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1104
|
+
var _a;
|
|
1105
|
+
const body = node.body ? this.visit(node.body) : null;
|
|
1106
|
+
let namespaceKeyword = (_a = this.findChildNode(node, ts.SyntaxKind.NamespaceKeyword)) !== null && _a !== void 0 ? _a : this.findChildNode(node, ts.SyntaxKind.ModuleKeyword);
|
|
1107
|
+
let keywordType;
|
|
1108
|
+
if (namespaceKeyword == undefined) {
|
|
1109
|
+
keywordType = JS.NamespaceDeclaration.KeywordType.Empty;
|
|
1110
|
+
}
|
|
1111
|
+
else if ((namespaceKeyword === null || namespaceKeyword === void 0 ? void 0 : namespaceKeyword.kind) === ts.SyntaxKind.NamespaceKeyword) {
|
|
1112
|
+
keywordType = JS.NamespaceDeclaration.KeywordType.Namespace;
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
keywordType = JS.NamespaceDeclaration.KeywordType.Module;
|
|
1116
|
+
}
|
|
1108
1117
|
if (body instanceof JS.NamespaceDeclaration) {
|
|
1109
1118
|
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)
|
|
1110
1119
|
? this.remapFieldAccess(body.name, node.name)
|
|
@@ -1127,7 +1136,10 @@ class JavaScriptParserVisitor {
|
|
|
1127
1136
|
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()));
|
|
1128
1137
|
}
|
|
1129
1138
|
visitNamespaceExportDeclaration(node) {
|
|
1130
|
-
return this.
|
|
1139
|
+
return new JS.NamespaceDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [
|
|
1140
|
+
new J.Modifier((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, 'export', J.Modifier.Type.LanguageExtension, []),
|
|
1141
|
+
new J.Modifier((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.AsKeyword)), core_1.Markers.EMPTY, 'as', J.Modifier.Type.LanguageExtension, [])
|
|
1142
|
+
], this.leftPadded(this.prefix(this.findChildNode(node, ts.SyntaxKind.NamespaceKeyword)), JS.NamespaceDeclaration.KeywordType.Namespace), this.rightPadded(this.convert(node.name), this.suffix(node.name)), null);
|
|
1131
1143
|
}
|
|
1132
1144
|
visitImportEqualsDeclaration(node) {
|
|
1133
1145
|
return this.visitUnknown(node);
|
|
@@ -1240,16 +1252,16 @@ class JavaScriptParserVisitor {
|
|
|
1240
1252
|
return this.visitUnknown(node);
|
|
1241
1253
|
}
|
|
1242
1254
|
visitPropertyAssignment(node) {
|
|
1243
|
-
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));
|
|
1255
|
+
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)), JS.PropertyAssignment.AssigmentToken.Colon, this.visit(node.initializer));
|
|
1244
1256
|
}
|
|
1245
1257
|
visitShorthandPropertyAssignment(node) {
|
|
1246
|
-
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);
|
|
1258
|
+
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)), JS.PropertyAssignment.AssigmentToken.Equals, node.objectAssignmentInitializer ? this.visit(node.objectAssignmentInitializer) : null);
|
|
1247
1259
|
}
|
|
1248
1260
|
visitSpreadAssignment(node) {
|
|
1249
|
-
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);
|
|
1261
|
+
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)), JS.PropertyAssignment.AssigmentToken.Empty, null);
|
|
1250
1262
|
}
|
|
1251
1263
|
visitEnumMember(node) {
|
|
1252
|
-
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);
|
|
1264
|
+
return new J.EnumValue((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [], node.name ? ts.isStringLiteral(node.name) ? this.mapIdentifier(node.name, node.name.getText()) : 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);
|
|
1253
1265
|
}
|
|
1254
1266
|
visitBundle(node) {
|
|
1255
1267
|
return this.visitUnknown(node);
|
|
@@ -1472,14 +1484,16 @@ class JavaScriptParserVisitor {
|
|
|
1472
1484
|
}
|
|
1473
1485
|
mapTypeParametersAsJContainer(node) {
|
|
1474
1486
|
return node.typeParameters
|
|
1475
|
-
? java_1.JContainer.build(this.suffix(this.findChildNode(node, ts.SyntaxKind.Identifier)), this.mapTypeParametersList(node.typeParameters)
|
|
1487
|
+
? java_1.JContainer.build(this.suffix(this.findChildNode(node, ts.SyntaxKind.Identifier)), this.mapTypeParametersList(node.typeParameters)
|
|
1488
|
+
.concat(node.typeParameters.hasTrailingComma ? this.rightPadded(new J.TypeParameter((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], [], this.newJEmpty(), null), this.prefix(this.findChildNode(node, ts.SyntaxKind.GreaterThanToken))) : []), core_1.Markers.EMPTY)
|
|
1476
1489
|
: null;
|
|
1477
1490
|
}
|
|
1478
1491
|
mapTypeParametersAsObject(node) {
|
|
1479
1492
|
const typeParameters = node.typeParameters;
|
|
1480
1493
|
if (!typeParameters)
|
|
1481
1494
|
return null;
|
|
1482
|
-
return new J.TypeParameters((0, core_1.randomId)(), this.prefix(node.getChildAt(node.getChildren().findIndex(n => n.pos === typeParameters[0].pos) - 1)), core_1.Markers.EMPTY, [], typeParameters.map(tp => this.rightPadded(this.visit(tp), this.suffix(tp)))
|
|
1495
|
+
return new J.TypeParameters((0, core_1.randomId)(), this.prefix(node.getChildAt(node.getChildren().findIndex(n => n.pos === typeParameters[0].pos) - 1)), core_1.Markers.EMPTY, [], typeParameters.map(tp => this.rightPadded(this.visit(tp), this.suffix(tp)))
|
|
1496
|
+
.concat(typeParameters.hasTrailingComma ? this.rightPadded(new J.TypeParameter((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, [], [], this.newJEmpty(), null), this.prefix(this.findChildNode(node, ts.SyntaxKind.GreaterThanToken))) : []));
|
|
1483
1497
|
}
|
|
1484
1498
|
mapTypeParametersList(typeParamsNodeArray) {
|
|
1485
1499
|
return typeParamsNodeArray.map(tp => this.rightPadded(this.visit(tp), this.suffix(tp)));
|