openrewrite / rewrite-migrate-java

OpenRewrite recipes for migrating to newer versions of Java.
Apache License 2.0
92 stars 65 forks source link

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

Closed ranuradh closed 1 month ago

ranuradh commented 1 month ago

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 https://github.com/openrewrite/rewrite-migrate-java/pull/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

ranuradh commented 1 month ago

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