openrewrite / rewrite-templating

Automated templating using code snippets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Limit `doAfterVisit(UnnecessaryParenthesesVisitor)` to `afterTemplate` `lstType`s that need it

timtebeek opened this issue · comments

What problem are you trying to solve?

Performance & usability improvement:

  • No longer require folks to add parentheses to after templates, by adding these in for certain types
  • No longer run doAfterVisit(UnnecessaryParenthesesVisitor) after every replacement, for performance improvements and less unwanted parentheses removals

Describe the solution you'd like

Insert parentheses around binaries, ternaries, assignments and casts.
Only add doAfterVisit(UnnecessaryParenthesesVisitor) for respective types.

Have you considered any alternatives or workarounds?

We could move this into the JavaTemplate, but that's harder to modify without side-effects than this generator.

Additional context

As of #63 we limit when we add the visitor to remove parens