You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
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.
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.
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):
rewrite-templating/src/test/resources/template/ShouldAddClasspathRecipes.java
Line 40 in b8b8cd2
rewrite-templating/src/test/resources/template/ShouldAddClasspathRecipes.java
Line 46 in b8b8cd2
rewrite-templating/src/test/resources/template/ShouldAddClasspathRecipes.java
Line 53 in b8b8cd2
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...
The text was updated successfully, but these errors were encountered: