From 5ec34c7a490f8cb8fb3f5be81e376a818c2e6ac1 Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Mon, 21 Aug 2023 08:27:27 +0200 Subject: [PATCH] Adjust `FindMethods` recipe for new `MethodCalls.Row` constructor --- .../analysis/search/FindMethods.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openrewrite/analysis/search/FindMethods.java b/src/main/java/org/openrewrite/analysis/search/FindMethods.java index ccb836296..4c9579810 100644 --- a/src/main/java/org/openrewrite/analysis/search/FindMethods.java +++ b/src/main/java/org/openrewrite/analysis/search/FindMethods.java @@ -29,6 +29,7 @@ import org.openrewrite.java.MethodMatcher; import org.openrewrite.java.search.UsesMethod; import org.openrewrite.java.table.MethodCalls; +import org.openrewrite.java.tree.Expression; import org.openrewrite.java.tree.J; import org.openrewrite.java.tree.JavaSourceFile; import org.openrewrite.marker.SearchResult; @@ -93,7 +94,13 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu if (javaSourceFile != null) { methodCalls.insertRow(ctx, new MethodCalls.Row( javaSourceFile.getSourcePath().toString(), - method.printTrimmed(getCursor()) + method.printTrimmed(getCursor()), + method.getMethodType().getDeclaringType().getFullyQualifiedName(), + method.getSimpleName(), + method.getArguments().stream() + .map(Expression::getType) + .map(String::valueOf) + .collect(Collectors.joining(", ")) )); } m = SearchResult.found(m); @@ -113,7 +120,13 @@ public J.MemberReference visitMemberReference(J.MemberReference memberRef, Execu if (javaSourceFile != null) { methodCalls.insertRow(ctx, new MethodCalls.Row( javaSourceFile.getSourcePath().toString(), - memberRef.printTrimmed(getCursor()) + memberRef.printTrimmed(getCursor()), + memberRef.getMethodType().getDeclaringType().getFullyQualifiedName(), + memberRef.getMethodType().getName(), + memberRef.getArguments().stream() + .map(Expression::getType) + .map(String::valueOf) + .collect(Collectors.joining(", ")) )); } m = m.withReference(SearchResult.found(m.getReference())); @@ -133,7 +146,13 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) { if (javaSourceFile != null) { methodCalls.insertRow(ctx, new MethodCalls.Row( javaSourceFile.getSourcePath().toString(), - newClass.printTrimmed(getCursor()) + newClass.printTrimmed(getCursor()), + newClass.getType().toString(), + "", + newClass.getArguments().stream() + .map(Expression::getType) + .map(String::valueOf) + .collect(Collectors.joining(", ")) )); } n = SearchResult.found(n);