openrewrite / rewrite-templating

Automated templating using code snippets.
Apache License 2.0
16 stars 7 forks source link

Version 1.7.0 produces non-compilable code #84

Closed Stephan202 closed 5 months ago

Stephan202 commented 5 months ago

See upgrade PR PicnicSupermarket/error-prone-support#1153 for a reproducer. After the upgrade, OpenRewrite generates recipes that contain the statement return SearchResult.found(elem);, without the requisite import org.openrewrite.marker.SearchResult; statement.

I assume that this is caused by 6b9ac4c330a20349ccb5c333d96ff36ed992a5c0 (was this change merged without a PR? :eyes:), but right now I won't have time to dive into the code. (Could try to find some time EOW, but no promises :).)

knutwannheden commented 5 months ago

Thanks for the report! We will look into a fix and create a patch release.

knutwannheden commented 5 months ago

OpenRewrite now allows Refaster rules without after templates. The corresponding recipes are used to find matches in the code base. As you noticed there was a big in the annotation processor. That is now fixed. I assume you were seeing this as you have some Refaster rules without after template on purpose to test that your tooling is robust when it comes to illegal input.

Stephan202 commented 5 months ago

Wow, that was fast :rocket:

I assume you were seeing this as you have some Refaster rules without after template on purpose to test that your tooling is robust when it comes to illegal input.

It was part of test code indeed :smile: (Not about handling invalid inputs (it's valid for a Refaster rule to not have an @AfterTemplate), but as a stand-in for an "arbitrary Refaster rule" to test our test framework.)