-
Notifications
You must be signed in to change notification settings - Fork 360
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
Creating "OR" preconditions instead of "AND" (#4003) does not actually work #4505
Creating "OR" preconditions instead of "AND" (#4003) does not actually work #4505
Conversation
Includes the example from the documentation.
Very much appreciated! Had this in the back of my mind still, but didn't quite get to writing the tests and giving them a try. Indeed this ought to work as described, as that's a nice simplification where possible. Did you already explore what might be the cause? I wonder if the |
I did some debugging which I described in the "what changed" section. I don't know what would be an appropriate solution though. Did it ever work? |
Thanks a lot @DidierLoiseau ; I've pushed up a change that fixes the tests you've provided. 🙏🏻 |
Amazing! Thanks for your reactivity as well! I should be able to try it out next week. However, as I am using the Maven plugin from the command-line, and it seems I can’t override the version of the rewrite modules used by the plugin without adding it to the pom (I’m using it with |
I've just kicked off a build (not yet release) of the rewrite-maven-plugin: That should produce a snapshot version that uses the latest from openrewrite/rewrite. Ideally that's enough to try this out before the scheduled release next Wednesday. 🤞🏻 |
What's changed?
Adds 2 failing tests using declarative recipes as preconditions.
Based on Creating "OR" preconditions instead of "AND", you should be able to use a declarative recipe as a precondition to combine recipes into an “or” clause, but it does not actually work.
Upon debugging, it appears that
DeclarativeRecipe
does not actually overridegetVisitor()
, so whenDeclarativeRecipe.getRecipeList()
callsgetVisitor()
on the declarative recipe used as precondition, it just returnsnoop()
.What's your motivation?
Be able to re-use a configured recipe as precondition for other recipes.
Anything in particular you'd like reviewers to focus on?
or
association #4003 this use-case was documented and later reported as not working.Anyone you would like to review specifically?
#4003 involved a discussion mostly between @timtebeek and @nmck257 who might be interested.
Have you considered any alternatives or workarounds?
Currently the only alternative is to repeat the predicate configuration, using only imperative recipes. If you need a disjunction of conditions, you will have to duplicate the whole recipe, but it may not always work.
Checklist