Skip to content

Commit

Permalink
#3156 = add test and exclusion for main method
Browse files Browse the repository at this point in the history
  • Loading branch information
coiouhkc committed Jun 17, 2023
1 parent 6d87f63 commit 2a27d55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public J.MethodDeclaration visitMethodDeclaration(
if (!method.hasModifier(J.Modifier.Type.Static)) {
shouldPerformChanges.set(false);
}

if (method.getSimpleName().equalsIgnoreCase("main")) {
shouldPerformChanges.set(false);
}
return super.visitMethodDeclaration(method, shouldPerformChanges);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* - abstract classes
* - instantiations of changed classes
* - constructor
* - public static void main
*/
class LombokUtilityClassTest implements RewriteTest {

Expand Down Expand Up @@ -237,6 +236,21 @@ public int add(final int x, final int y) {
);
}

@Test
void givenMain() {
rewriteRun(
recipeSpec -> recipeSpec.recipe(new LombokUtilityClass()),
java(
"""
public class A {
public static void main(String[] args) {
}
}
"""
)
);
}

}

@Test
Expand Down

0 comments on commit 2a27d55

Please sign in to comment.