Skip to content
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

Support fluent chains in RemoveMethodCallVisitor #340

Merged

Conversation

mbruggmann
Copy link
Contributor

@mbruggmann mbruggmann commented Sep 19, 2024

What's changed?

RemoveMethodCallVisitor can now remove method invocations in a fluent chain, assuming that the select is also a method invocation and of the same return type. In particular, this works for the builder pattern.

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Is partial support for this use-case worth the added complexity?

Anyone you would like to review specifically?

@timtebeek

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • src/main/java/org/openrewrite/staticanalysis/RemoveMethodCallVisitor.java
    • lines 25-25

@timtebeek
Copy link
Contributor

Thanks for the measured improvement here! Indeed would say that this is worthwhile to add into the visitor. Could you let me know when you're ready for review?

@mbruggmann mbruggmann marked this pull request as ready for review September 19, 2024 13:49
@mbruggmann
Copy link
Contributor Author

@timtebeek Cool. Feel free to have a look, I was just waiting for the tests to go through in CI.

Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the controlled extension to what the visitor can cover! I've added some small polishing commits, but other than that good to go.

@timtebeek timtebeek added the enhancement New feature or request label Sep 19, 2024
@timtebeek timtebeek merged commit 1185126 into openrewrite:main Sep 19, 2024
2 checks passed
@mbruggmann mbruggmann deleted the remove-fluent-method-invocation branch September 19, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

RemoveMethodCallVisitor doesn't work in fluent APIs
2 participants