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

fix: Add DelegatingRecipe to find underlying recipe for loading options #4286

Merged

Conversation

pstreef
Copy link
Contributor

@pstreef pstreef commented Jun 25, 2024

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.

pstreef added 2 commits June 25, 2024 15:50
…wrappers.

Fixes a problem where RecipeDescriptor does not have the options on it when a recipe has preconditions.
Comment on lines 424 to 426
public abstract static class DelegatingRecipe extends Recipe {
public abstract Recipe getDelegate();
}
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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 {
Copy link
Contributor

@timtebeek timtebeek Jun 27, 2024

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good catch!

@pstreef pstreef requested a review from timtebeek June 28, 2024 06:28
@sambsnyd sambsnyd merged commit 5f8c839 into main Jun 28, 2024
2 checks passed
@sambsnyd sambsnyd deleted the fix/missing-options-in-recipe-descriptor-with-preconditions branch June 28, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants