Skip to content

Commit f95d7a1

Browse files
committed
Fix ConstructorBindingHelper
1 parent 86c73d8 commit f95d7a1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.openrewrite.ExecutionContext;
2020
import org.openrewrite.TreeVisitor;
2121
import org.openrewrite.internal.lang.Nullable;
22+
import org.openrewrite.java.search.UsesType;
2223
import org.openrewrite.java.spring.boot3.RemoveConstructorBindingAnnotation;
2324
import org.openrewrite.java.tree.J;
2425
import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection;
@@ -29,15 +30,12 @@
2930

3031
import java.util.List;
3132
import java.util.Map;
33+
import java.util.stream.Collectors;
3234

3335

3436
public class ConstructorBindingHelper implements SpringBootUpgradeReportSection.Helper<List<String>> {
3537

36-
private static class ConstructorBindingAnnotationDetector extends RemoveConstructorBindingAnnotation {
37-
public @Nullable TreeVisitor<?, ExecutionContext> getSingleSourceApplicableTest() {
38-
return super.getSingleSourceApplicableTest();
39-
}
40-
}
38+
private List<String> constructorBindingFiles;
4139

4240
@Override
4341
public String getDescription() {
@@ -47,21 +45,23 @@ public String getDescription() {
4745
@Override
4846
public boolean evaluate(ProjectContext context) {
4947

50-
ConstructorBindingAnnotationDetector constructorBindingAnnotationDetector =
51-
new ConstructorBindingAnnotationDetector();
52-
53-
TreeVisitor<?, ExecutionContext> testVisitor =
54-
constructorBindingAnnotationDetector.getSingleSourceApplicableTest();
5548
GenericOpenRewriteRecipe<TreeVisitor<?, ExecutionContext>> recipe =
56-
new GenericOpenRewriteRecipe<>(() -> testVisitor);
49+
new GenericOpenRewriteRecipe<>(() -> new UsesType("org.springframework.boot.context.properties.ConstructorBinding"));
5750

58-
List<RewriteSourceFileHolder<J.CompilationUnit>> rewriteSourceFileHolders = context.getProjectJavaSources().find(recipe);
51+
List<RewriteSourceFileHolder<J.CompilationUnit>> rewriteSourceFileHolders =
52+
context.getProjectJavaSources().find(recipe);
53+
54+
constructorBindingFiles = rewriteSourceFileHolders
55+
.stream()
56+
.map(k -> k.getAbsolutePath().toString())
57+
.collect(Collectors.toList());
5958

6059
return !rewriteSourceFileHolders.isEmpty();
6160
}
6261

6362
@Override
6463
public Map<String, List<String>> getData(ProjectContext context) {
65-
return null;
64+
65+
return Map.of("files", constructorBindingFiles);
6666
}
6767
}

0 commit comments

Comments
 (0)