-
Notifications
You must be signed in to change notification settings - Fork 52
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
feature(LambdaBlockToExpression): convert lambda with method invocation as well #241
feature(LambdaBlockToExpression): convert lambda with method invocation as well #241
Conversation
src/test/java/org/openrewrite/staticanalysis/LambdaBlockToExpressionTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start at contributing here @timo-abele ! I've added a comment to explain the use of classpaths for tests, and suggestion to remove the second test. Beyond that I think we can try this out if you agree with removing that second test.
src/test/java/org/openrewrite/staticanalysis/LambdaBlockToExpressionTest.java
Outdated
Show resolved
Hide resolved
the other test covers the expected behavior sufficiently Co-authored-by: Tim te Beek <timtebeek@gmail.com>
There was another test that failed namely
The new result looks good to me, can I simply adapt |
Yeah sure! Agree with your observation there. Feel free to mark your PR ready for review once done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two small changes to minimize casts and white space changes; hope you agree! Typically we leave white space changes to the specific style configured rather than setting an explicit space to use. Figured in this case folks might have chosen to add white space, rather than { statement }
, so we should be mindful an keep that in.
Neat addition to this recipe! Look forward to how it will affect changes at scale. Thanks again!
I agree with the casts and I don't mind the white space changes, it did feel strange adding it explicitly in the code. But the reason I did it was to be consistent with the existing behavior Lines 38 to 58 in f1e53d2
where the white space is removed (because the expression is extracted from the statement and the statement holding the white space is dropped). Since the statement in the lambda is only one line, I think it is less of a surprise to continue the line with the -> and not to break it (by keeping the white space).
|
You're right; in the case of |
Hi @timtebeek, could you please release a new version? I'd like to try these changes out. |
Know that you can always try out the latest builds from our snapshot versions; we'll likely folllow up with a release next week. |
What's changed?
This PR will enable the transformation of lambdas with method invocation as body.
What's your motivation?
Fixes #236
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist