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

Recipe to call ToolProvider methods as static methods, not on instances #477

Conversation

ranuradh
Copy link
Contributor

What's changed?

Created RemovedToolProviderConstructor Recipe:
For the following rule:
image

What's your motivation?

This recipe checks for a specific method pattern and converts it to a static call.The existing recipe ChangeMethodTargetToStatic did not work in this case since it doesn't meet the criteria of the method should not be static and should not be of the SameReceiverType

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

I had to create a new branch and work on this recipe since my old branch got corrupted for some reason so this work is a duplicate of #454 and I updated the test to cover the chained call of the methods to be converted to Static.

Anyone you would like to review specifically?

@cjobinabo

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

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@ranuradh ranuradh changed the title adding recipe RemovedToolProvider Adding Java SE 17 recipe RemovedToolProviderConstructor May 17, 2024
@ranuradh ranuradh changed the title Adding Java SE 17 recipe RemovedToolProviderConstructor Adding Java SE 17 Recipe RemovedToolProviderConstructor May 17, 2024
@ranuradh ranuradh requested a review from cjobinabo May 17, 2024 13:35
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.

Hi! Some quick feedback to hopefully prevent any duplicate work, and end up with a leaner PR.

@ranuradh ranuradh marked this pull request as draft May 17, 2024 15:52
@timtebeek timtebeek marked this pull request as ready for review May 19, 2024 23:12
@timtebeek timtebeek added the recipe Recipe requested label May 19, 2024
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 prompting me to revisit ChangeMethodTargetToStatic @ranuradh ; I've now simplified your PR to retain the test and implement the recipe as a declarative one, as per our best practices. That also clears out the cycle issues we saw before.

Good to merge if you ask me; I'll leave a final review and merge up to @cjobinabo

@timtebeek timtebeek changed the title Adding Java SE 17 Recipe RemovedToolProviderConstructor Recipe to call ToolProvider methods as static methods, not on instances May 19, 2024
@ranuradh
Copy link
Contributor Author

Thanks @timtebeek this works. I have another recipe call that is similar to this one..will help with that as well!

@timtebeek timtebeek merged commit 047c19f into openrewrite:main May 21, 2024
2 checks passed
@ranuradh ranuradh deleted the remove_modifier_bootstrap_toolprovider_real branch May 21, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants