-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💡 Make visitors generated by Refastor templates return early where feasible #95
Comments
Hi! Linking a concrete example to get a little wider view on to an example generated visitMethodInvocation rewrite-templating/src/test/resources/refaster/EscapesRecipes.java Lines 99 to 110 in 347af90
If we were to not invoke |
For now I don't immediately see any points at which we could return early, as much as I'd love to be proven wrong. Closing this issue until a concrete example comes in, however much as the idea is appreciated! |
I also think that the generated code for the Refaster recipes is quite readable and easy to adapt. I think that is quite an acceptable workaround. The alternative would be an annotation which would instruct the generator to not generate the super call. What fo you think about that @timtebeek ? As it doesn't really add API surface area, I think that would be OK and if someone is willing to work on it, we could have that solution quite soon. |
What problem are you trying to solve?
Having a simple method migration recipe such as this:
will generate a
visitMethodDeclaration
implementation such as:Describe the solution you'd like
@MBoegers and i were wondering over another review whether it may be feasible to simply
return elem;
instead, leading to increased performance as the visitation of the method contents would be skipped.Not sure if i'm overlooking something here (maybe anonymous classes within the method body?) but i believe it's worth contemplating as this notion applies to all visitors generated by refastor templates.
Have you considered any alternatives or workarounds?
Apart from hand-coding the recipes instead (which would violate the „If it can be declarative, it should be declarative“-convention, nothing comes to mind.
Are you interested in contributing this feature to OpenRewrite?
Potentially.
The text was updated successfully, but these errors were encountered: