Skip to content

Commit

Permalink
#3156 = do not transform abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
coiouhkc committed Jun 17, 2023
1 parent 28581b0 commit acb5cf5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public J.ClassDeclaration visitClassDeclaration(
final J.ClassDeclaration classDecl,
final AtomicBoolean shouldPerformChanges
) {
if (classDecl.hasModifier(J.Modifier.Type.Abstract)) {
shouldPerformChanges.set(false);
}
if (classDecl.getLeadingAnnotations().stream().anyMatch(a -> "UtilityClass".equals(a.getSimpleName()))) {
shouldPerformChanges.set(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* - Interfaces
* - Empty classes & interfaces
* - inheritance
* - abstract classes
* - instantiations of changed classes
* - constructor
*/
Expand Down Expand Up @@ -266,6 +265,21 @@ public static void main(String[] args) {
);
}

@Test
void givenAbstractClass() {
rewriteRun(
recipeSpec -> recipeSpec.recipe(new LombokUtilityClass()),
java(
"""
public abstract class A {
public static void doSmth() {
};
}
"""
)
);
}

}

@Test
Expand Down

0 comments on commit acb5cf5

Please sign in to comment.