Skip to content

Commit

Permalink
Adjust FindMethods recipe for new MethodCalls.Row constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Aug 21, 2023
1 parent 2989d87 commit 5ec34c7
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/main/java/org/openrewrite/analysis/search/FindMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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()));
Expand All @@ -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(),
"<constructor>",
newClass.getArguments().stream()
.map(Expression::getType)
.map(String::valueOf)
.collect(Collectors.joining(", "))
));
}
n = SearchResult.found(n);
Expand Down

0 comments on commit 5ec34c7

Please sign in to comment.