From 795a5d81b840f440239653c44355de63d70f5a27 Mon Sep 17 00:00:00 2001 From: evanchooly Date: Sun, 22 Dec 2024 21:07:32 -0500 Subject: [PATCH] version bump --- .mvn/wrapper/maven-wrapper.properties | 2 +- .../recipes/CreateDatastoreMigration.java | 19 +++++++++++++++---- .../recipes/MorphiaConfigMigration.java | 3 ++- .../rewrite/recipes/PipelineRewrite.java | 2 +- .../test/CreateDatastoreMigrationTest.java | 2 +- .../test/MorphiaConfigMigrationTest.java | 2 +- .../recipes/test/PipelineRewriteTest.java | 2 +- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 72d6eaa6529..7d86f1f3b85 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/4.0.0-beta-3/apache-maven-4.0.0-beta-3-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/4.0.0-beta-3/apache-maven-4.0.0-beta-5-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar diff --git a/rewrite/src/main/java/dev/morphia/rewrite/recipes/CreateDatastoreMigration.java b/rewrite/src/main/java/dev/morphia/rewrite/recipes/CreateDatastoreMigration.java index ddc61809e71..72bfe99cb2d 100644 --- a/rewrite/src/main/java/dev/morphia/rewrite/recipes/CreateDatastoreMigration.java +++ b/rewrite/src/main/java/dev/morphia/rewrite/recipes/CreateDatastoreMigration.java @@ -20,6 +20,7 @@ import org.openrewrite.java.tree.Expression; import org.openrewrite.java.tree.J.Identifier; import org.openrewrite.java.tree.J.MethodInvocation; +import org.openrewrite.java.tree.JavaType; import static java.util.List.of; import static org.openrewrite.java.tree.JavaType.buildType; @@ -72,7 +73,7 @@ public MethodInvocation visitMethodInvocation(@NotNull MethodInvocation methodIn buildType(NEW_TYPE)))) .withArguments( of(arguments.get(0), convertToMorphiaConfig(getCursor(), options, databaseName))); - return maybeAutoFormat(methodInvocation, after, context); + return autoFormat(after, context); } catch (RuntimeException e) { System.out.println("methodInvocation = " + methodInvocation); throw e; @@ -110,7 +111,11 @@ public static Expression convertToMorphiaConfig(Cursor cursor, Expression builde expressions.set(0, applied); expressions.remove(1); - expressions.removeIf(e -> e instanceof MethodInvocation mi && mi.getSimpleName().equals("build")); + + return rechain(expressions); + } + + private static Expression rechain(List expressions) { return expressions.subList(1, expressions.size()).stream().reduce(expressions.get(0), (current, next) -> ((MethodInvocation) next).withSelect(current)); } @@ -122,8 +127,14 @@ public static Expression reuseArgument(Cursor cursor, Identifier identifier, @Nu .classpath("morphia-core")) .build(); - return databaseCall. apply(new Cursor(cursor, identifier), - identifier.getCoordinates().replace(), databaseName); + return databaseCall.apply(new Cursor(cursor, identifier), + identifier.getCoordinates().replace(), databaseName); + } + + private static Expression updateIdentifierType(Expression expression) { + var flattened = flatten(expression); + flattened.set(0, flattened.get(0).withType(JavaType.buildType(NEW_TYPE))); + return rechain(flattened); } private static @NotNull ArrayList flatten(Expression start) { diff --git a/rewrite/src/main/java/dev/morphia/rewrite/recipes/MorphiaConfigMigration.java b/rewrite/src/main/java/dev/morphia/rewrite/recipes/MorphiaConfigMigration.java index 9eefb932f31..75336b05ab8 100644 --- a/rewrite/src/main/java/dev/morphia/rewrite/recipes/MorphiaConfigMigration.java +++ b/rewrite/src/main/java/dev/morphia/rewrite/recipes/MorphiaConfigMigration.java @@ -37,8 +37,9 @@ private static class MorphiaConfigMigrationVisitor extends JavaIsoVisitor aggregation) { public class UnwrapTest { public void update(Aggregation aggregation) { aggregation - .pipeline(group(id("author")).field("count", sum(value(1))),sort().ascending("1"),sort().ascending("2"),sort().ascending("3"),sort().ascending("4")) + .pipeline(group(id("author")).field("count", sum(value(1))), sort().ascending("1"), sort().ascending("2"), sort().ascending("3"), sort().ascending("4")) .execute(Document.class); } }