Recipe generation should invoke ShortenFullyQualifiedTypeReferences for recipe code itself
Closed this issue · 1 comments
What problem are you trying to solve?
In the generated recipes the lambdas used for matching contain fully qualified type names for all types not contained in java.lang. Examples can be seen in this repository itself (watch for LoggerFactory, Pattern, Primitive):
Describe the solution you'd like
While recipes are generated code, the lambdas would still be more readable for humans trying to debug/understand them. If the template contains multiple expressions or statements, they grow quite quickly anyway. So the TemplateProcessor should run ShortenFullyQualifiedTypeReferences on the generated recipe code before serializing it.
Are you interested in contributing this feature to OpenRewrite?
I can try, but might take a bit of time...
I am not sure it will be worth the effort, since we want to proceed with #57 and thus no longer generate the Java lambdas in the first place, but instead directly generate template code (in Java strings). That will then also not be very readable, but having fully qualified names in the template code help avoid clashes when the template is applied.