Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite 8.0 migration recipes #3241

Merged
merged 24 commits into from
May 16, 2023
Merged

Rewrite 8.0 migration recipes #3241

merged 24 commits into from
May 16, 2023

Conversation

kunli2
Copy link
Contributor

@kunli2 kunli2 commented May 13, 2023

Recipe to migrate rewrite 8.
ticket: #3234
These recipes have been tested on repo rewrite-static-analysis (branch) which is before the rewrite8 migration.

This PR covers below features

  • 1. getVisitor() to public
  • 2. single source applicability test to Preconditions
    • Includes potentially changing return type of getVisitor() to TreeVisitor<?, ExecutionContext>, because that is what Preconditions returns
  • 3. Add a comment with a link to our migration documentation (to be written) to classes which use non-single source applicability tests
  • 4. Add a comment with a link to our migration documentation to classes which override Recipe.visit(List)
  • 5. replace removed JavaSourceFile visitJavaSourceFile(JavaSourceFile cu, ExecutionContext ctx) to J visit(@Nullable Tree tree, ExecutionContext ctx)
  • 6. Applicability.of() -> Preconditions.of(), and Applicability.and() -> Preconditions.and()
  • 7. For YAML recipes using applicability tests I think we should comment the lines out and add a marker / comment which makes it clear that this is no longer supported and requires migrating the recipe to Java code
  • 8. Migrate both imperative and declarative recipes referencing the recipes which were moved to rewrite-static-analysis
  • 9. The JavaTemplate.Builder#javaParser(Supplier<JavaParser>) method no longer exists. Jonathan created a recipe to migrate it to JavaTemplate.Builder#javaParser(JavaParser.Builder), but I think that recipe needs to be extended a bit, in case the Supplier<JavaParser> is represented by a variable or field
  • 10. TreeVisitor.doNext(..) is removed, leave a comment to replace with TreeVisitor.doAfterVisit(..) or follow the instruction.
  • 11. For unit test, change spec.recipe(X.doNext(Y)) to spec.recipes(X, Y)
  • 12. org.openrewrite.marker.Markers#SearchResult() and org.openrewrite.marker.Markers.searchResult(@Nullable String description) are deprecated and removed, use SearchResult.found() instead.
  • 13. Gradle ChangeJavaCompatibility was renamed to UpdateJavaCompatibility with slightly different arguments in Feature/gradle/enhance update java compatibility #3238 not sure whether it should be part of rewrite 8 migration

@kunli2 kunli2 changed the title Kunli/rewrite8 migrate Rewrite8 migrate recipes May 13, 2023
@timtebeek timtebeek changed the title Rewrite8 migrate recipes Rewrite 8.0 migration recipes May 16, 2023
@timtebeek timtebeek added the recipe Requested Recipe label May 16, 2023
@jsoref
Copy link
Contributor

jsoref commented May 16, 2023

org.openrewrite.java.spring.boot2.MigrateHibernateContraintsToJavax to org.openrewrite.java.spring.boot2.MigrateHibernateConstraintsToJavax

@kunli2 kunli2 merged commit a82248c into main May 16, 2023
@kunli2 kunli2 deleted the kunli/rewrite8-migrate branch May 16, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Requested Recipe
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants