"Simplify using destructuring declaration" is now applicable for function literals #KT-13941 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-10-03 12:18:29 +03:00
parent 42aea59253
commit df0cf3da84
19 changed files with 193 additions and 9 deletions
@@ -244,15 +244,16 @@ class KtPsiFactory(private val project: Project) {
return (createFunction("fun foo() {$text}").bodyExpression as KtBlockExpression).statements.first() as KtDestructuringDeclaration
}
fun createDestructuringDeclarationInFor(text: String): KtDestructuringDeclaration {
return ((createFunction("fun foo() {for ($text in foo) {} }").bodyExpression as KtBlockExpression).statements.first() as KtForExpression).destructuringParameter!!
}
fun createDestructuringParameter(text: String): KtDestructuringDeclaration {
val dummyFun = createFunction("fun foo() { for ($text in foo) {} }")
return ((dummyFun.bodyExpression as KtBlockExpression).statements.first() as KtForExpression).destructuringParameter!!
}
fun createDestructuringParameterForLambda(text: String): KtParameter {
val dummyFun = createFunction("fun foo() = { $text -> }")
return (dummyFun.bodyExpression as KtLambdaExpression).functionLiteral.valueParameters.first()
}
fun <TDeclaration : KtDeclaration> createDeclaration(text: String): TDeclaration {
val file = createFile(text)
val declarations = file.declarations