From b0a9001c98632ddc0819b9b17d4bff09ad33eb82 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 19 Sep 2024 17:39:40 +0200 Subject: [PATCH] Inline call to MethodMatcher --- .../staticanalysis/RemoveMethodCallVisitor.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openrewrite/staticanalysis/RemoveMethodCallVisitor.java b/src/main/java/org/openrewrite/staticanalysis/RemoveMethodCallVisitor.java index 7aae0e8bd..52e9dd2ad 100644 --- a/src/main/java/org/openrewrite/staticanalysis/RemoveMethodCallVisitor.java +++ b/src/main/java/org/openrewrite/staticanalysis/RemoveMethodCallVisitor.java @@ -45,7 +45,7 @@ public class RemoveMethodCallVisitor

extends JavaIsoVisitor

{ @SuppressWarnings("NullableProblems") @Override public J.@Nullable NewClass visitNewClass(J.NewClass newClass, P p) { - if (matchesMethod(newClass) && predicateMatchesAllArguments(newClass) && isStatementInParentBlock(newClass)) { + if (methodMatcher.matches(newClass) && predicateMatchesAllArguments(newClass) && isStatementInParentBlock(newClass)) { if (newClass.getMethodType() != null) { maybeRemoveImport(newClass.getMethodType().getDeclaringType()); } @@ -58,7 +58,7 @@ public class RemoveMethodCallVisitor

extends JavaIsoVisitor

{ @Override public J.@Nullable MethodInvocation visitMethodInvocation(J.MethodInvocation method, P p) { // Find method invocations that match the specified method and arguments - if (matchesMethod(method) && predicateMatchesAllArguments(method)) { + if (methodMatcher.matches(method) && predicateMatchesAllArguments(method)) { // If the method invocation is a standalone statement, remove it altogether if (isStatementInParentBlock(method)) { if (method.getMethodType() != null) { @@ -76,10 +76,6 @@ public class RemoveMethodCallVisitor

extends JavaIsoVisitor

{ return super.visitMethodInvocation(method, p); } - private boolean matchesMethod(MethodCall method) { - return methodMatcher.matches(method); - } - private boolean predicateMatchesAllArguments(MethodCall method) { for (int i = 0; i < method.getArguments().size(); i++) { if (!argumentPredicate.test(i, method.getArguments().get(i))) {