Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesRabauer committed Feb 2, 2024
1 parent 2f08c60 commit 07673dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
7 changes: 7 additions & 0 deletions spring-data-eclipse-store-migration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@
<artifactId>rewrite-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.11</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.openrewrite.java.JavaTemplate;
import org.openrewrite.java.tree.J;


public class AddAnnotationToOtherAnnotation extends Recipe
{

Expand Down Expand Up @@ -83,8 +84,8 @@ public String getDescription()
@Override
public TreeVisitor<?, ExecutionContext> 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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 07673dd

Please sign in to comment.