Skip to content

Commit

Permalink
traverse recipes to leaf nodes first before checking type in order to…
Browse files Browse the repository at this point in the history
… handle composite recipes
  • Loading branch information
aegershman authored and jkschneider committed Jun 30, 2021
1 parent a68c947 commit 2763494
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 2763494

Please sign in to comment.