Introduce Parameter: Add suspend to lambdas with nested suspend-calls

#KT-24712 Fixed
This commit is contained in:
Alexey Sedunov
2018-06-01 21:12:48 +03:00
parent 8a838ab5bb
commit 0ea1784d33
4 changed files with 21 additions and 0 deletions
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.idea.refactoring.isMultiLine
import org.jetbrains.kotlin.idea.refactoring.runRefactoringWithPostprocessing
import org.jetbrains.kotlin.idea.refactoring.validateElement
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.quoteIfNeeded
import org.jetbrains.kotlin.types.KotlinType
@@ -285,6 +286,9 @@ class KotlinIntroduceParameterDialog private constructor(
val returnType = function.typeReference?.text ?: "Unit"
chosenType = (receiverType?.let { "$it." } ?: "") + "($parameterTypes) -> $returnType"
if (KtTokens.SUSPEND_KEYWORD in newDescriptor.modifiers) {
chosenType = "${KtTokens.SUSPEND_KEYWORD} $chosenType"
}
newArgumentValue = createLambdaForArgument(function)
newReplacer = { }