Skip to content

Commit

Permalink
update deps for downstream ease
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Dec 15, 2024
1 parent 85ebe88 commit 40ff4c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion rewrite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
<groupId>dev.morphia.morphia</groupId>
<artifactId>morphia-core</artifactId>
<version>${morphia.prior.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Collections;
import java.util.List;

import javax.annotation.Nullable;

import org.jetbrains.annotations.NotNull;
import org.openrewrite.Cursor;
import org.openrewrite.ExecutionContext;
Expand All @@ -19,8 +21,6 @@
import org.openrewrite.java.tree.J.Identifier;
import org.openrewrite.java.tree.J.MethodInvocation;

import javax.annotation.Nullable;

import static java.util.List.of;
import static org.openrewrite.java.tree.JavaType.buildType;

Expand Down Expand Up @@ -73,12 +73,12 @@ public MethodInvocation visitMethodInvocation(@NotNull MethodInvocation methodIn

public static Expression convertToMorphiaConfig(Cursor cursor, Expression builder, @Nullable Expression databaseName) {
JavaTemplate databaseCall = (databaseName != null
? JavaTemplate.builder("MorphiaConfig.load().database(#{})")
:JavaTemplate.builder("MorphiaConfig.load()"))
.javaParser(JavaParser.fromJavaVersion()
.classpath("morphia-core"))
.imports(NEW_TYPE)
.build();
? JavaTemplate.builder("MorphiaConfig.load().database(#{})")
: JavaTemplate.builder("MorphiaConfig.load()"))
.javaParser(JavaParser.fromJavaVersion()
.classpath("morphia-core"))
.imports(NEW_TYPE)
.build();

Cursor scope = new Cursor(cursor, builder);
MethodInvocation applied;
Expand All @@ -92,8 +92,7 @@ public static Expression convertToMorphiaConfig(Cursor cursor, Expression builde

expressions.set(0, applied);
expressions.remove(1);
expressions.removeIf(
expression -> expression instanceof MethodInvocation invocation && invocation.getSimpleName().equals("build"));
expressions.removeIf(e -> e instanceof MethodInvocation mi && mi.getSimpleName().equals("build"));
return expressions.subList(1, expressions.size()).stream().reduce(expressions.get(0),
(current, next) -> ((MethodInvocation) next).withSelect(current));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.morphia.rewrite.recipes;

import dev.morphia.rewrite.recipes.CreateDatastoreMigration.CreateDatastoreMigrationVisitor;

import org.jetbrains.annotations.NotNull;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Preconditions;
Expand Down

0 comments on commit 40ff4c1

Please sign in to comment.