-
Notifications
You must be signed in to change notification settings - Fork 365
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
fix: Add DelegatingRecipe to find underlying recipe for loading options #4286
fix: Add DelegatingRecipe to find underlying recipe for loading options #4286
Conversation
…wrappers. Fixes a problem where RecipeDescriptor does not have the options on it when a recipe has preconditions.
public abstract static class DelegatingRecipe extends Recipe { | ||
public abstract Recipe getDelegate(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this is an abstract class rather than an interface? Seems like it could be an interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it extends recipe, which is an abstract class. We could remove the extends ofcourse, but I thought this made more sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the inteface, it looks a little nicer, but it does not force the DelegatingRecipe to be a Recipe itself. Not sure which I like better. What do you think? (see last commit)
@@ -168,7 +168,7 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) { | |||
|
|||
@EqualsAndHashCode(callSuper = false) | |||
@Value | |||
static class BellwetherDecoratedRecipe extends Recipe { | |||
static class BellwetherDecoratedRecipe extends Recipe implements DelegatingRecipe { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should BellwetherDecoratedScanningRecipe
below implement the same interface? Or a DelegatingScanningRecipe
for that part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, good catch!
Fixes a problem where RecipeDescriptor does not have the options on it when a recipe has preconditions.
What's changed?
When a recipe is actually a delegate it can return that delegate to be used in option extraction.
What's your motivation?
Currently a recipe with preconditions will have no options on the descriptors of children
Have you considered any alternatives or workarounds?
Adding a specific check for the Bellwether wrapper, but I think this is cleaner.