Change Signature: Avoid creating parameters from scratch

#KT-15519 Fixed
This commit is contained in:
Alexey Sedunov
2017-04-18 17:49:03 +03:00
parent c305a42128
commit b80fbe1192
11 changed files with 117 additions and 36 deletions
@@ -313,3 +313,10 @@ fun KtCallableDeclaration.setReceiverType(type: KotlinType) {
ShortenReferences.DEFAULT.process(receiverTypeReference!!)
}
fun KtParameter.setDefaultValue(newDefaultValue: KtExpression): PsiElement? {
defaultValue?.let { return it.replaced(newDefaultValue) }
val psiFactory = KtPsiFactory(this)
val eq = equalsToken ?: add(psiFactory.createEQ())
return addAfter(newDefaultValue, eq) as KtExpression
}