@@ -38,7 +38,7 @@ void assignmentWithinIfPredicate() {
38
38
rewriteRun (
39
39
spec -> spec .recipe (toRecipe (() -> new JavaIsoVisitor <>() {
40
40
@ Override
41
- public J .Assignment visitAssignment (J .Assignment assignment , ExecutionContext p ) {
41
+ public J .Assignment visitAssignment (J .Assignment assignment , ExecutionContext ctx ) {
42
42
if ((assignment .getAssignment () instanceof J .Literal ) &&
43
43
((J .Literal ) assignment .getAssignment ()).getValue ().equals (1 )) {
44
44
return JavaTemplate .builder ("value = 0" )
@@ -77,7 +77,7 @@ void lambdaIsNewClass() {
77
77
rewriteRun (
78
78
spec -> spec .recipe (toRecipe (() -> new JavaIsoVisitor <>() {
79
79
@ Override
80
- public J .Assignment visitAssignment (J .Assignment assignment , ExecutionContext p ) {
80
+ public J .Assignment visitAssignment (J .Assignment assignment , ExecutionContext ctx ) {
81
81
var a = assignment ;
82
82
if (a .getAssignment () instanceof J .MethodInvocation ) {
83
83
J .MethodInvocation mi = (J .MethodInvocation ) a .getAssignment ();
@@ -120,8 +120,8 @@ void replaceForEachControlVariableType() {
120
120
rewriteRun (
121
121
spec -> spec .recipe (toRecipe (() -> new JavaIsoVisitor <>() {
122
122
@ Override
123
- public J .VariableDeclarations visitVariableDeclarations (J .VariableDeclarations multiVariable , ExecutionContext p ) {
124
- var mv = super .visitVariableDeclarations (multiVariable , p );
123
+ public J .VariableDeclarations visitVariableDeclarations (J .VariableDeclarations multiVariable , ExecutionContext ctx ) {
124
+ var mv = super .visitVariableDeclarations (multiVariable , ctx );
125
125
if (mv .getVariables ().get (0 ).getInitializer () == null && TypeUtils .isOfType (mv .getTypeExpression ()
126
126
.getType (), JavaType .Primitive .String )) {
127
127
mv = JavaTemplate .apply ("Object #{}" , getCursor (),
@@ -158,8 +158,8 @@ void replaceForEachControlIterable() {
158
158
rewriteRun (
159
159
spec -> spec .recipe (toRecipe (() -> new JavaIsoVisitor <>() {
160
160
@ Override
161
- public J .ForEachLoop .Control visitForEachControl (J .ForEachLoop .Control control , ExecutionContext executionContext ) {
162
- control = super .visitForEachControl (control , executionContext );
161
+ public J .ForEachLoop .Control visitForEachControl (J .ForEachLoop .Control control , ExecutionContext ctx ) {
162
+ control = super .visitForEachControl (control , ctx );
163
163
Expression iterable = control .getIterable ();
164
164
if (!TypeUtils .isOfClassType (iterable .getType (), "java.lang.String" )) {
165
165
return control ;
@@ -192,8 +192,8 @@ void replaceBinaryExpression() {
192
192
rewriteRun (
193
193
spec -> spec .recipe (toRecipe (() -> new JavaIsoVisitor <>() {
194
194
@ Override
195
- public J .Binary visitBinary (J .Binary binary , ExecutionContext executionContext ) {
196
- binary = super .visitBinary (binary , executionContext );
195
+ public J .Binary visitBinary (J .Binary binary , ExecutionContext ctx ) {
196
+ binary = super .visitBinary (binary , ctx );
197
197
if (binary .getLeft () instanceof J .Literal lit && lit .getValue ().equals (42 )) {
198
198
return JavaTemplate .apply ("43" , getCursor (), lit .getCoordinates ().replace ());
199
199
}
@@ -225,7 +225,7 @@ void replaceForEachControlIterator() {
225
225
rewriteRun (
226
226
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
227
227
@ Override
228
- public J visitNewClass (J .NewClass newClass , ExecutionContext p ) {
228
+ public J visitNewClass (J .NewClass newClass , ExecutionContext ctx ) {
229
229
if (TypeUtils .isOfClassType (newClass .getType (), "java.util.ArrayList" )) {
230
230
return JavaTemplate .builder ("Collections.emptyList()" )
231
231
.imports ("java.util.Collections" ).build ()
@@ -313,7 +313,7 @@ void replaceAnonymousClassObject() {
313
313
rewriteRun (
314
314
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
315
315
@ Override
316
- public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext executionContext ) {
316
+ public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext ctx ) {
317
317
if (method .getSimpleName ().equals ("asList" )) {
318
318
maybeAddImport ("java.util.Collections" );
319
319
maybeRemoveImport ("java.util.Arrays" );
@@ -361,7 +361,7 @@ void replaceGenericTypedObject() {
361
361
rewriteRun (
362
362
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
363
363
@ Override
364
- public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext executionContext ) {
364
+ public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext ctx ) {
365
365
if (method .getSimpleName ().equals ("asList" )) {
366
366
maybeAddImport ("java.util.Collections" );
367
367
maybeRemoveImport ("java.util.Arrays" );
@@ -411,7 +411,7 @@ void replaceParameterizedTypeObject() {
411
411
rewriteRun (
412
412
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
413
413
@ Override
414
- public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext executionContext ) {
414
+ public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext ctx ) {
415
415
if (method .getSimpleName ().equals ("asList" )) {
416
416
maybeAddImport ("java.util.Collections" );
417
417
maybeRemoveImport ("java.util.Arrays" );
@@ -465,7 +465,7 @@ void templatingWhileLoopCondition() {
465
465
rewriteRun (
466
466
spec -> spec .expectedCyclesThatMakeChanges (2 ).recipe (toRecipe (() -> new JavaVisitor <>() {
467
467
@ Override
468
- public J visitBinary (J .Binary binary , ExecutionContext p ) {
468
+ public J visitBinary (J .Binary binary , ExecutionContext ctx ) {
469
469
if (binary .getLeft () instanceof J .MethodInvocation ) {
470
470
J .MethodInvocation mi = (J .MethodInvocation ) binary .getLeft ();
471
471
return JavaTemplate .builder ("!#{any(java.util.List)}.isEmpty()" )
@@ -508,8 +508,8 @@ void javaTemplateControlsSemiColons() {
508
508
.imports ("java.math.RoundingMode" ).build ();
509
509
510
510
@ Override
511
- public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext p ) {
512
- J .MethodInvocation mi = (J .MethodInvocation ) super .visitMethodInvocation (method , p );
511
+ public J visitMethodInvocation (J .MethodInvocation method , ExecutionContext ctx ) {
512
+ J .MethodInvocation mi = (J .MethodInvocation ) super .visitMethodInvocation (method , ctx );
513
513
if (bigDecimalSetScale .matches (mi )) {
514
514
mi = twoArgScale .apply (updateCursor (mi ), mi .getCoordinates ().replaceArguments (),
515
515
mi .getArguments ().get (0 ), "RoundingMode.HALF_UP" );
@@ -550,7 +550,7 @@ void replaceExpressionWithAnotherExpression() {
550
550
rewriteRun (
551
551
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
552
552
@ Override
553
- public J visitUnary (J .Unary unary , ExecutionContext p ) {
553
+ public J visitUnary (J .Unary unary , ExecutionContext ctx ) {
554
554
return JavaTemplate .builder ("#{any()}++" )
555
555
.contextSensitive ()
556
556
.build ().apply (
@@ -585,7 +585,7 @@ void replaceMemberReference() {
585
585
rewriteRun (
586
586
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
587
587
@ Override
588
- public J visitMemberReference (J .MemberReference memberRef , ExecutionContext executionContext ) {
588
+ public J visitMemberReference (J .MemberReference memberRef , ExecutionContext ctx ) {
589
589
return JavaTemplate .builder ("() -> new ArrayList<>(1)" )
590
590
.contextSensitive ()
591
591
.imports ("java.util.ArrayList" )
@@ -624,12 +624,12 @@ void replaceFieldAccessWithMethodInvocation() {
624
624
rewriteRun (
625
625
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
626
626
@ Override
627
- public J visitMethodDeclaration (J .MethodDeclaration method , ExecutionContext p ) {
628
- return method .withBody ((J .Block ) visit (method .getBody (), p ));
627
+ public J visitMethodDeclaration (J .MethodDeclaration method , ExecutionContext ctx ) {
628
+ return method .withBody ((J .Block ) visit (method .getBody (), ctx ));
629
629
}
630
630
631
631
@ Override
632
- public J visitFieldAccess (J .FieldAccess fa , ExecutionContext p ) {
632
+ public J visitFieldAccess (J .FieldAccess fa , ExecutionContext ctx ) {
633
633
if (fa .getSimpleName ().equals ("f" )) {
634
634
return JavaTemplate .apply ("#{any(java.io.File)}.getCanonicalFile().toPath()" ,
635
635
getCursor (), fa .getCoordinates ().replace (), fa );
@@ -705,7 +705,7 @@ void innerEnumWithStaticMethod() {
705
705
rewriteRun (
706
706
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
707
707
@ Override
708
- public J visitNewClass (J .NewClass newClass , ExecutionContext p ) {
708
+ public J visitNewClass (J .NewClass newClass , ExecutionContext ctx ) {
709
709
if (newClass .getArguments ().get (0 ) instanceof J .Empty ) {
710
710
return newClass ;
711
711
}
@@ -774,7 +774,7 @@ void arrayInitializer() {
774
774
final MethodMatcher mm = new MethodMatcher ("abc.ArrayHelper of(..)" );
775
775
776
776
@ Override
777
- public J .MethodInvocation visitMethodInvocation (J .MethodInvocation method , ExecutionContext p ) {
777
+ public J .MethodInvocation visitMethodInvocation (J .MethodInvocation method , ExecutionContext ctx ) {
778
778
if (mm .matches (method )) {
779
779
return JavaTemplate .builder ("Arrays.asList(#{any(java.lang.Integer)}, #{any(java.lang.Integer)}, #{any(java.lang.Integer)})" )
780
780
.imports ("java.util.Arrays" )
@@ -828,8 +828,8 @@ void multiDimensionalArrayInitializer() {
828
828
final MethodMatcher mm = new MethodMatcher ("java.util.stream.IntStream sum()" );
829
829
830
830
@ Override
831
- public J visitNewClass (J .NewClass newClass , ExecutionContext p ) {
832
- J .NewClass nc = (J .NewClass ) super .visitNewClass (newClass , p );
831
+ public J visitNewClass (J .NewClass newClass , ExecutionContext ctx ) {
832
+ J .NewClass nc = (J .NewClass ) super .visitNewClass (newClass , ctx );
833
833
return JavaTemplate .apply ("Integer.valueOf(#{any(java.lang.Integer)}" ,
834
834
getCursor (), nc .getCoordinates ().replace (), nc .getArguments ().get (0 ));
835
835
}
@@ -855,7 +855,7 @@ void dontDropTheAssert() {
855
855
rewriteRun (
856
856
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
857
857
@ Override
858
- public J visitBinary (J .Binary binary , ExecutionContext p ) {
858
+ public J visitBinary (J .Binary binary , ExecutionContext ctx ) {
859
859
J isEmpty = JavaTemplate .apply ("!#{any(java.util.Collection)}.isEmpty()" , getCursor (),
860
860
binary .getCoordinates ().replace (), ((J .MethodInvocation ) binary .getLeft ()).getSelect ());
861
861
return isEmpty .withPrefix (binary .getPrefix ());
@@ -889,7 +889,7 @@ void nestedEnums() {
889
889
rewriteRun (
890
890
spec -> spec .recipe (toRecipe (() -> new JavaVisitor <>() {
891
891
@ Override
892
- public J visitBinary (J .Binary binary , ExecutionContext p ) {
892
+ public J visitBinary (J .Binary binary , ExecutionContext ctx ) {
893
893
return JavaTemplate .builder ("\" ab\" " ).contextSensitive ().build ()
894
894
.apply (getCursor (), binary .getCoordinates ().replace ());
895
895
}
@@ -1199,7 +1199,8 @@ interface Test {
1199
1199
void finalMethodParameter () {
1200
1200
rewriteRun (
1201
1201
spec -> spec .recipe (new ReplaceAnnotation ("@org.jetbrains.annotations.NotNull" , "@lombok.NonNull" , null )),
1202
- java ("""
1202
+ java (
1203
+ """
1203
1204
import org.jetbrains.annotations.NotNull;
1204
1205
1205
1206
class A {
0 commit comments