KT-19126 Add convert property initializer to getter in interfaces (#1224)

This commit is contained in:
Andrius Semionovas
2017-08-07 12:53:37 +03:00
committed by Dmitry Jemerov
parent 2536615e0e
commit 666c241479
12 changed files with 122 additions and 2 deletions
@@ -261,6 +261,15 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
return getter
}
fun createPropertySetter(expression: KtExpression): KtPropertyAccessor {
val property = createProperty("val x get() = 1\nset(value) = TODO()")
val setter = property.setter!!
val bodyExpression = setter.bodyExpression!!
bodyExpression.replace(expression)
return setter
}
fun createDestructuringDeclaration(text: String): KtDestructuringDeclaration {
return (createFunction("fun foo() {$text}").bodyExpression as KtBlockExpression).statements.first() as KtDestructuringDeclaration
}