Skip to content

Commit 2b647c6

Browse files
committed
minor polish
1 parent cab227b commit 2b647c6

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

src/main/java/org/openrewrite/java/migrate/lombok/SummarizeGetter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 the original author or authors.
2+
* Copyright 2024 the original author or authors.
33
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ public class SummarizeGetter extends Recipe {
3333

3434
@Override
3535
public String getDisplayName() {
36-
//language=markdown
3736
return "Summarize @Getter on fields to class level annotation";
3837
}
3938

@@ -100,6 +99,7 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations v
10099
}
101100

102101
private J.VariableDeclarations fixFormat(J.VariableDeclarations initial, J.VariableDeclarations visited, ExecutionContext ctx) {
102+
//as of August 2024 manual fixes to the format are necessary. Hopefully in the future this method becomes obsolete
103103

104104
boolean isAnnotationOnLineAbove = initial.toString().contains("@Getter\n");
105105

@@ -121,8 +121,8 @@ public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ct
121121
&& annotation.getArguments() == null //no Access level, or other arguments
122122
//should only trigger on field annotation, not class annotation
123123
&& getCursor().getParent().getValue() instanceof J.VariableDeclarations
124-
? null
125-
: annotation;
124+
? null // -> delete
125+
: annotation; // -> keep
126126
}
127127
}
128128
}

src/main/java/org/openrewrite/java/migrate/lombok/SummarizeSetter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 the original author or authors.
2+
* Copyright 2024 the original author or authors.
33
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ public class SummarizeSetter extends Recipe {
3333

3434
@Override
3535
public String getDisplayName() {
36-
//language=markdown
3736
return "Summarize @Setter on fields to class level annotation";
3837
}
3938

@@ -104,6 +103,7 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations v
104103
}
105104

106105
private J.VariableDeclarations fixFormat(J.VariableDeclarations initial, J.VariableDeclarations visited, ExecutionContext ctx) {
106+
//as of August 2024 manual fixes to the format are necessary. Hopefully in the future this method becomes obsolete
107107

108108
boolean isAnnotationOnLineAbove = initial.toString().contains("@Setter\n");
109109

@@ -127,8 +127,8 @@ public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ct
127127
return isSetterAnnotated
128128
//should only trigger on field annotation, not class annotation
129129
&& getCursor().getParent().getValue() instanceof J.VariableDeclarations
130-
? null
131-
: annotation;
130+
? null // -> delete
131+
: annotation; // -> keep
132132
}
133133
}
134134
}

src/test/java/org/openrewrite/java/migrate/lombok/SummarizeGetterTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 the original author or authors.
2+
* Copyright 2024 the original author or authors.
33
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,22 +17,16 @@
1717

1818
import org.junit.jupiter.api.Test;
1919
import org.openrewrite.DocumentExample;
20-
import org.openrewrite.java.JavaParser;
2120
import org.openrewrite.test.RecipeSpec;
2221
import org.openrewrite.test.RewriteTest;
2322

2423
import static org.openrewrite.java.Assertions.java;
2524

26-
// This is a test for the ConvertToNoArgsConstructor recipe, as an example of how to write a test for an imperative recipe.
2725
class SummarizeGetterTest implements RewriteTest {
2826

29-
// Note, you can define defaults for the RecipeSpec and these defaults will be used for all tests.
30-
// In this case, the recipe and the parser are common. See below, on how the defaults can be overridden
31-
// per test.
3227
@Override
3328
public void defaults(RecipeSpec spec) {
34-
spec.recipe(new SummarizeGetter())
35-
.parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("lombok"));
29+
spec.recipe(new SummarizeGetter());
3630
}
3731

3832
@DocumentExample

src/test/java/org/openrewrite/java/migrate/lombok/SummarizeSetterTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 the original author or authors.
2+
* Copyright 2024 the original author or authors.
33
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,22 +17,16 @@
1717

1818
import org.junit.jupiter.api.Test;
1919
import org.openrewrite.DocumentExample;
20-
import org.openrewrite.java.JavaParser;
2120
import org.openrewrite.test.RecipeSpec;
2221
import org.openrewrite.test.RewriteTest;
2322

2423
import static org.openrewrite.java.Assertions.java;
2524

26-
// This is a test for the ConvertToNoArgsConstructor recipe, as an example of how to write a test for an imperative recipe.
2725
class SummarizeSetterTest implements RewriteTest {
2826

29-
// Note, you can define defaults for the RecipeSpec and these defaults will be used for all tests.
30-
// In this case, the recipe and the parser are common. See below, on how the defaults can be overridden
31-
// per test.
3227
@Override
3328
public void defaults(RecipeSpec spec) {
34-
spec.recipe(new SummarizeSetter())
35-
.parser(JavaParser.fromJavaVersion().logCompilationWarningsAndErrors(true).classpath("lombok"));
29+
spec.recipe(new SummarizeSetter());
3630
}
3731

3832
@DocumentExample

0 commit comments

Comments
 (0)