Skip to content

Commit

Permalink
Inline call to MethodMatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Sep 19, 2024
1 parent 90339bb commit b0a9001
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class RemoveMethodCallVisitor<P> extends JavaIsoVisitor<P> {
@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());
}
Expand All @@ -58,7 +58,7 @@ public class RemoveMethodCallVisitor<P> extends JavaIsoVisitor<P> {
@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) {
Expand All @@ -76,10 +76,6 @@ public class RemoveMethodCallVisitor<P> extends JavaIsoVisitor<P> {
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))) {
Expand Down

0 comments on commit b0a9001

Please sign in to comment.