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

traverse recipes to leaf nodes first before checking type in order to handle composite recipes #189

Merged
merged 1 commit into from
Jun 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ protected ResultsContainer listResults() throws MojoExecutionException {
}

private void discoverRecipeTypes(Recipe recipe, Set<Class<?>> recipeTypes) {
for (Recipe next : recipe.getRecipeList()) {
discoverRecipeTypes(next, recipeTypes);
}

try {
Method getVisitor = recipe.getClass().getDeclaredMethod("getVisitor");
getVisitor.setAccessible(true);
Expand All @@ -354,9 +358,6 @@ private void discoverRecipeTypes(Recipe recipe, Set<Class<?>> recipeTypes) {
} else if (visitor instanceof YamlVisitor) {
recipeTypes.add(YamlVisitor.class);
}
for (Recipe next : recipe.getRecipeList()) {
discoverRecipeTypes(next, recipeTypes);
}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {
// not every recipe will implement getVisitor() directly, e.g. CompositeRecipe.
}
Expand Down