From 7560861ca1d0a8c875e88a120fed3e0a6b3552ed Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 14 Oct 2024 11:59:39 +0200 Subject: [PATCH] Pass parent cursor into `.visit()` calls Following https://github.com/openrewrite/rewrite/commit/f50d4aee6586807d4aa5393e49906b0bb61cdc3c --- .../MigrateInstantiationAwareBeanPostProcessorAdapter.java | 2 +- ...MigrateInstantiationAwareBeanPostProcessorAdapterTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java b/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java index 0cfa112df..30e5a51fb 100644 --- a/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java +++ b/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java @@ -53,7 +53,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex J.Identifier ident = new J.Identifier(Tree.randomId(), Space.format(" "), Markers.EMPTY, emptyList(), "SmartInstantiationAwareBeanPostProcessor", JavaType.buildType(toImplementsFqn), null); J.Block body = cd.getBody(); - cd = maybeAutoFormat(cd, cd.withBody(cd.getBody().withStatements(emptyList())).withImplements(ListUtils.concat(cd.getImplements(), ident)), ctx, getCursor()); + cd = maybeAutoFormat(cd, cd.withBody(cd.getBody().withStatements(emptyList())).withImplements(ListUtils.concat(cd.getImplements(), ident)), ctx, getCursor().getParentOrThrow()); cd = cd.withBody(body); } return cd; diff --git a/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java b/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java index ecd1a8dcd..80af241d3 100644 --- a/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java +++ b/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java @@ -39,13 +39,13 @@ void migrateInterface() { java( """ import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; - + class A extends InstantiationAwareBeanPostProcessorAdapter { } """, """ import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor; - + class A implements SmartInstantiationAwareBeanPostProcessor { } """