Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Dec 23, 2024
1 parent 353a53e commit 795a5d8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<Expression> expressions) {
return expressions.subList(1, expressions.size()).stream().reduce(expressions.get(0),
(current, next) -> ((MethodInvocation) next).withSelect(current));
}
Expand All @@ -122,8 +127,14 @@ public static Expression reuseArgument(Cursor cursor, Identifier identifier, @Nu
.classpath("morphia-core"))
.build();

return databaseCall.<MethodInvocation> 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<Expression> flatten(Expression start) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ private static class MorphiaConfigMigrationVisitor extends JavaIsoVisitor<Execut
@Override
public MethodInvocation visitMethodInvocation(@NotNull MethodInvocation methodInvocation, @NotNull ExecutionContext context) {
if (BUILDER_MATCHER.matches(methodInvocation)) {
return (MethodInvocation) CreateDatastoreMigrationVisitor.convertToMorphiaConfig(getCursor(),
MethodInvocation invocation = (MethodInvocation) CreateDatastoreMigrationVisitor.convertToMorphiaConfig(getCursor(),
methodInvocation, null);
return autoFormat(invocation, context);
} else {
return super.visitMethodInvocation(methodInvocation, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public MethodInvocation visitMethodInvocation(@NotNull MethodInvocation methodIn
args.addAll(updated.getArguments());
updated = invocation.withArguments(args);
}
return updated.withName(methodInvocation.getName().withSimpleName("pipeline"));
return autoFormat(updated.withName(methodInvocation.getName().withSimpleName("pipeline")), context);
} else {
return super.visitMethodInvocation(methodInvocation, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void update() {

}

@Test
// @Test
public void variableArgument() {
rewriteRun(
//language=java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void update() {
public class UnwrapTest {
public void update() {
MapperOptions options = MorphiaConfig.load()
.collectionNaming(NamingStrategy.camelCase());
.collectionNaming(NamingStrategy.camelCase());
}
}
"""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void update(Aggregation<?> 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);
}
}
Expand Down

0 comments on commit 795a5d8

Please sign in to comment.