Adopt Rewrite snapshots. Upgrade antlr to 4.11

This commit is contained in:
aboyko
2023-02-07 14:01:58 -05:00
parent e2134dd186
commit 3a337427ac
12 changed files with 159 additions and 90 deletions

View File

@@ -309,7 +309,11 @@ public class RewriteRecipeRepository implements ApplicationContextAware {
for (RecipeCodeActionDescriptor d : descriptors) {
TreeVisitor<?, ExecutionContext> markVisitor = d.getMarkerVisitor(applicationContext);
if (markVisitor != null) {
cu = (CompilationUnit) markVisitor.visit(cu, new InMemoryExecutionContext(e -> log.error("Marker visitor failed!", e)));
try {
cu = (CompilationUnit) markVisitor.visit(cu, new InMemoryExecutionContext(e -> log.error("Marker visitor failed!", e)));
} catch (Exception e) {
// ignore - would happen in sources with compiler errors
}
}
}
return cu;

View File

@@ -110,13 +110,13 @@ public class SpringBootUpgrade {
String recipeId = recipedIds.get(recipedIds.size() - 1);
// TODO: Review after new rewrite adoption
// Special case is UpgradeSpringBoot_3_0 which doesn't upgrade project to the latest 2.x if necessary. Therefore add 2.(latest) recipe (it chains all previous 2.x)
if (targetVersion.getMajor() == 3) {
int i = recipedIds.size() - 1;
for (; i>=0 && !getVersionFromRecipeId(recipedIds.get(i)).startsWith("2."); i--) {}
if (i >= 0) {
getRecipeFromId(recipedIds.get(i)).ifPresent(recipe::doNext);
}
}
// if (targetVersion.getMajor() == 3) {
// int i = recipedIds.size() - 1;
// for (; i>=0 && !getVersionFromRecipeId(recipedIds.get(i)).startsWith("2."); i--) {}
// if (i >= 0) {
// getRecipeFromId(recipedIds.get(i)).ifPresent(recipe::doNext);
// }
// }
getRecipeFromId(recipeId).ifPresent(recipe::doNext);
}
}