rewrite-spring icon indicating copy to clipboard operation
rewrite-spring copied to clipboard

Datatable not correct for find spring components?

Open Jenson3210 opened this issue 1 year ago • 1 comments

Not sure if this is a bug or expected behaviour.

when we run find spring components recipe, we get the results back of all @Bean annotated methods. However, some/all these beans that are marked with @bean are not added to the datatables of the results it seems. Classes with @Component or extensions are shown correctly it seems.

  1. Using a codebase without classes marked with @Component
  2. Running the recipe org.openrewrite.java.spring.search.FindSpringComponents
  3. See there are results

Screenshot 2024-09-23 at 10 05 08

  1. See details of results Screenshot 2024-09-23 at 10 05 25

  2. See that only one of the datables is available (as no bean's through component annotation?) Screenshot 2024-09-23 at 10 05 35

  3. The available datatable contains the correct rows Screenshot 2024-09-23 at 10 06 39

EXPECTED: Also the other table should contain the beans identified.

Jenson3210 avatar Sep 23 '24 08:09 Jenson3210

Here only the addition to one of the 2 datatables is happening: this line https://github.com/openrewrite/rewrite-spring/blob/0af9942357688f00147743762dcdf9680bf34bab/src/main/java/org/openrewrite/java/spring/search/FindSpringComponents.java#L77

Should be sufficient to add

springComponents.insertRow(ctx, new SpringComponents.Row(getCursor().firstEnclosingOrThrow(SourceFile.class).getSourcePath().toString(), TypeUtils.asFullyQualified(requireNonNull(m.getReturnTypeExpression()).getType())));

We can provide PR once it is indicated that would indeed be "expected"/wanted

Jenson3210 avatar Sep 23 '24 09:09 Jenson3210