@openrewrite/rewrite 8.92.15 → 8.92.17
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/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +3 -2
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/amd.d.ts.map +1 -1
- package/dist/javascript/amd.js +3 -2
- package/dist/javascript/amd.js.map +1 -1
- package/dist/javascript/binding.js +3 -3
- package/dist/javascript/binding.js.map +1 -1
- package/dist/javascript/comparator.d.ts.map +1 -1
- package/dist/javascript/comparator.js +4 -0
- package/dist/javascript/comparator.js.map +1 -1
- package/dist/javascript/format/tabs-and-indents-visitor.d.ts.map +1 -1
- package/dist/javascript/format/tabs-and-indents-visitor.js +31 -4
- package/dist/javascript/format/tabs-and-indents-visitor.js.map +1 -1
- package/dist/javascript/index.d.ts +3 -0
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +3 -0
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/markers.d.ts +12 -0
- package/dist/javascript/markers.d.ts.map +1 -1
- package/dist/javascript/markers.js +17 -2
- package/dist/javascript/markers.js.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.d.ts.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js +28 -32
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js.map +1 -1
- package/dist/javascript/node-resolution-result.js +3 -2
- package/dist/javascript/node-resolution-result.js.map +1 -1
- package/dist/javascript/parser.d.ts +9 -0
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +185 -88
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/preconditions.d.ts +11 -0
- package/dist/javascript/preconditions.d.ts.map +1 -1
- package/dist/javascript/preconditions.js +14 -0
- package/dist/javascript/preconditions.js.map +1 -1
- package/dist/javascript/print.d.ts +10 -1
- package/dist/javascript/print.d.ts.map +1 -1
- package/dist/javascript/print.js +120 -77
- package/dist/javascript/print.js.map +1 -1
- package/dist/javascript/search/index.d.ts +1 -0
- package/dist/javascript/search/index.d.ts.map +1 -1
- package/dist/javascript/search/index.js +1 -0
- package/dist/javascript/search/index.js.map +1 -1
- package/dist/javascript/search/is-vendored-or-bundled.d.ts +13 -0
- package/dist/javascript/search/is-vendored-or-bundled.d.ts.map +1 -0
- package/dist/javascript/search/is-vendored-or-bundled.js +93 -0
- package/dist/javascript/search/is-vendored-or-bundled.js.map +1 -0
- package/dist/javascript/templating/engine.d.ts.map +1 -1
- package/dist/javascript/templating/engine.js +8 -3
- package/dist/javascript/templating/engine.js.map +1 -1
- package/dist/javascript/type-mapping.d.ts +1 -0
- package/dist/javascript/type-mapping.d.ts.map +1 -1
- package/dist/javascript/type-mapping.js +18 -3
- package/dist/javascript/type-mapping.js.map +1 -1
- package/dist/print.d.ts +6 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +21 -7
- package/dist/print.js.map +1 -1
- package/dist/rewrite-javascript-version.txt +1 -1
- package/dist/rpc/java-rpc-client.d.ts +2 -0
- package/dist/rpc/java-rpc-client.d.ts.map +1 -1
- package/dist/rpc/java-rpc-client.js +1 -0
- package/dist/rpc/java-rpc-client.js.map +1 -1
- package/dist/rpc/queue.d.ts +8 -0
- package/dist/rpc/queue.d.ts.map +1 -1
- package/dist/rpc/queue.js +45 -3
- package/dist/rpc/queue.js.map +1 -1
- package/dist/rpc/request/get-object.d.ts +4 -0
- package/dist/rpc/request/get-object.d.ts.map +1 -1
- package/dist/rpc/request/get-object.js +23 -1
- package/dist/rpc/request/get-object.js.map +1 -1
- package/dist/rpc/request/parse.d.ts.map +1 -1
- package/dist/rpc/request/parse.js +3 -1
- package/dist/rpc/request/parse.js.map +1 -1
- package/dist/rpc/request/print.d.ts +8 -2
- package/dist/rpc/request/print.d.ts.map +1 -1
- package/dist/rpc/request/print.js +12 -9
- package/dist/rpc/request/print.js.map +1 -1
- package/dist/rpc/rewrite-rpc.d.ts +3 -2
- package/dist/rpc/rewrite-rpc.d.ts.map +1 -1
- package/dist/rpc/rewrite-rpc.js +9 -3
- package/dist/rpc/rewrite-rpc.js.map +1 -1
- package/dist/rpc/server.d.ts.map +1 -1
- package/dist/rpc/server.js +19 -5
- package/dist/rpc/server.js.map +1 -1
- package/dist/test/java-rpc.d.ts.map +1 -1
- package/dist/test/java-rpc.js +3 -0
- package/dist/test/java-rpc.js.map +1 -1
- package/package.json +1 -1
- package/src/javascript/add-import.ts +3 -2
- package/src/javascript/amd.ts +3 -2
- package/src/javascript/binding.ts +3 -3
- package/src/javascript/comparator.ts +10 -0
- package/src/javascript/format/tabs-and-indents-visitor.ts +30 -3
- package/src/javascript/index.ts +3 -0
- package/src/javascript/markers.ts +34 -4
- package/src/javascript/migrate/es6/modernize-octal-escape-sequences.ts +28 -36
- package/src/javascript/node-resolution-result.ts +3 -2
- package/src/javascript/parser.ts +200 -91
- package/src/javascript/preconditions.ts +19 -1
- package/src/javascript/print.ts +123 -76
- package/src/javascript/search/index.ts +1 -0
- package/src/javascript/search/is-vendored-or-bundled.ts +59 -0
- package/src/javascript/templating/engine.ts +7 -2
- package/src/javascript/type-mapping.ts +19 -3
- package/src/print.ts +23 -8
- package/src/rpc/java-rpc-client.ts +3 -0
- package/src/rpc/queue.ts +37 -3
- package/src/rpc/request/get-object.ts +24 -0
- package/src/rpc/request/parse.ts +4 -1
- package/src/rpc/request/print.ts +12 -8
- package/src/rpc/rewrite-rpc.ts +16 -5
- package/src/rpc/server.ts +18 -6
- package/src/test/java-rpc.ts +3 -0
|
@@ -602,24 +602,11 @@ class JavaScriptParserVisitor {
|
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
604
|
mapModifiers(node) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
const modifiers = node.modifiers;
|
|
608
|
-
return modifiers ? modifiers.filter(typescript_1.default.isModifier).map(this.mapModifier) : [];
|
|
609
|
-
}
|
|
610
|
-
if (typescript_1.default.isVariableStatement(node) || typescript_1.default.isModuleDeclaration(node) || typescript_1.default.isClassDeclaration(node) || typescript_1.default.isEnumDeclaration(node)
|
|
611
|
-
|| typescript_1.default.isInterfaceDeclaration(node) || typescript_1.default.isPropertyDeclaration(node) || typescript_1.default.isPropertySignature(node) || typescript_1.default.isParameter(node)
|
|
605
|
+
if (typescript_1.default.isVariableStatement(node) || typescript_1.default.isClassDeclaration(node) || typescript_1.default.isEnumDeclaration(node)
|
|
606
|
+
|| typescript_1.default.isInterfaceDeclaration(node) || typescript_1.default.isPropertyDeclaration(node) || typescript_1.default.isPropertySignature(node) || typescript_1.default.isMethodSignature(node) || typescript_1.default.isParameter(node)
|
|
612
607
|
|| typescript_1.default.isMethodDeclaration(node) || typescript_1.default.isConstructorDeclaration(node) || typescript_1.default.isArrowFunction(node)
|
|
613
|
-
|| typescript_1.default.
|
|
614
|
-
|
|
615
|
-
return node.modifiers ? (_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.filter(typescript_1.default.isModifier).map(this.mapModifier) : [];
|
|
616
|
-
}
|
|
617
|
-
else if (typescript_1.default.isExportAssignment(node)) {
|
|
618
|
-
const defaultModifier = this.findChildNode(node, typescript_1.default.SyntaxKind.DefaultKeyword);
|
|
619
|
-
return [
|
|
620
|
-
...node.modifiers ? (_b = node.modifiers) === null || _b === void 0 ? void 0 : _b.filter(typescript_1.default.isModifier).map(this.mapModifier) : [],
|
|
621
|
-
...defaultModifier && typescript_1.default.isModifier(defaultModifier) ? [this.mapModifier(defaultModifier)] : []
|
|
622
|
-
];
|
|
608
|
+
|| typescript_1.default.isFunctionDeclaration(node) || typescript_1.default.isFunctionExpression(node) || typescript_1.default.isConstructorTypeNode(node) || typescript_1.default.isTypeParameterDeclaration(node)) {
|
|
609
|
+
return this.mapKeywordModifiers(node.modifiers);
|
|
623
610
|
}
|
|
624
611
|
else if (typescript_1.default.isVariableDeclarationList(node)) {
|
|
625
612
|
let modifier;
|
|
@@ -643,29 +630,71 @@ class JavaScriptParserVisitor {
|
|
|
643
630
|
}] : [];
|
|
644
631
|
}
|
|
645
632
|
else if (typescript_1.default.isGetAccessorDeclaration(node)) {
|
|
646
|
-
return
|
|
633
|
+
return this.mapKeywordModifiers(node.modifiers).concat({
|
|
647
634
|
kind: java_1.J.Kind.Modifier,
|
|
648
635
|
id: (0, uuid_1.randomId)(),
|
|
649
636
|
prefix: this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.GetKeyword)),
|
|
650
637
|
markers: markers_1.emptyMarkers,
|
|
651
638
|
keyword: 'get',
|
|
652
639
|
type: java_1.J.ModifierType.LanguageExtension,
|
|
653
|
-
annotations:
|
|
640
|
+
annotations: this.mapTrailingDecorators(node)
|
|
654
641
|
});
|
|
655
642
|
}
|
|
656
643
|
else if (typescript_1.default.isSetAccessorDeclaration(node)) {
|
|
657
|
-
return
|
|
644
|
+
return this.mapKeywordModifiers(node.modifiers).concat({
|
|
658
645
|
kind: java_1.J.Kind.Modifier,
|
|
659
646
|
id: (0, uuid_1.randomId)(),
|
|
660
647
|
prefix: this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.SetKeyword)),
|
|
661
648
|
markers: markers_1.emptyMarkers,
|
|
662
649
|
keyword: 'set',
|
|
663
650
|
type: java_1.J.ModifierType.LanguageExtension,
|
|
664
|
-
annotations:
|
|
651
|
+
annotations: this.mapTrailingDecorators(node)
|
|
665
652
|
});
|
|
666
653
|
}
|
|
667
654
|
throw new Error(`Cannot get modifiers from ${node}`);
|
|
668
655
|
}
|
|
656
|
+
// A decorator written after a modifier is an annotation of the modifier that follows it.
|
|
657
|
+
mapKeywordModifiers(modifiers) {
|
|
658
|
+
const mapped = [];
|
|
659
|
+
let decorators = [];
|
|
660
|
+
for (const modifier of modifiers !== null && modifiers !== void 0 ? modifiers : []) {
|
|
661
|
+
if (typescript_1.default.isDecorator(modifier)) {
|
|
662
|
+
decorators.push(modifier);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
const annotations = mapped.length > 0 ? decorators.map((this.convert)) : [];
|
|
666
|
+
mapped.push(Object.assign(Object.assign({}, this.mapModifier(modifier)), { annotations }));
|
|
667
|
+
decorators = [];
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
return mapped;
|
|
671
|
+
}
|
|
672
|
+
// For a tree with no annotations of its own: a decorator is an annotation of the modifier written after it.
|
|
673
|
+
mapDecoratedModifiers(modifiers) {
|
|
674
|
+
const mapped = [];
|
|
675
|
+
let decorators = [];
|
|
676
|
+
for (const modifier of modifiers !== null && modifiers !== void 0 ? modifiers : []) {
|
|
677
|
+
if (typescript_1.default.isDecorator(modifier)) {
|
|
678
|
+
decorators.push(modifier);
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
const annotations = decorators.map((this.convert));
|
|
682
|
+
mapped.push(Object.assign(Object.assign({}, this.mapModifier(modifier)), { annotations }));
|
|
683
|
+
decorators = [];
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
this.reject(decorators);
|
|
687
|
+
return mapped;
|
|
688
|
+
}
|
|
689
|
+
// What the model has no place for is refused in the compiler's words, never left out of the tree.
|
|
690
|
+
reject(modifiers) {
|
|
691
|
+
if (!modifiers || modifiers.length === 0) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
const { line, character } = this.sourceFile.getLineAndCharacterOfPosition(modifiers[0].getStart(this.sourceFile));
|
|
695
|
+
const message = typescript_1.default.isDecorator(modifiers[0]) ? "Decorators are not valid here." : "Modifiers cannot appear here.";
|
|
696
|
+
throw new SyntaxError(`(${line + 1},${character + 1}): ${message}`);
|
|
697
|
+
}
|
|
669
698
|
rightPadded(t, trailing, markers) {
|
|
670
699
|
return {
|
|
671
700
|
kind: java_1.J.Kind.RightPadded,
|
|
@@ -712,7 +741,7 @@ class JavaScriptParserVisitor {
|
|
|
712
741
|
id: (0, uuid_1.randomId)(),
|
|
713
742
|
prefix: node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node),
|
|
714
743
|
markers: markers_1.emptyMarkers,
|
|
715
|
-
annotations:
|
|
744
|
+
annotations: this.mapTrailingDecorators(node),
|
|
716
745
|
type: java_1.J.ClassDeclaration.Kind.Type.Class
|
|
717
746
|
},
|
|
718
747
|
name: node.name ? this.convert(node.name) : this.mapIdentifier(node, ""),
|
|
@@ -1032,6 +1061,7 @@ class JavaScriptParserVisitor {
|
|
|
1032
1061
|
};
|
|
1033
1062
|
name = spread;
|
|
1034
1063
|
}
|
|
1064
|
+
name = this.annotateName(name, this.trailingDecorators(node));
|
|
1035
1065
|
return {
|
|
1036
1066
|
kind: java_1.J.Kind.VariableDeclarations,
|
|
1037
1067
|
id: (0, uuid_1.randomId)(),
|
|
@@ -1052,6 +1082,23 @@ class JavaScriptParserVisitor {
|
|
|
1052
1082
|
}, this.suffix(node.name))]
|
|
1053
1083
|
};
|
|
1054
1084
|
}
|
|
1085
|
+
// A decorator written after the last modifier of a parameter is an annotation of the name it is written before.
|
|
1086
|
+
annotateName(name, decorators) {
|
|
1087
|
+
if (decorators.length === 0) {
|
|
1088
|
+
return name;
|
|
1089
|
+
}
|
|
1090
|
+
if (name.kind === java_1.J.Kind.Identifier) {
|
|
1091
|
+
const annotations = decorators.map((this.convert));
|
|
1092
|
+
return Object.assign(Object.assign({}, name), { annotations });
|
|
1093
|
+
}
|
|
1094
|
+
if (name.kind === _1.JS.Kind.ObjectBindingPattern) {
|
|
1095
|
+
// a pattern prints its annotations after its prefix, so the space before its brace moves behind them
|
|
1096
|
+
const pattern = name;
|
|
1097
|
+
return Object.assign(Object.assign({}, pattern), { prefix: java_1.emptySpace, leadingAnnotations: decorators.map((this.convert)), bindings: Object.assign(Object.assign({}, pattern.bindings), { before: pattern.prefix }) });
|
|
1098
|
+
}
|
|
1099
|
+
this.reject(decorators);
|
|
1100
|
+
return name;
|
|
1101
|
+
}
|
|
1055
1102
|
visitDecorator(node) {
|
|
1056
1103
|
let annotationType;
|
|
1057
1104
|
let _arguments = undefined;
|
|
@@ -1065,7 +1112,7 @@ class JavaScriptParserVisitor {
|
|
|
1065
1112
|
prefix: java_1.emptySpace,
|
|
1066
1113
|
markers: markers_1.emptyMarkers,
|
|
1067
1114
|
clazz: this.convert(node.expression.expression),
|
|
1068
|
-
typeArguments: this.mapTypeArguments(this.
|
|
1115
|
+
typeArguments: this.mapTypeArguments(this.typeArgumentsPrefix(node.expression, node.expression.typeArguments), node.expression.typeArguments)
|
|
1069
1116
|
};
|
|
1070
1117
|
_arguments = this.mapCommaSeparatedList(node.expression.getChildren(this.sourceFile).slice(-3));
|
|
1071
1118
|
}
|
|
@@ -1170,7 +1217,7 @@ class JavaScriptParserVisitor {
|
|
|
1170
1217
|
prefix: prefix,
|
|
1171
1218
|
markers: markers_1.emptyMarkers,
|
|
1172
1219
|
leadingAnnotations: [], // no decorators allowed
|
|
1173
|
-
modifiers:
|
|
1220
|
+
modifiers: this.mapModifiers(node),
|
|
1174
1221
|
typeParameters: this.mapTypeParametersAsObject(node),
|
|
1175
1222
|
returnTypeExpression: this.mapTypeInfo(node),
|
|
1176
1223
|
name: (0, mutative_1.create)(this.convert(node.name), draft => {
|
|
@@ -1190,7 +1237,7 @@ class JavaScriptParserVisitor {
|
|
|
1190
1237
|
prefix: prefix,
|
|
1191
1238
|
markers: markers_1.emptyMarkers,
|
|
1192
1239
|
leadingAnnotations: [], // no decorators allowed
|
|
1193
|
-
modifiers:
|
|
1240
|
+
modifiers: this.mapModifiers(node),
|
|
1194
1241
|
typeParameters: this.mapTypeParametersAsObject(node),
|
|
1195
1242
|
returnTypeExpression: this.mapTypeInfo(node),
|
|
1196
1243
|
nameAnnotations: [],
|
|
@@ -1217,6 +1264,7 @@ class JavaScriptParserVisitor {
|
|
|
1217
1264
|
draft.markers = this.maybeAddOptionalMarker(draft, node);
|
|
1218
1265
|
});
|
|
1219
1266
|
if (typescript_1.default.isComputedPropertyName(node.name)) {
|
|
1267
|
+
this.reject(this.trailingDecorators(node));
|
|
1220
1268
|
return {
|
|
1221
1269
|
kind: _1.JS.Kind.ComputedPropertyMethodDeclaration,
|
|
1222
1270
|
id: (0, uuid_1.randomId)(),
|
|
@@ -1241,7 +1289,7 @@ class JavaScriptParserVisitor {
|
|
|
1241
1289
|
modifiers: this.mapModifiers(node),
|
|
1242
1290
|
typeParameters: this.mapTypeParametersAsObject(node),
|
|
1243
1291
|
returnTypeExpression: this.mapTypeInfo(node),
|
|
1244
|
-
nameAnnotations:
|
|
1292
|
+
nameAnnotations: this.mapTrailingDecorators(node),
|
|
1245
1293
|
name: name,
|
|
1246
1294
|
parameters: this.mapCommaSeparatedList(this.getParameterListNodes(node)),
|
|
1247
1295
|
dimensionsAfterName: [],
|
|
@@ -1282,6 +1330,7 @@ class JavaScriptParserVisitor {
|
|
|
1282
1330
|
};
|
|
1283
1331
|
}
|
|
1284
1332
|
visitClassStaticBlockDeclaration(node) {
|
|
1333
|
+
this.reject(node.modifiers);
|
|
1285
1334
|
return {
|
|
1286
1335
|
kind: java_1.J.Kind.Block,
|
|
1287
1336
|
id: (0, uuid_1.randomId)(),
|
|
@@ -1449,7 +1498,7 @@ class JavaScriptParserVisitor {
|
|
|
1449
1498
|
id: (0, uuid_1.randomId)(),
|
|
1450
1499
|
prefix: this.prefix(node),
|
|
1451
1500
|
markers: markers_1.emptyMarkers,
|
|
1452
|
-
modifiers: this.
|
|
1501
|
+
modifiers: this.mapDecoratedModifiers(node.modifiers),
|
|
1453
1502
|
parameters: this.mapCommaSeparatedList(this.getParameterListNodes(node, typescript_1.default.SyntaxKind.OpenBracketToken)),
|
|
1454
1503
|
typeExpression: this.leftPadded(this.prefix(node.getChildAt(node.getChildren().indexOf(node.type) - 1)), this.convert(node.type)),
|
|
1455
1504
|
type: this.mapType(node)
|
|
@@ -1475,7 +1524,7 @@ class JavaScriptParserVisitor {
|
|
|
1475
1524
|
prefix: this.prefix(node),
|
|
1476
1525
|
markers: markers_1.emptyMarkers,
|
|
1477
1526
|
class: this.visit(node.typeName),
|
|
1478
|
-
typeParameters: this.mapTypeArguments(this.
|
|
1527
|
+
typeParameters: this.mapTypeArguments(this.typeArgumentsPrefix(node, node.typeArguments), node.typeArguments),
|
|
1479
1528
|
type: this.mapType(node)
|
|
1480
1529
|
};
|
|
1481
1530
|
}
|
|
@@ -1522,7 +1571,7 @@ class JavaScriptParserVisitor {
|
|
|
1522
1571
|
prefix: this.prefix(node),
|
|
1523
1572
|
markers: markers_1.emptyMarkers,
|
|
1524
1573
|
typeExpression: this.convert(node.exprName),
|
|
1525
|
-
typeArguments: node.typeArguments && this.mapTypeArguments(this.
|
|
1574
|
+
typeArguments: node.typeArguments && this.mapTypeArguments(this.typeArgumentsPrefix(node, node.typeArguments), node.typeArguments),
|
|
1526
1575
|
type: this.mapType(node)
|
|
1527
1576
|
};
|
|
1528
1577
|
}
|
|
@@ -1892,7 +1941,7 @@ class JavaScriptParserVisitor {
|
|
|
1892
1941
|
markers: markers_1.emptyMarkers
|
|
1893
1942
|
},
|
|
1894
1943
|
qualifier: node.qualifier && this.leftPadded(this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.DotToken)), this.visit(node.qualifier)),
|
|
1895
|
-
typeArguments: node.typeArguments && this.mapTypeArguments(this.
|
|
1944
|
+
typeArguments: node.typeArguments && this.mapTypeArguments(this.typeArgumentsPrefix(node, node.typeArguments), node.typeArguments),
|
|
1896
1945
|
type: this.mapType(node)
|
|
1897
1946
|
};
|
|
1898
1947
|
}
|
|
@@ -2033,9 +2082,8 @@ class JavaScriptParserVisitor {
|
|
|
2033
2082
|
}
|
|
2034
2083
|
visitCallExpression(node) {
|
|
2035
2084
|
const prefix = this.prefix(node);
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
-
? this.mapTypeArguments(this.prefix(ltToken), node.typeArguments)
|
|
2085
|
+
const typeArguments = node.typeArguments
|
|
2086
|
+
? this.mapTypeArguments(this.typeArgumentsPrefix(node, node.typeArguments), node.typeArguments)
|
|
2039
2087
|
: undefined;
|
|
2040
2088
|
let select;
|
|
2041
2089
|
let name = {
|
|
@@ -2128,7 +2176,7 @@ class JavaScriptParserVisitor {
|
|
|
2128
2176
|
}
|
|
2129
2177
|
return typeTree;
|
|
2130
2178
|
})(),
|
|
2131
|
-
typeParameters: this.mapTypeArguments(this.
|
|
2179
|
+
typeParameters: this.mapTypeArguments(this.typeArgumentsPrefix(node, node.typeArguments), node.typeArguments),
|
|
2132
2180
|
type: undefined
|
|
2133
2181
|
} : this.mapTypeTree(node.expression),
|
|
2134
2182
|
arguments: node.arguments ?
|
|
@@ -2145,7 +2193,7 @@ class JavaScriptParserVisitor {
|
|
|
2145
2193
|
id: (0, uuid_1.randomId)(),
|
|
2146
2194
|
prefix: this.prefix(node),
|
|
2147
2195
|
markers: markers_1.emptyMarkers,
|
|
2148
|
-
tag: this.rightPadded(this.visit(node.tag), this.suffix(node.tag)),
|
|
2196
|
+
tag: this.rightPadded(this.visit(node.tag), node.typeArguments ? this.typeArgumentsPrefix(node, node.typeArguments) : this.suffix(node.tag)),
|
|
2149
2197
|
typeArguments: node.typeArguments && this.mapTypeArguments(java_1.emptySpace, node.typeArguments),
|
|
2150
2198
|
templateExpression: this.convert(node.template),
|
|
2151
2199
|
type: this.mapType(node)
|
|
@@ -2580,13 +2628,13 @@ class JavaScriptParserVisitor {
|
|
|
2580
2628
|
prefix: java_1.emptySpace,
|
|
2581
2629
|
markers: markers_1.emptyMarkers,
|
|
2582
2630
|
leadingAnnotations: this.mapDecorators(node),
|
|
2583
|
-
modifiers:
|
|
2631
|
+
modifiers: this.mapKeywordModifiers(node.modifiers),
|
|
2584
2632
|
classKind: {
|
|
2585
2633
|
kind: java_1.J.Kind.ClassDeclarationKind,
|
|
2586
2634
|
id: (0, uuid_1.randomId)(),
|
|
2587
2635
|
prefix: node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node),
|
|
2588
2636
|
markers: markers_1.emptyMarkers,
|
|
2589
|
-
annotations:
|
|
2637
|
+
annotations: this.mapTrailingDecorators(node),
|
|
2590
2638
|
type: java_1.J.ClassDeclaration.Kind.Type.Class
|
|
2591
2639
|
},
|
|
2592
2640
|
name: node.name ? this.convert(node.name) : this.mapIdentifier(node, ""),
|
|
@@ -2628,7 +2676,7 @@ class JavaScriptParserVisitor {
|
|
|
2628
2676
|
prefix: this.prefix(node),
|
|
2629
2677
|
markers: markers_1.emptyMarkers,
|
|
2630
2678
|
clazz: this.visit(node.expression),
|
|
2631
|
-
typeArguments: this.mapTypeArguments(this.
|
|
2679
|
+
typeArguments: this.mapTypeArguments(this.typeArgumentsPrefix(node, node.typeArguments), node.typeArguments),
|
|
2632
2680
|
type: this.mapType(node)
|
|
2633
2681
|
};
|
|
2634
2682
|
}
|
|
@@ -2709,11 +2757,35 @@ class JavaScriptParserVisitor {
|
|
|
2709
2757
|
}
|
|
2710
2758
|
visitVariableStatement(node) {
|
|
2711
2759
|
const prefix = this.prefix(node);
|
|
2760
|
+
const leading = this.mapDecorators(node);
|
|
2761
|
+
const modifiers = this.mapModifiers(node);
|
|
2762
|
+
const trailing = this.mapTrailingDecorators(node);
|
|
2712
2763
|
return (0, mutative_1.create)(this.visitVariableDeclarationList(node.declarationList), draft => {
|
|
2713
2764
|
draft.prefix = prefix;
|
|
2714
|
-
|
|
2765
|
+
// `const`, `let` or `var` is the modifier that follows them
|
|
2766
|
+
draft.modifiers[0].annotations = (0, mutative_1.castDraft)(trailing);
|
|
2767
|
+
draft.modifiers = (0, mutative_1.castDraft)(modifiers).concat(draft.modifiers);
|
|
2768
|
+
if (draft.kind === java_1.J.Kind.VariableDeclarations) {
|
|
2769
|
+
draft.leadingAnnotations = (0, mutative_1.castDraft)(leading);
|
|
2770
|
+
}
|
|
2771
|
+
else if (leading.length > 0) {
|
|
2772
|
+
draft.modifiers[0].annotations = (0, mutative_1.castDraft)(leading);
|
|
2773
|
+
}
|
|
2715
2774
|
});
|
|
2716
2775
|
}
|
|
2776
|
+
// A loop variable is a statement in the model, which a pattern or an access expression is not.
|
|
2777
|
+
asStatement(tree) {
|
|
2778
|
+
if ((0, parser_utils_1.isStatement)(tree)) {
|
|
2779
|
+
return tree;
|
|
2780
|
+
}
|
|
2781
|
+
return {
|
|
2782
|
+
kind: _1.JS.Kind.ExpressionStatement,
|
|
2783
|
+
id: (0, uuid_1.randomId)(),
|
|
2784
|
+
prefix: java_1.emptySpace,
|
|
2785
|
+
markers: markers_1.emptyMarkers,
|
|
2786
|
+
expression: tree
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2717
2789
|
visitExpressionStatement(node) {
|
|
2718
2790
|
const expression = this.visit(node.expression);
|
|
2719
2791
|
if ((0, parser_utils_1.isStatement)(expression)) {
|
|
@@ -2864,7 +2936,7 @@ class JavaScriptParserVisitor {
|
|
|
2864
2936
|
}, this.suffix(node.initializer));
|
|
2865
2937
|
}
|
|
2866
2938
|
else {
|
|
2867
|
-
return this.rightPadded(this.visit(node.initializer), this.suffix(node.initializer));
|
|
2939
|
+
return this.rightPadded(this.asStatement(this.visit(node.initializer)), this.suffix(node.initializer));
|
|
2868
2940
|
}
|
|
2869
2941
|
})(),
|
|
2870
2942
|
iterable: this.rightPadded(this.visit(node.expression), this.suffix(node.expression))
|
|
@@ -2925,7 +2997,7 @@ class JavaScriptParserVisitor {
|
|
|
2925
2997
|
}, this.suffix(node.initializer));
|
|
2926
2998
|
}
|
|
2927
2999
|
else if (typescript_1.default.isObjectLiteralExpression(node.initializer)) {
|
|
2928
|
-
return this.rightPadded({
|
|
3000
|
+
return this.rightPadded(this.asStatement({
|
|
2929
3001
|
kind: _1.JS.Kind.ObjectBindingPattern,
|
|
2930
3002
|
id: (0, uuid_1.randomId)(),
|
|
2931
3003
|
leadingAnnotations: [],
|
|
@@ -2940,10 +3012,10 @@ class JavaScriptParserVisitor {
|
|
|
2940
3012
|
},
|
|
2941
3013
|
markers: markers_1.emptyMarkers,
|
|
2942
3014
|
prefix: java_1.emptySpace
|
|
2943
|
-
}, this.suffix(node.initializer));
|
|
3015
|
+
}), this.suffix(node.initializer));
|
|
2944
3016
|
}
|
|
2945
3017
|
else {
|
|
2946
|
-
return this.rightPadded(this.visit(node.initializer), this.suffix(node.initializer));
|
|
3018
|
+
return this.rightPadded(this.asStatement(this.visit(node.initializer)), this.suffix(node.initializer));
|
|
2947
3019
|
}
|
|
2948
3020
|
})(),
|
|
2949
3021
|
iterable: this.rightPadded(this.visit(node.expression), this.suffix(node.expression))
|
|
@@ -3197,8 +3269,8 @@ class JavaScriptParserVisitor {
|
|
|
3197
3269
|
});
|
|
3198
3270
|
}
|
|
3199
3271
|
}),
|
|
3200
|
-
leadingAnnotations:
|
|
3201
|
-
nameAnnotations:
|
|
3272
|
+
leadingAnnotations: this.mapDecorators(node),
|
|
3273
|
+
nameAnnotations: this.mapTrailingDecorators(node),
|
|
3202
3274
|
modifiers: this.mapModifiers(node),
|
|
3203
3275
|
name: this.mapMethodName(node, methodType),
|
|
3204
3276
|
typeParameters: this.mapTypeParametersAsObject(node),
|
|
@@ -3224,14 +3296,14 @@ class JavaScriptParserVisitor {
|
|
|
3224
3296
|
id: (0, uuid_1.randomId)(),
|
|
3225
3297
|
prefix: this.prefix(node),
|
|
3226
3298
|
markers: markers_1.emptyMarkers,
|
|
3227
|
-
leadingAnnotations:
|
|
3299
|
+
leadingAnnotations: this.mapDecorators(node),
|
|
3228
3300
|
modifiers: this.mapModifiers(node),
|
|
3229
3301
|
classKind: {
|
|
3230
3302
|
kind: java_1.J.Kind.ClassDeclarationKind,
|
|
3231
3303
|
id: (0, uuid_1.randomId)(),
|
|
3232
3304
|
prefix: node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node),
|
|
3233
3305
|
markers: markers_1.emptyMarkers,
|
|
3234
|
-
annotations:
|
|
3306
|
+
annotations: this.mapTrailingDecorators(node),
|
|
3235
3307
|
type: java_1.J.ClassDeclaration.Kind.Type.Interface
|
|
3236
3308
|
},
|
|
3237
3309
|
name: node.name ? this.convert(node.name) : this.mapIdentifier(node, ""),
|
|
@@ -3263,7 +3335,7 @@ class JavaScriptParserVisitor {
|
|
|
3263
3335
|
id: (0, uuid_1.randomId)(),
|
|
3264
3336
|
prefix: this.prefix(node),
|
|
3265
3337
|
markers: markers_1.emptyMarkers,
|
|
3266
|
-
modifiers: this.
|
|
3338
|
+
modifiers: this.mapDecoratedModifiers(node.modifiers),
|
|
3267
3339
|
name: this.leftPadded(this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.TypeKeyword)), this.visit(node.name)),
|
|
3268
3340
|
typeParameters: node.typeParameters && this.mapTypeParametersAsObject(node),
|
|
3269
3341
|
initializer: this.leftPadded(this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.EqualsToken)), this.convert(node.type)),
|
|
@@ -3276,14 +3348,14 @@ class JavaScriptParserVisitor {
|
|
|
3276
3348
|
id: (0, uuid_1.randomId)(),
|
|
3277
3349
|
prefix: this.prefix(node),
|
|
3278
3350
|
markers: markers_1.emptyMarkers,
|
|
3279
|
-
leadingAnnotations:
|
|
3351
|
+
leadingAnnotations: this.mapDecorators(node),
|
|
3280
3352
|
modifiers: this.mapModifiers(node),
|
|
3281
3353
|
classKind: {
|
|
3282
3354
|
kind: java_1.J.Kind.ClassDeclarationKind,
|
|
3283
3355
|
id: (0, uuid_1.randomId)(),
|
|
3284
3356
|
prefix: node.modifiers ? this.suffix(node.modifiers[node.modifiers.length - 1]) : this.prefix(node),
|
|
3285
3357
|
markers: markers_1.emptyMarkers,
|
|
3286
|
-
annotations:
|
|
3358
|
+
annotations: this.mapTrailingDecorators(node),
|
|
3287
3359
|
type: java_1.J.ClassDeclaration.Kind.Type.Enum
|
|
3288
3360
|
},
|
|
3289
3361
|
name: node.name ? this.convert(node.name) : this.mapIdentifier(node, ""),
|
|
@@ -3334,7 +3406,7 @@ class JavaScriptParserVisitor {
|
|
|
3334
3406
|
id: (0, uuid_1.randomId)(),
|
|
3335
3407
|
prefix: java_1.emptySpace,
|
|
3336
3408
|
markers: markers_1.emptyMarkers,
|
|
3337
|
-
modifiers: this.
|
|
3409
|
+
modifiers: this.mapDecoratedModifiers(node.modifiers),
|
|
3338
3410
|
keywordType: this.leftPadded(namespaceKeyword ? this.prefix(namespaceKeyword) : java_1.emptySpace, keywordType),
|
|
3339
3411
|
name: this.rightPadded((body.name.element.kind === java_1.J.Kind.FieldAccess)
|
|
3340
3412
|
? this.remapFieldAccess(body.name.element, node.name)
|
|
@@ -3361,7 +3433,7 @@ class JavaScriptParserVisitor {
|
|
|
3361
3433
|
id: (0, uuid_1.randomId)(),
|
|
3362
3434
|
prefix: this.prefix(node),
|
|
3363
3435
|
markers: markers_1.emptyMarkers,
|
|
3364
|
-
modifiers: this.
|
|
3436
|
+
modifiers: this.mapDecoratedModifiers(node.modifiers),
|
|
3365
3437
|
keywordType: this.leftPadded(namespaceKeyword ? this.prefix(namespaceKeyword) : java_1.emptySpace, keywordType),
|
|
3366
3438
|
name: this.rightPadded(this.convert(node.name), this.suffix(node.name)),
|
|
3367
3439
|
body
|
|
@@ -3423,21 +3495,16 @@ class JavaScriptParserVisitor {
|
|
|
3423
3495
|
};
|
|
3424
3496
|
}
|
|
3425
3497
|
visitNamespaceExportDeclaration(node) {
|
|
3498
|
+
var _a;
|
|
3499
|
+
const prefix = this.prefix(node);
|
|
3500
|
+
const written = (_a = node.modifiers) !== null && _a !== void 0 ? _a : [];
|
|
3426
3501
|
return {
|
|
3427
3502
|
kind: _1.JS.Kind.NamespaceDeclaration,
|
|
3428
3503
|
id: (0, uuid_1.randomId)(),
|
|
3429
|
-
prefix
|
|
3504
|
+
prefix,
|
|
3430
3505
|
markers: markers_1.emptyMarkers,
|
|
3431
3506
|
modifiers: [
|
|
3432
|
-
|
|
3433
|
-
kind: java_1.J.Kind.Modifier,
|
|
3434
|
-
id: (0, uuid_1.randomId)(),
|
|
3435
|
-
prefix: java_1.emptySpace,
|
|
3436
|
-
markers: markers_1.emptyMarkers,
|
|
3437
|
-
keyword: 'export',
|
|
3438
|
-
type: java_1.J.ModifierType.LanguageExtension,
|
|
3439
|
-
annotations: []
|
|
3440
|
-
},
|
|
3507
|
+
...this.mapDecoratedModifiers([...written, this.findChildNode(node, typescript_1.default.SyntaxKind.ExportKeyword)]),
|
|
3441
3508
|
{
|
|
3442
3509
|
kind: java_1.J.Kind.Modifier,
|
|
3443
3510
|
id: (0, uuid_1.randomId)(),
|
|
@@ -3453,25 +3520,14 @@ class JavaScriptParserVisitor {
|
|
|
3453
3520
|
};
|
|
3454
3521
|
}
|
|
3455
3522
|
visitImportEqualsDeclaration(node) {
|
|
3456
|
-
|
|
3523
|
+
// mapped before the prefix, so that what is written first takes the leading whitespace
|
|
3524
|
+
const modifiers = this.mapDecoratedModifiers(node.modifiers);
|
|
3457
3525
|
return {
|
|
3458
3526
|
kind: _1.JS.Kind.Import,
|
|
3459
3527
|
id: (0, uuid_1.randomId)(),
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
exportModifierSuffix = exportModifier && this.suffix(exportModifier);
|
|
3464
|
-
return exportModifier ? [{
|
|
3465
|
-
kind: java_1.J.Kind.Modifier,
|
|
3466
|
-
id: (0, uuid_1.randomId)(),
|
|
3467
|
-
prefix: this.prefix(exportModifier),
|
|
3468
|
-
markers: markers_1.emptyMarkers,
|
|
3469
|
-
keyword: 'export',
|
|
3470
|
-
type: java_1.J.ModifierType.LanguageExtension,
|
|
3471
|
-
annotations: []
|
|
3472
|
-
}] : [];
|
|
3473
|
-
})(),
|
|
3474
|
-
prefix: exportModifierSuffix ? exportModifierSuffix : this.prefix(node),
|
|
3528
|
+
prefix: this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.ImportKeyword)),
|
|
3529
|
+
markers: markers_1.emptyMarkers,
|
|
3530
|
+
modifiers,
|
|
3475
3531
|
importClause: {
|
|
3476
3532
|
kind: _1.JS.Kind.ImportClause,
|
|
3477
3533
|
id: (0, uuid_1.randomId)(),
|
|
@@ -3489,7 +3545,6 @@ class JavaScriptParserVisitor {
|
|
|
3489
3545
|
name: node.name && this.rightPadded(this.visit(node.name), this.suffix(node.name)),
|
|
3490
3546
|
namedBindings: undefined
|
|
3491
3547
|
},
|
|
3492
|
-
markers: markers_1.emptyMarkers,
|
|
3493
3548
|
moduleSpecifier: undefined,
|
|
3494
3549
|
attributes: undefined,
|
|
3495
3550
|
initializer: this.leftPadded(this.suffix(node.name), this.visit(node.moduleReference))
|
|
@@ -3500,12 +3555,13 @@ class JavaScriptParserVisitor {
|
|
|
3500
3555
|
return this.mapIdentifier(node, 'import');
|
|
3501
3556
|
}
|
|
3502
3557
|
visitImportDeclaration(node) {
|
|
3558
|
+
const modifiers = this.mapDecoratedModifiers(node.modifiers);
|
|
3503
3559
|
return {
|
|
3504
3560
|
kind: _1.JS.Kind.Import,
|
|
3505
3561
|
id: (0, uuid_1.randomId)(),
|
|
3506
|
-
prefix: this.prefix(node),
|
|
3562
|
+
prefix: this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.ImportKeyword)),
|
|
3507
3563
|
markers: markers_1.emptyMarkers,
|
|
3508
|
-
modifiers
|
|
3564
|
+
modifiers,
|
|
3509
3565
|
importClause: node.importClause && this.visit(node.importClause),
|
|
3510
3566
|
moduleSpecifier: this.leftPadded(node.importClause ? this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.FromKeyword)) : java_1.emptySpace, this.visit(node.moduleSpecifier)),
|
|
3511
3567
|
attributes: node.attributes && this.visit(node.attributes)
|
|
@@ -3586,6 +3642,7 @@ class JavaScriptParserVisitor {
|
|
|
3586
3642
|
};
|
|
3587
3643
|
}
|
|
3588
3644
|
visitExportAssignment(node) {
|
|
3645
|
+
this.reject(node.modifiers);
|
|
3589
3646
|
return {
|
|
3590
3647
|
kind: _1.JS.Kind.ExportAssignment,
|
|
3591
3648
|
id: (0, uuid_1.randomId)(),
|
|
@@ -3596,12 +3653,13 @@ class JavaScriptParserVisitor {
|
|
|
3596
3653
|
};
|
|
3597
3654
|
}
|
|
3598
3655
|
visitExportDeclaration(node) {
|
|
3656
|
+
const modifiers = this.mapDecoratedModifiers(node.modifiers);
|
|
3599
3657
|
return {
|
|
3600
3658
|
kind: _1.JS.Kind.ExportDeclaration,
|
|
3601
3659
|
id: (0, uuid_1.randomId)(),
|
|
3602
|
-
prefix: this.prefix(node),
|
|
3660
|
+
prefix: this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.ExportKeyword)),
|
|
3603
3661
|
markers: markers_1.emptyMarkers,
|
|
3604
|
-
modifiers
|
|
3662
|
+
modifiers,
|
|
3605
3663
|
typeOnly: this.leftPadded(node.isTypeOnly ? this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.TypeKeyword)) : java_1.emptySpace, node.isTypeOnly),
|
|
3606
3664
|
exportClause: node.exportClause ? this.visit(node.exportClause) : this.mapIdentifier(this.findChildNode(node, typescript_1.default.SyntaxKind.AsteriskToken), "*"),
|
|
3607
3665
|
moduleSpecifier: node.moduleSpecifier && this.leftPadded(this.prefix(this.findChildNode(node, typescript_1.default.SyntaxKind.FromKeyword)), this.visit(node.moduleSpecifier)),
|
|
@@ -3906,7 +3964,7 @@ class JavaScriptParserVisitor {
|
|
|
3906
3964
|
id: (0, uuid_1.randomId)(),
|
|
3907
3965
|
prefix: this.prefix(node),
|
|
3908
3966
|
markers: markers_1.emptyMarkers,
|
|
3909
|
-
modifiers: this.
|
|
3967
|
+
modifiers: this.mapDecoratedModifiers(node.modifiers),
|
|
3910
3968
|
name: this.rightPadded(this.visit(node.name), this.suffix(node.name)),
|
|
3911
3969
|
assigmentToken: _1.JS.PropertyAssignment.Token.Colon,
|
|
3912
3970
|
initializer: this.visit(node.initializer)
|
|
@@ -3918,7 +3976,7 @@ class JavaScriptParserVisitor {
|
|
|
3918
3976
|
id: (0, uuid_1.randomId)(),
|
|
3919
3977
|
prefix: this.prefix(node),
|
|
3920
3978
|
markers: markers_1.emptyMarkers,
|
|
3921
|
-
modifiers: this.
|
|
3979
|
+
modifiers: this.mapDecoratedModifiers(node.modifiers),
|
|
3922
3980
|
name: this.rightPadded(this.visit(node.name), this.suffix(node.name)),
|
|
3923
3981
|
assigmentToken: _1.JS.PropertyAssignment.Token.Equals,
|
|
3924
3982
|
initializer: node.objectAssignmentInitializer && this.visit(node.objectAssignmentInitializer)
|
|
@@ -3941,7 +3999,11 @@ class JavaScriptParserVisitor {
|
|
|
3941
3999
|
prefix: this.prefix(node),
|
|
3942
4000
|
markers: markers_1.emptyMarkers,
|
|
3943
4001
|
annotations: [],
|
|
3944
|
-
name: node.name ?
|
|
4002
|
+
name: node.name ?
|
|
4003
|
+
typescript_1.default.isStringLiteral(node.name) ? this.mapIdentifier(node.name, node.name.getText()) :
|
|
4004
|
+
typescript_1.default.isComputedPropertyName(node.name) ? this.mapComputedEnumMemberName(node.name) :
|
|
4005
|
+
this.convert(node.name) :
|
|
4006
|
+
this.mapIdentifier(node, ""),
|
|
3945
4007
|
initializer: node.initializer && {
|
|
3946
4008
|
kind: java_1.J.Kind.NewClass,
|
|
3947
4009
|
id: (0, uuid_1.randomId)(),
|
|
@@ -3958,6 +4020,14 @@ class JavaScriptParserVisitor {
|
|
|
3958
4020
|
}
|
|
3959
4021
|
};
|
|
3960
4022
|
}
|
|
4023
|
+
// An enum member is named by an identifier in the model, so the brackets go in a marker.
|
|
4024
|
+
mapComputedEnumMemberName(node) {
|
|
4025
|
+
return Object.assign(Object.assign({}, this.mapIdentifier(node.expression, node.expression.getText())), { markers: (0, markers_1.markers)({
|
|
4026
|
+
kind: _1.JS.Markers.Computed,
|
|
4027
|
+
id: (0, uuid_1.randomId)(),
|
|
4028
|
+
suffix: this.suffix(node.expression)
|
|
4029
|
+
}) });
|
|
4030
|
+
}
|
|
3961
4031
|
visitBundle(node) {
|
|
3962
4032
|
return this.visitUnknown(node);
|
|
3963
4033
|
}
|
|
@@ -4152,6 +4222,17 @@ class JavaScriptParserVisitor {
|
|
|
4152
4222
|
mapCommaSeparatedList(nodes) {
|
|
4153
4223
|
return this.mapToContainer(nodes, this.trailingComma(nodes));
|
|
4154
4224
|
}
|
|
4225
|
+
// `<<` is scanned as one token, so a list whose first type argument starts with `<` has no `<` among the children.
|
|
4226
|
+
typeArgumentsPrefix(node, typeArguments) {
|
|
4227
|
+
var _a;
|
|
4228
|
+
const lessThan = this.findChildNode(node, typescript_1.default.SyntaxKind.LessThanToken);
|
|
4229
|
+
if (lessThan) {
|
|
4230
|
+
return this.prefix(lessThan);
|
|
4231
|
+
}
|
|
4232
|
+
const start = typeArguments.pos - 1;
|
|
4233
|
+
const fullStart = (_a = node.getChildren(this.sourceFile).map(child => child.getEnd()).filter(end => end <= start).pop()) !== null && _a !== void 0 ? _a : start;
|
|
4234
|
+
return this.prefix({ getFullStart: () => fullStart, getStart: () => start });
|
|
4235
|
+
}
|
|
4155
4236
|
mapTypeArguments(prefix, nodes) {
|
|
4156
4237
|
if (nodes.length === 0) {
|
|
4157
4238
|
return (0, java_1.emptyContainer)();
|
|
@@ -4224,8 +4305,24 @@ class JavaScriptParserVisitor {
|
|
|
4224
4305
|
}
|
|
4225
4306
|
}
|
|
4226
4307
|
mapDecorators(node) {
|
|
4227
|
-
var _a
|
|
4228
|
-
|
|
4308
|
+
var _a;
|
|
4309
|
+
const modifiers = (_a = node.modifiers) !== null && _a !== void 0 ? _a : [];
|
|
4310
|
+
const firstKeyword = modifiers.findIndex(typescript_1.default.isModifier);
|
|
4311
|
+
return modifiers.slice(0, firstKeyword < 0 ? modifiers.length : firstKeyword)
|
|
4312
|
+
.filter(typescript_1.default.isDecorator).map((this.convert));
|
|
4313
|
+
}
|
|
4314
|
+
// The decorators between the last modifier and the keyword of the declaration.
|
|
4315
|
+
mapTrailingDecorators(node) {
|
|
4316
|
+
return this.trailingDecorators(node).map((this.convert));
|
|
4317
|
+
}
|
|
4318
|
+
trailingDecorators(node) {
|
|
4319
|
+
var _a;
|
|
4320
|
+
const modifiers = (_a = node.modifiers) !== null && _a !== void 0 ? _a : [];
|
|
4321
|
+
let afterKeywords = modifiers.length;
|
|
4322
|
+
while (afterKeywords > 0 && typescript_1.default.isDecorator(modifiers[afterKeywords - 1])) {
|
|
4323
|
+
afterKeywords--;
|
|
4324
|
+
}
|
|
4325
|
+
return afterKeywords === 0 ? [] : modifiers.slice(afterKeywords).filter(typescript_1.default.isDecorator);
|
|
4229
4326
|
}
|
|
4230
4327
|
mapTypeParametersAsContainer(node) {
|
|
4231
4328
|
return node.typeParameters &&
|