diff --git a/spring-data-eclipse-store-migration/pom.xml b/spring-data-eclipse-store-migration/pom.xml index 4ebe921..cc8cedf 100644 --- a/spring-data-eclipse-store-migration/pom.xml +++ b/spring-data-eclipse-store-migration/pom.xml @@ -141,6 +141,13 @@ rewrite-test test + + org.slf4j + slf4j-simple + 2.0.11 + test + + diff --git a/spring-data-eclipse-store-migration/src/main/java/software/xdev/spring/data/eclipse/store/AddAnnotationToOtherAnnotation.java b/spring-data-eclipse-store-migration/src/main/java/software/xdev/spring/data/eclipse/store/AddAnnotationToOtherAnnotation.java index 43c86d7..3ee26b0 100644 --- a/spring-data-eclipse-store-migration/src/main/java/software/xdev/spring/data/eclipse/store/AddAnnotationToOtherAnnotation.java +++ b/spring-data-eclipse-store-migration/src/main/java/software/xdev/spring/data/eclipse/store/AddAnnotationToOtherAnnotation.java @@ -27,6 +27,7 @@ import org.openrewrite.java.JavaTemplate; import org.openrewrite.java.tree.J; + public class AddAnnotationToOtherAnnotation extends Recipe { @@ -83,8 +84,8 @@ public String getDescription() @Override public TreeVisitor getVisitor() { - final AnnotationMatcher EXISTING_ANNOTATION_MATCHER = new AnnotationMatcher(this.existingAnnotationType); - final AnnotationMatcher NEW_ANNOTATION_MATCHER = new AnnotationMatcher(this.annotationTypeToAdd); + final AnnotationMatcher existingAnnotationMatcher = new AnnotationMatcher(this.existingAnnotationType); + final AnnotationMatcher newAnnotationMatcher = new AnnotationMatcher(this.annotationTypeToAdd); return new JavaIsoVisitor<>() { @Override @@ -95,17 +96,17 @@ public J.ClassDeclaration visitClassDeclaration( final J.ClassDeclaration cd = super.visitClassDeclaration(classDecl, executionContext); if( - cd.getAnnotations() == null || - cd.getLeadingAnnotations() - .stream() - .filter(annotation -> EXISTING_ANNOTATION_MATCHER.matches(annotation)) - .findAny() - .isEmpty() || - cd.getLeadingAnnotations() - .stream() - .filter(annotation -> NEW_ANNOTATION_MATCHER.matches(annotation)) - .findAny() - .isPresent() + cd.getAnnotations() == null + || cd.getLeadingAnnotations() + .stream() + .filter(annotation -> existingAnnotationMatcher.matches(annotation)) + .findAny() + .isEmpty() + || cd.getLeadingAnnotations() + .stream() + .filter(annotation -> newAnnotationMatcher.matches(annotation)) + .findAny() + .isPresent() ) { return cd; diff --git a/spring-data-eclipse-store-migration/src/main/resources/META-INF/rewrite/rewrite.yml b/spring-data-eclipse-store-migration/src/main/resources/META-INF/rewrite/rewrite.yml index f8ae837..718b462 100644 --- a/spring-data-eclipse-store-migration/src/main/resources/META-INF/rewrite/rewrite.yml +++ b/spring-data-eclipse-store-migration/src/main/resources/META-INF/rewrite/rewrite.yml @@ -40,5 +40,3 @@ recipeList: - org.openrewrite.java.RemoveAnnotation: # https://docs.openrewrite.org/reference/method-patterns annotationPattern: '@org.springframework.data.jpa.repository.Query *(..)' - - - org.openrewrite.java.RemoveUnusedImports