Skip to content

Commit

Permalink
Remove redundant space for DeleteMethodArgument when argumentIndex=0
Browse files Browse the repository at this point in the history
Signed-off-by: Kun Chang <[email protected]>
  • Loading branch information
ckcd committed Nov 15, 2024
1 parent 58f15f7 commit 57057fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,16 @@ void deleteConstructorArgument() {
)
);
}

@Test
void deleteFirstArgument() {
rewriteRun(
spec -> spec.recipe(new DeleteMethodArgument("B foo(int, int, int)", 0)),
java(b),
java(
"public class A {{ B.foo(0, 1, 2); }}",
"public class A {{ B.foo(1, 2); }}"
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ private MethodCall visitMethodCall(MethodCall methodCall) {
args.remove(argumentIndex);
if (args.isEmpty()) {
args = singletonList(new J.Empty(randomId(), Space.EMPTY, Markers.EMPTY));
} else if (argumentIndex == 0) {
args.set(0, args.get(0).withPrefix(Space.EMPTY));
}

m = m.withArguments(args);
Expand Down

0 comments on commit 57057fd

Please sign in to comment.