File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
main/java/org/openrewrite/java/logging
test/java/org/openrewrite/java/logging Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 3434
3535import static java .util .Collections .emptyList ;
3636import static java .util .stream .Collectors .toSet ;
37+ import static org .openrewrite .java .tree .J .Modifier .Type .Abstract ;
3738
3839@ EqualsAndHashCode (callSuper = false )
3940@ Value
@@ -76,7 +77,8 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations m
7677 }
7778
7879 J .ClassDeclaration classDeclaration = parent .getValue ();
79- if (classDeclaration .getKind () == J .ClassDeclaration .Kind .Type .Interface ) {
80+ if (classDeclaration .getKind () == J .ClassDeclaration .Kind .Type .Interface ||
81+ classDeclaration .hasModifier (Abstract )) {
8082 return mv ;
8183 }
8284
Original file line number Diff line number Diff line change @@ -175,6 +175,23 @@ interface Constants {
175175 );
176176 }
177177
178+ @ Test
179+ void loggerInAbstractClassShouldNotChange () {
180+ rewriteRun (
181+ //language=java
182+ java (
183+ """
184+ import org.slf4j.Logger;
185+ import org.slf4j.LoggerFactory;
186+
187+ abstract class Constants {
188+ Logger logger = LoggerFactory.getLogger(Constants.class);
189+ }
190+ """
191+ )
192+ );
193+ }
194+
178195 @ Test
179196 void localVariableLoggerShouldNotChange () {
180197 rewriteRun (
You can’t perform that action at this time.
0 commit comments