Rewrite calls from deprecated API to target API
What problem are you trying to solve?
Certain API got deprecated in favor of something new. There is a replacement, and we need to define the rules on how old, deprecated API calls are transitioned into a new call, that is open to discussion
What precondition(s) should be checked before applying this recipe?
We have calls to an old API. The old API produces the type A. The old API produces also either the type A, or any of its children. So it is backward compatible on the source code level. But the input parameters are either changed, or more qualified, or re-arranged or etc.
Describe the situation before applying the recipe
class A {
void foo(String a, String b) {
bar(a, b);
}
/**
* @deprecated in favor of #bar(Integer, Boolean)
*/
@Deprecated
void bar(Integer int, String value) {
}
void bar(Integer int, Boolean value) {
}
}
Describe the situation after applying the recipe
class A {
void foo(String a, String b) {
bar(a, Boolean.valueOf(b));
}
/**
* @deprecated in favor of #bar(Integer, Boolean)
*/
@Deprecated
void bar(Integer int, String value) {
}
void bar(Integer int, Boolean value) {
}
}
Have you considered any alternatives or workarounds?
Based on documentation, there are no workarounds to this in openrewrite, yet.
Any additional context
Are you interested in contributing this recipe to OpenRewrite?
Yes, I would like to
hi! It's not immediately clear what you're proposing to contribute. Would this be a new recipe that reads the JavaDoc?
We've had a recent proposal that perhaps comes close to what you're suggesting, somewhat similar to ErrorProne's @InlineMe:
- https://github.com/openrewrite/rewrite/issues/5400
Any additional details you can provide would help us better understand and guide your efforts.
You might be interested in this new recipe:
- https://github.com/openrewrite/rewrite-migrate-java/pull/788#issuecomment-3200452153