mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] k2 deprecation fix: don't insert comments from origin function body
^KTIJ-31410 fixed GitOrigin-RevId: 56342b8657bdbef21b64e4089a254a6f162e3fee
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ee0d4019d2
commit
f7fd73abe1
+4
-1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.k2.refactoring.inline.codeInliner.ClassUsageRep
|
||||
import org.jetbrains.kotlin.idea.k2.refactoring.inline.codeInliner.CodeToInlineBuilder
|
||||
import org.jetbrains.kotlin.idea.quickfix.replaceWith.ReplaceWithData
|
||||
import org.jetbrains.kotlin.idea.refactoring.inline.codeInliner.CodeToInline
|
||||
import org.jetbrains.kotlin.idea.refactoring.inline.codeInliner.MutableCodeToInline
|
||||
import org.jetbrains.kotlin.idea.refactoring.inline.codeInliner.UsageReplacementStrategy
|
||||
import org.jetbrains.kotlin.idea.refactoring.inline.codeInliner.buildCodeToInline
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
@@ -175,7 +176,9 @@ abstract class DeprecatedSymbolUsageFixBase(
|
||||
val expression =
|
||||
psiFactory.createExpressionCodeFragment(replaceWith.pattern, context).getContentElement() ?: return null
|
||||
|
||||
return buildCodeToInline(target, expression, false, null, CodeToInlineBuilder(original = target))
|
||||
return buildCodeToInline(target, expression, false, null, object : CodeToInlineBuilder(original = target) {
|
||||
override fun saveComments(codeToInline: MutableCodeToInline, contextDeclaration: KtDeclaration) {}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
|
||||
@Deprecated("", ReplaceWith("newFun()"))
|
||||
fun oldFun(p: Int) {
|
||||
/** some comments */
|
||||
newFun()
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
|
||||
@Deprecated("", ReplaceWith("newFun()"))
|
||||
fun oldFun(p: Int) {
|
||||
/** some comments */
|
||||
newFun()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ abstract class AbstractCodeToInlineBuilder(
|
||||
protected val fallbackToSuperCall: Boolean = false,
|
||||
) {
|
||||
protected val psiFactory = KtPsiFactory(project)
|
||||
protected fun saveComments(codeToInline: MutableCodeToInline, contextDeclaration: KtDeclaration) {
|
||||
protected open fun saveComments(codeToInline: MutableCodeToInline, contextDeclaration: KtDeclaration) {
|
||||
val bodyBlockExpression = contextDeclaration.safeAs<KtDeclarationWithBody>()?.bodyBlockExpression
|
||||
if (bodyBlockExpression != null) addCommentHoldersForStatements(codeToInline, bodyBlockExpression)
|
||||
}
|
||||
|
||||
+3
-6
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.idea.refactoring.inline.codeInliner.AbstractCodeToIn
|
||||
import org.jetbrains.kotlin.idea.refactoring.inline.codeInliner.MutableCodeToInline
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
class CodeToInlineBuilder(
|
||||
open class CodeToInlineBuilder(
|
||||
private val original: KtDeclaration, fallbackToSuperCall: Boolean = false
|
||||
) : AbstractCodeToInlineBuilder(original.project, original, fallbackToSuperCall) {
|
||||
|
||||
@@ -33,17 +33,14 @@ class CodeToInlineBuilder(
|
||||
|
||||
val codeToInline = MutableCodeToInline(
|
||||
mainExpression,
|
||||
originalDeclaration,
|
||||
original,
|
||||
statementsBefore.toMutableList(),
|
||||
mutableSetOf(),
|
||||
alwaysKeepMainExpression,
|
||||
extraComments = null,
|
||||
)
|
||||
|
||||
if (originalDeclaration != null) {
|
||||
saveComments(codeToInline, originalDeclaration!!)
|
||||
}
|
||||
|
||||
saveComments(codeToInline, original)
|
||||
insertExplicitTypeArguments(codeToInline)
|
||||
removeContracts(codeToInline)
|
||||
encodeInternalReferences(codeToInline, original)
|
||||
|
||||
Reference in New Issue
Block a user