@openrewrite/rewrite 0.25.3 → 0.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +56 -43
- package/dist/src/javascript/parser.js.map +1 -1
- package/dist/src/javascript/remote/receiver.js +17 -4
- package/dist/src/javascript/remote/receiver.js.map +1 -1
- package/dist/src/javascript/remote/sender.js +11 -1
- package/dist/src/javascript/remote/sender.js.map +1 -1
- package/dist/src/javascript/tree/support_types.d.ts +11 -10
- package/dist/src/javascript/tree/support_types.d.ts.map +1 -1
- package/dist/src/javascript/tree/support_types.js +9 -8
- package/dist/src/javascript/tree/support_types.js.map +1 -1
- package/dist/src/javascript/tree/tree.d.ts +41 -20
- package/dist/src/javascript/tree/tree.d.ts.map +1 -1
- package/dist/src/javascript/tree/tree.js +63 -22
- package/dist/src/javascript/tree/tree.js.map +1 -1
- package/dist/src/javascript/visitor.d.ts.map +1 -1
- package/dist/src/javascript/visitor.js +3 -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, 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)), this.mapCommaSeparatedList(this.getParameterListNodes(node)), 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));
|
|
@@ -1000,9 +999,9 @@ class JavaScriptParserVisitor {
|
|
|
1000
999
|
return new JS.ExpressionStatement((0, core_1.randomId)(), expression);
|
|
1001
1000
|
}
|
|
1002
1001
|
visitIfStatement(node) {
|
|
1003
|
-
var _a, _b, _c;
|
|
1004
|
-
const semicolonAfterThen = ((_a = node.thenStatement.getLastToken()) === null ||
|
|
1005
|
-
const semicolonAfterElse = ((_c = (
|
|
1002
|
+
var _a, _b, _c, _d, _e;
|
|
1003
|
+
const semicolonAfterThen = (((_a = node.thenStatement) === null || _a === void 0 ? void 0 : _a.kind) != ts.SyntaxKind.IfStatement) && (((_b = node.thenStatement.getLastToken()) === null || _b === void 0 ? void 0 : _b.kind) == ts.SyntaxKind.SemicolonToken);
|
|
1004
|
+
const semicolonAfterElse = (((_c = node.elseStatement) === null || _c === void 0 ? void 0 : _c.kind) != ts.SyntaxKind.IfStatement) && (((_e = (_d = node.elseStatement) === null || _d === void 0 ? void 0 : _d.getLastToken()) === null || _e === void 0 ? void 0 : _e.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) {
|
|
@@ -1016,9 +1015,9 @@ 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
|
|
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)) :
|
|
1022
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.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));
|
|
1023
1022
|
}
|
|
1024
1023
|
visitForInStatement(node) {
|
|
@@ -1058,10 +1057,10 @@ class JavaScriptParserVisitor {
|
|
|
1058
1057
|
}
|
|
1059
1058
|
visitVariableDeclaration(node) {
|
|
1060
1059
|
const nameExpression = this.visit(node.name);
|
|
1061
|
-
if (nameExpression instanceof J.Identifier) {
|
|
1060
|
+
if (nameExpression instanceof J.Identifier && !node.exclamationToken) {
|
|
1062
1061
|
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
1062
|
}
|
|
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));
|
|
1063
|
+
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
1064
|
}
|
|
1066
1065
|
visitVariableDeclarationList(node) {
|
|
1067
1066
|
const kind = node.getFirstToken(this.sourceFile);
|
|
@@ -1101,10 +1100,19 @@ class JavaScriptParserVisitor {
|
|
|
1101
1100
|
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
1101
|
}
|
|
1103
1102
|
visitModuleDeclaration(node) {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1103
|
+
var _a;
|
|
1104
|
+
const body = node.body ? this.visit(node.body) : null;
|
|
1105
|
+
let namespaceKeyword = (_a = this.findChildNode(node, ts.SyntaxKind.NamespaceKeyword)) !== null && _a !== void 0 ? _a : this.findChildNode(node, ts.SyntaxKind.ModuleKeyword);
|
|
1106
|
+
let keywordType;
|
|
1107
|
+
if (namespaceKeyword == undefined) {
|
|
1108
|
+
keywordType = JS.NamespaceDeclaration.KeywordType.Empty;
|
|
1109
|
+
}
|
|
1110
|
+
else if ((namespaceKeyword === null || namespaceKeyword === void 0 ? void 0 : namespaceKeyword.kind) === ts.SyntaxKind.NamespaceKeyword) {
|
|
1111
|
+
keywordType = JS.NamespaceDeclaration.KeywordType.Namespace;
|
|
1112
|
+
}
|
|
1113
|
+
else {
|
|
1114
|
+
keywordType = JS.NamespaceDeclaration.KeywordType.Module;
|
|
1115
|
+
}
|
|
1108
1116
|
if (body instanceof JS.NamespaceDeclaration) {
|
|
1109
1117
|
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
1118
|
? this.remapFieldAccess(body.name, node.name)
|
|
@@ -1127,7 +1135,10 @@ class JavaScriptParserVisitor {
|
|
|
1127
1135
|
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
1136
|
}
|
|
1129
1137
|
visitNamespaceExportDeclaration(node) {
|
|
1130
|
-
return this.
|
|
1138
|
+
return new JS.NamespaceDeclaration((0, core_1.randomId)(), this.prefix(node), core_1.Markers.EMPTY, [
|
|
1139
|
+
new J.Modifier((0, core_1.randomId)(), java_1.Space.EMPTY, core_1.Markers.EMPTY, 'export', J.Modifier.Type.LanguageExtension, []),
|
|
1140
|
+
new J.Modifier((0, core_1.randomId)(), this.prefix(this.findChildNode(node, ts.SyntaxKind.AsKeyword)), core_1.Markers.EMPTY, 'as', J.Modifier.Type.LanguageExtension, [])
|
|
1141
|
+
], 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
1142
|
}
|
|
1132
1143
|
visitImportEqualsDeclaration(node) {
|
|
1133
1144
|
return this.visitUnknown(node);
|
|
@@ -1240,16 +1251,16 @@ class JavaScriptParserVisitor {
|
|
|
1240
1251
|
return this.visitUnknown(node);
|
|
1241
1252
|
}
|
|
1242
1253
|
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));
|
|
1254
|
+
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
1255
|
}
|
|
1245
1256
|
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);
|
|
1257
|
+
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
1258
|
}
|
|
1248
1259
|
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);
|
|
1260
|
+
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
1261
|
}
|
|
1251
1262
|
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);
|
|
1263
|
+
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
1264
|
}
|
|
1254
1265
|
visitBundle(node) {
|
|
1255
1266
|
return this.visitUnknown(node);
|
|
@@ -1472,14 +1483,16 @@ class JavaScriptParserVisitor {
|
|
|
1472
1483
|
}
|
|
1473
1484
|
mapTypeParametersAsJContainer(node) {
|
|
1474
1485
|
return node.typeParameters
|
|
1475
|
-
? java_1.JContainer.build(this.suffix(this.findChildNode(node, ts.SyntaxKind.Identifier)), this.mapTypeParametersList(node.typeParameters)
|
|
1486
|
+
? java_1.JContainer.build(this.suffix(this.findChildNode(node, ts.SyntaxKind.Identifier)), this.mapTypeParametersList(node.typeParameters)
|
|
1487
|
+
.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
1488
|
: null;
|
|
1477
1489
|
}
|
|
1478
1490
|
mapTypeParametersAsObject(node) {
|
|
1479
1491
|
const typeParameters = node.typeParameters;
|
|
1480
1492
|
if (!typeParameters)
|
|
1481
1493
|
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)))
|
|
1494
|
+
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
|
+
.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
1496
|
}
|
|
1484
1497
|
mapTypeParametersList(typeParamsNodeArray) {
|
|
1485
1498
|
return typeParamsNodeArray.map(tp => this.rightPadded(this.visit(tp), this.suffix(tp)));
|