Add recipe generator for Kotlin's Deprecated ReplaceWith#57
Closed
timtebeek wants to merge 3 commits into
Closed
Conversation
timtebeek
added a commit
to openrewrite/rewrite
that referenced
this pull request
Jan 17, 2026
Follows the pattern we already have for `InlineMethodCalls`, but now for Kotlin. Related openrewrite/rewrite-third-party#57
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
| import kotlin.Deprecated; | ||
| import kotlin.Metadata; | ||
| import kotlin.ReplaceWith; | ||
| import kotlin.metadata.*; |
Contributor
There was a problem hiding this comment.
Suggested change
| import kotlin.metadata.*; | |
| import kotlin.metadata.KmClass; | |
| import kotlin.metadata.KmClassifier; | |
| import kotlin.metadata.KmFunction; | |
| import kotlin.metadata.KmPackage; | |
| import kotlin.metadata.KmType; | |
| import kotlin.metadata.KmValueParameter; |
Comment on lines
+189
to
+190
| } else if (artifactId.startsWith("kotlinx-coroutines")) { | ||
| return "org.jetbrains.kotlinx"; |
Contributor
There was a problem hiding this comment.
Suggested change
| } else if (artifactId.startsWith("kotlinx-coroutines")) { | |
| return "org.jetbrains.kotlinx"; | |
| } | |
| if (artifactId.startsWith("kotlinx-coroutines")) { | |
| } | |
| if (artifactId.startsWith("kotlinx-serialization")) { |
Comment on lines
+264
to
+265
| } else { | ||
| return buildMethodPatternFromReflection(className, method); |
Contributor
There was a problem hiding this comment.
Suggested change
| } else { | |
| return buildMethodPatternFromReflection(className, method); | |
| return buildMethodPatternFromReflection(className, method); |
| if (classifier instanceof KmClassifier.Class classClassifier) { | ||
| String name = classClassifier.getName().replace('/', '.'); | ||
| return mapKotlinType(name); | ||
| } else if (classifier instanceof KmClassifier.TypeParameter) { |
Contributor
There was a problem hiding this comment.
Suggested change
| } else if (classifier instanceof KmClassifier.TypeParameter) { | |
| } | |
| if (classifier instanceof KmClassifier.TypeParameter) { |
| import kotlin.Deprecated; | ||
| import kotlin.Metadata; | ||
| import kotlin.ReplaceWith; | ||
| import kotlin.metadata.*; |
Contributor
There was a problem hiding this comment.
Suggested change
| import kotlin.metadata.*; | |
| import kotlin.metadata.KmClass; | |
| import kotlin.metadata.KmClassifier; | |
| import kotlin.metadata.KmFunction; | |
| import kotlin.metadata.KmPackage; | |
| import kotlin.metadata.KmType; | |
| import kotlin.metadata.KmValueParameter; |
Member
Author
timtebeek
added a commit
to openrewrite/rewrite
that referenced
this pull request
Feb 13, 2026
…ceWith` (#6561) * Add `ReplaceDeprecatedKotlinMethod` with `template` argument Follows the pattern we already have for `InlineMethodCalls`, but now for Kotlin. Related openrewrite/rewrite-third-party#57 * Update recipes.csv * Move and add scanner/generator for faster iterations * Improve the scanner, generator and replacement recipe * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Move filter to scanner; keep Kotlin types and use `*` for generic types * Handle extension functions and receivers * Add comments to show original expression * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Special handling for suspend and coroutines * Add recipes for Kotlinx * Polish `ReplaceDeprecatedKotlinMethod` * Also support replacements for constructors * Rename recipe * Add a test for constructor replacement * Quick renames * Expect explicit groupId passed in * Apply formatter * Polish DeprecatedMethodScanner * Collapse catch blocks * Use `<init>` Co-authored-by: Knut Wannheden <knut@moderne.io> * Exclude transitive kotlin-stdlib from kotlin-metadata-jvm (#6726) The kotlin-metadata-jvm:2.1.0 dependency pulls in kotlin-stdlib:2.1.0, which conflicts with the parser's embedded kotlin-stdlib:1.9.25 and causes existing Kotlin tests to fail with metadata version errors. Co-authored-by: Tim te Beek <tim@mac.home> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * Comment out the testRuntime dependencies when not generating * Increase heap size * Update recipes.csv --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Knut Wannheden <knut@moderne.io> Co-authored-by: Tim te Beek <tim@mac.home> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@Deprecated(replaceWith=...)suggestions rewrite#5929