Skip to content

Commit

Permalink
Adjust RefasterTemplateProcessor for new JavaTemplate API
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Jun 1, 2023
1 parent e970ef4 commit fb8089b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ public void visitClassDef(JCTree.JCClassDecl classDecl) {
recipe.append(" }\n");
}
recipe.append(" JavaTemplate.Matcher matcher;\n");
String predicate = befores.keySet().stream().map(b -> "(matcher = " + b + ".matcher(elem)).find()").collect(Collectors.joining(" || "));
String predicate = befores.keySet().stream().map(b -> "(matcher = " + b + ".matcher(getCursor())).find()").collect(Collectors.joining(" || "));
recipe.append(" if (" + predicate + ") {\n");
if (parameters.isEmpty()) {
recipe.append(" return elem.withTemplate(" + after + ", getCursor(), elem.getCoordinates().replace());\n");
recipe.append(" return " + after + ".apply(getCursor(), elem.getCoordinates().replace());\n");
} else {
recipe.append(" return elem.withTemplate(" + after + ", getCursor(), elem.getCoordinates().replace(), " + parameters + ");\n");
recipe.append(" return " + after + ".apply(getCursor(), elem.getCoordinates().replace(), " + parameters + ");\n");
}
recipe.append(" }\n");
recipe.append(" return super.visit" + methodSuffix + "(elem, ctx);\n");
Expand Down

0 comments on commit fb8089b

Please sign in to comment.