@openrewrite/rewrite 8.66.0-SNAPSHOT → 8.66.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/javascript/comparator.d.ts +91 -5
- package/dist/javascript/comparator.d.ts.map +1 -1
- package/dist/javascript/comparator.js +679 -3091
- package/dist/javascript/comparator.js.map +1 -1
- package/dist/javascript/format.d.ts.map +1 -1
- package/dist/javascript/format.js +4 -3
- package/dist/javascript/format.js.map +1 -1
- package/dist/javascript/index.d.ts +1 -1
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +1 -1
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +22 -21
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/print.d.ts +2 -2
- package/dist/javascript/print.d.ts.map +1 -1
- package/dist/javascript/print.js +4 -4
- package/dist/javascript/print.js.map +1 -1
- package/dist/javascript/templating/capture.d.ts +226 -0
- package/dist/javascript/templating/capture.d.ts.map +1 -0
- package/dist/javascript/templating/capture.js +371 -0
- package/dist/javascript/templating/capture.js.map +1 -0
- package/dist/javascript/templating/comparator.d.ts +61 -0
- package/dist/javascript/templating/comparator.d.ts.map +1 -0
- package/dist/javascript/templating/comparator.js +393 -0
- package/dist/javascript/templating/comparator.js.map +1 -0
- package/dist/javascript/templating/engine.d.ts +75 -0
- package/dist/javascript/templating/engine.d.ts.map +1 -0
- package/dist/javascript/templating/engine.js +228 -0
- package/dist/javascript/templating/engine.js.map +1 -0
- package/dist/javascript/templating/index.d.ts +6 -0
- package/dist/javascript/templating/index.d.ts.map +1 -0
- package/dist/javascript/templating/index.js +42 -0
- package/dist/javascript/templating/index.js.map +1 -0
- package/dist/javascript/templating/pattern.d.ts +171 -0
- package/dist/javascript/templating/pattern.d.ts.map +1 -0
- package/dist/javascript/templating/pattern.js +681 -0
- package/dist/javascript/templating/pattern.js.map +1 -0
- package/dist/javascript/templating/placeholder-replacement.d.ts +58 -0
- package/dist/javascript/templating/placeholder-replacement.d.ts.map +1 -0
- package/dist/javascript/templating/placeholder-replacement.js +365 -0
- package/dist/javascript/templating/placeholder-replacement.js.map +1 -0
- package/dist/javascript/templating/rewrite.d.ts +39 -0
- package/dist/javascript/templating/rewrite.d.ts.map +1 -0
- package/dist/javascript/templating/rewrite.js +81 -0
- package/dist/javascript/templating/rewrite.js.map +1 -0
- package/dist/javascript/templating/template.d.ts +204 -0
- package/dist/javascript/templating/template.d.ts.map +1 -0
- package/dist/javascript/templating/template.js +293 -0
- package/dist/javascript/templating/template.js.map +1 -0
- package/dist/javascript/templating/types.d.ts +263 -0
- package/dist/javascript/templating/types.d.ts.map +1 -0
- package/dist/javascript/templating/types.js +3 -0
- package/dist/javascript/templating/types.js.map +1 -0
- package/dist/javascript/templating/utils.d.ts +118 -0
- package/dist/javascript/templating/utils.d.ts.map +1 -0
- package/dist/javascript/templating/utils.js +253 -0
- package/dist/javascript/templating/utils.js.map +1 -0
- package/dist/test/rewrite-test.d.ts.map +1 -1
- package/dist/test/rewrite-test.js +65 -9
- package/dist/test/rewrite-test.js.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +2 -2
- package/src/javascript/comparator.ts +721 -3607
- package/src/javascript/format.ts +3 -2
- package/src/javascript/index.ts +1 -1
- package/src/javascript/parser.ts +23 -22
- package/src/javascript/print.ts +6 -6
- package/src/javascript/templating/capture.ts +503 -0
- package/src/javascript/templating/comparator.ts +430 -0
- package/src/javascript/templating/engine.ts +252 -0
- package/src/javascript/templating/index.ts +60 -0
- package/src/javascript/templating/pattern.ts +727 -0
- package/src/javascript/templating/placeholder-replacement.ts +372 -0
- package/src/javascript/templating/rewrite.ts +95 -0
- package/src/javascript/templating/template.ts +326 -0
- package/src/javascript/templating/types.ts +300 -0
- package/src/javascript/templating/utils.ts +284 -0
- package/src/test/rewrite-test.ts +65 -1
- package/dist/javascript/templating.d.ts +0 -265
- package/dist/javascript/templating.d.ts.map +0 -1
- package/dist/javascript/templating.js +0 -1069
- package/dist/javascript/templating.js.map +0 -1
- package/src/javascript/templating.ts +0 -1277
package/src/javascript/format.ts
CHANGED
|
@@ -826,7 +826,7 @@ export class MinimumViableSpacingVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
826
826
|
return produce(ret, draft => {
|
|
827
827
|
if (draft.class) {
|
|
828
828
|
if (draft.class.kind == JS.Kind.TypeTreeExpression) {
|
|
829
|
-
this.ensureSpace((draft.class as Draft<JS.TypeTreeExpression>).
|
|
829
|
+
this.ensureSpace((draft.class as Draft<JS.TypeTreeExpression>).prefix);
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
});
|
|
@@ -941,7 +941,8 @@ export class BlankLinesVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
941
941
|
tree = produce(tree as JS.StatementExpression, draft => {
|
|
942
942
|
this.ensurePrefixHasNewLine(draft);
|
|
943
943
|
});
|
|
944
|
-
} else if (tree.kind === J.Kind.MethodDeclaration && this.cursor.value.kind != JS.Kind.StatementExpression
|
|
944
|
+
} else if (tree.kind === J.Kind.MethodDeclaration && this.cursor.value.kind != JS.Kind.StatementExpression
|
|
945
|
+
&& (this.cursor.parent?.value.kind != JS.Kind.CompilationUnit || (this.cursor.parent?.value as JS.CompilationUnit).statements[0].element !== tree)) {
|
|
945
946
|
tree = produce(tree as J.MethodDeclaration, draft => {
|
|
946
947
|
this.ensurePrefixHasNewLine(draft);
|
|
947
948
|
});
|
package/src/javascript/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ export * from "./parser";
|
|
|
20
20
|
export * from "./style";
|
|
21
21
|
export * from "./markers";
|
|
22
22
|
export * from "./preconditions";
|
|
23
|
-
export * from "./templating";
|
|
23
|
+
export * from "./templating/index";
|
|
24
24
|
export * from "./method-matcher";
|
|
25
25
|
|
|
26
26
|
export * from "./add-import";
|
package/src/javascript/parser.ts
CHANGED
|
@@ -612,13 +612,12 @@ export class JavaScriptParserVisitor {
|
|
|
612
612
|
}
|
|
613
613
|
for (let heritageClause of node.heritageClauses) {
|
|
614
614
|
if (heritageClause.token == ts.SyntaxKind.ExtendsKeyword) {
|
|
615
|
-
const expression = this.visit(heritageClause.types[0]);
|
|
616
615
|
return this.leftPadded<TypeTree>(this.prefix(heritageClause.getFirstToken()!), {
|
|
617
616
|
kind: JS.Kind.TypeTreeExpression,
|
|
618
617
|
id: randomId(),
|
|
619
|
-
prefix:
|
|
618
|
+
prefix: this.prefix(heritageClause.types[0]),
|
|
620
619
|
markers: emptyMarkers,
|
|
621
|
-
expression:
|
|
620
|
+
expression: this.visit(heritageClause.types[0])
|
|
622
621
|
} satisfies JS.TypeTreeExpression as JS.TypeTreeExpression);
|
|
623
622
|
}
|
|
624
623
|
}
|
|
@@ -1493,7 +1492,7 @@ export class JavaScriptParserVisitor {
|
|
|
1493
1492
|
element: {
|
|
1494
1493
|
kind: J.Kind.Ternary,
|
|
1495
1494
|
id: randomId(),
|
|
1496
|
-
prefix:
|
|
1495
|
+
prefix: this.prefix(node.extendsType),
|
|
1497
1496
|
markers: emptyMarkers,
|
|
1498
1497
|
condition: this.convert(node.extendsType),
|
|
1499
1498
|
truePart: this.leftPadded(this.suffix(node.extendsType), this.convert(node.trueType)),
|
|
@@ -1998,7 +1997,7 @@ export class JavaScriptParserVisitor {
|
|
|
1998
1997
|
class: node.typeArguments ? {
|
|
1999
1998
|
kind: J.Kind.ParameterizedType,
|
|
2000
1999
|
id: randomId(),
|
|
2001
|
-
prefix:
|
|
2000
|
+
prefix: this.prefix(node.expression),
|
|
2002
2001
|
markers: emptyMarkers,
|
|
2003
2002
|
class: {
|
|
2004
2003
|
kind: JS.Kind.TypeTreeExpression,
|
|
@@ -2012,7 +2011,7 @@ export class JavaScriptParserVisitor {
|
|
|
2012
2011
|
} satisfies J.ParameterizedType as J.ParameterizedType : {
|
|
2013
2012
|
kind: JS.Kind.TypeTreeExpression,
|
|
2014
2013
|
id: randomId(),
|
|
2015
|
-
prefix:
|
|
2014
|
+
prefix: this.prefix(node.expression),
|
|
2016
2015
|
markers: emptyMarkers,
|
|
2017
2016
|
expression: this.visit(node.expression),
|
|
2018
2017
|
} satisfies JS.TypeTreeExpression as JS.TypeTreeExpression,
|
|
@@ -2460,12 +2459,12 @@ export class JavaScriptParserVisitor {
|
|
|
2460
2459
|
return {
|
|
2461
2460
|
kind: JS.Kind.StatementExpression,
|
|
2462
2461
|
id: randomId(),
|
|
2463
|
-
prefix:
|
|
2462
|
+
prefix: this.prefix(node),
|
|
2464
2463
|
markers: emptyMarkers,
|
|
2465
2464
|
statement: {
|
|
2466
2465
|
kind: J.Kind.Yield,
|
|
2467
2466
|
id: randomId(),
|
|
2468
|
-
prefix:
|
|
2467
|
+
prefix: emptySpace,
|
|
2469
2468
|
markers: node.asteriskToken ?
|
|
2470
2469
|
markers({
|
|
2471
2470
|
kind: JS.Markers.DelegatedYield,
|
|
@@ -2492,12 +2491,12 @@ export class JavaScriptParserVisitor {
|
|
|
2492
2491
|
return {
|
|
2493
2492
|
kind: JS.Kind.StatementExpression,
|
|
2494
2493
|
id: randomId(),
|
|
2495
|
-
prefix:
|
|
2494
|
+
prefix: this.prefix(node),
|
|
2496
2495
|
markers: emptyMarkers,
|
|
2497
2496
|
statement: {
|
|
2498
2497
|
kind: J.Kind.ClassDeclaration,
|
|
2499
2498
|
id: randomId(),
|
|
2500
|
-
prefix:
|
|
2499
|
+
prefix: emptySpace,
|
|
2501
2500
|
markers: emptyMarkers,
|
|
2502
2501
|
leadingAnnotations: this.mapDecorators(node),
|
|
2503
2502
|
modifiers: [],
|
|
@@ -2637,25 +2636,27 @@ export class JavaScriptParserVisitor {
|
|
|
2637
2636
|
}
|
|
2638
2637
|
|
|
2639
2638
|
visitVariableStatement(node: ts.VariableStatement): JS.ScopedVariableDeclarations | J.VariableDeclarations {
|
|
2639
|
+
const prefix = this.prefix(node);
|
|
2640
2640
|
return produce(this.visitVariableDeclarationList(node.declarationList), draft => {
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
}
|
|
2644
|
-
draft.prefix = this.prefix(node);
|
|
2641
|
+
draft.prefix = prefix;
|
|
2642
|
+
draft.modifiers = this.mapModifiers(node).concat(draft.modifiers);
|
|
2645
2643
|
});
|
|
2646
2644
|
}
|
|
2647
2645
|
|
|
2648
2646
|
visitExpressionStatement(node: ts.ExpressionStatement): Statement {
|
|
2649
|
-
const expression = this.visit(node.expression) as Expression;
|
|
2647
|
+
const expression: Expression = this.visit(node.expression) as Expression;
|
|
2650
2648
|
if (isStatement(expression)) {
|
|
2651
2649
|
return expression as Statement;
|
|
2652
2650
|
}
|
|
2651
|
+
const e: Expression = expression;
|
|
2653
2652
|
return {
|
|
2654
2653
|
kind: JS.Kind.ExpressionStatement,
|
|
2655
2654
|
id: randomId(),
|
|
2656
|
-
prefix:
|
|
2655
|
+
prefix: e.prefix,
|
|
2657
2656
|
markers: emptyMarkers,
|
|
2658
|
-
expression:
|
|
2657
|
+
expression: produce(e, draft => {
|
|
2658
|
+
draft.prefix = emptySpace
|
|
2659
|
+
})
|
|
2659
2660
|
} satisfies JS.ExpressionStatement as JS.ExpressionStatement;
|
|
2660
2661
|
}
|
|
2661
2662
|
|
|
@@ -2768,7 +2769,7 @@ export class JavaScriptParserVisitor {
|
|
|
2768
2769
|
update: [node.incrementor ? this.rightPadded(ts.isStatement(node.incrementor) ? this.visit(node.incrementor) : {
|
|
2769
2770
|
kind: JS.Kind.ExpressionStatement,
|
|
2770
2771
|
id: randomId(),
|
|
2771
|
-
prefix:
|
|
2772
|
+
prefix: this.prefix(node.incrementor),
|
|
2772
2773
|
markers: emptyMarkers,
|
|
2773
2774
|
expression: this.visit(node.incrementor)
|
|
2774
2775
|
}, this.suffix(node.incrementor)) :
|
|
@@ -3064,7 +3065,7 @@ export class JavaScriptParserVisitor {
|
|
|
3064
3065
|
modifiers.push({
|
|
3065
3066
|
kind: J.Kind.Modifier,
|
|
3066
3067
|
id: randomId(),
|
|
3067
|
-
prefix: this.prefix(kind),
|
|
3068
|
+
prefix: modifiers.length === 0 ? this.prefix(kind) : this.prefix(kind),
|
|
3068
3069
|
markers: emptyMarkers,
|
|
3069
3070
|
annotations: [],
|
|
3070
3071
|
keyword: kind.kind === ts.SyntaxKind.VarKeyword ? 'var' :
|
|
@@ -3263,7 +3264,7 @@ export class JavaScriptParserVisitor {
|
|
|
3263
3264
|
{
|
|
3264
3265
|
kind: J.Kind.EnumValueSet,
|
|
3265
3266
|
id: randomId(),
|
|
3266
|
-
prefix: emptySpace,
|
|
3267
|
+
prefix: node.members[0] ? this.prefix(node.members[0]) : emptySpace,
|
|
3267
3268
|
markers: emptyMarkers,
|
|
3268
3269
|
enums: node.members.map(em => this.rightPadded(this.visit(em), this.suffix(em))),
|
|
3269
3270
|
terminatedWithSemicolon: node.members.hasTrailingComma
|
|
@@ -3323,7 +3324,7 @@ export class JavaScriptParserVisitor {
|
|
|
3323
3324
|
return {
|
|
3324
3325
|
kind: JS.Kind.NamespaceDeclaration,
|
|
3325
3326
|
id: randomId(),
|
|
3326
|
-
prefix:
|
|
3327
|
+
prefix: this.prefix(node),
|
|
3327
3328
|
markers: emptyMarkers,
|
|
3328
3329
|
modifiers: this.mapModifiers(node),
|
|
3329
3330
|
keywordType: this.leftPadded(
|
|
@@ -3457,7 +3458,7 @@ export class JavaScriptParserVisitor {
|
|
|
3457
3458
|
const typeKeyword = node.getChildren().find(n => n.kind === ts.SyntaxKind.TypeKeyword);
|
|
3458
3459
|
return this.prefix(typeKeyword!);
|
|
3459
3460
|
} else {
|
|
3460
|
-
return
|
|
3461
|
+
return this.prefix(node.name);
|
|
3461
3462
|
}
|
|
3462
3463
|
})(),
|
|
3463
3464
|
markers: emptyMarkers,
|
package/src/javascript/print.ts
CHANGED
|
@@ -75,16 +75,16 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
override async visitExpressionStatement(statement: JS.ExpressionStatement, p: PrintOutputCapture): Promise<J | undefined> {
|
|
78
|
-
await this.
|
|
79
|
-
await this.visitMarkers(statement.markers, p);
|
|
78
|
+
await this.beforeSyntax(statement, p);
|
|
80
79
|
await this.visit(statement.expression, p);
|
|
80
|
+
await this.afterSyntax(statement, p);
|
|
81
81
|
return statement;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
override async visitStatementExpression(statementExpression: JS.StatementExpression, p: PrintOutputCapture): Promise<J | undefined> {
|
|
85
|
-
await this.
|
|
86
|
-
await this.visitMarkers(statementExpression.markers, p);
|
|
85
|
+
await this.beforeSyntax(statementExpression, p);
|
|
87
86
|
await this.visit(statementExpression.statement, p);
|
|
87
|
+
await this.afterSyntax(statementExpression, p);
|
|
88
88
|
return statementExpression;
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -1767,7 +1767,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
|
|
|
1767
1767
|
return cursor;
|
|
1768
1768
|
}
|
|
1769
1769
|
|
|
1770
|
-
|
|
1770
|
+
protected async afterSyntax(j: J, p: PrintOutputCapture) {
|
|
1771
1771
|
await this.afterSyntaxMarkers(j.markers, p);
|
|
1772
1772
|
}
|
|
1773
1773
|
|
|
@@ -1777,7 +1777,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
|
|
|
1777
1777
|
}
|
|
1778
1778
|
}
|
|
1779
1779
|
|
|
1780
|
-
|
|
1780
|
+
protected async beforeSyntax(j: J, p: PrintOutputCapture) {
|
|
1781
1781
|
await this.beforeSyntaxExt(j.prefix, j.markers, p);
|
|
1782
1782
|
}
|
|
1783
1783
|
|