J2K: KotlinInlineValHandler (conversion and refactoring)

This commit is contained in:
Alexey Sedunov
2015-12-04 15:22:17 +03:00
parent 2fef2763ab
commit 0af2243245
3 changed files with 194 additions and 347 deletions
@@ -25,11 +25,12 @@ public class KtFunctionLiteralArgument(node: ASTNode) : KtValueArgument(node), F
override fun getFunctionLiteral(): KtFunctionLiteralExpression = getArgumentExpression().unpackFunctionLiteral()!!
}
public fun KtExpression.unpackFunctionLiteral(): KtFunctionLiteralExpression? {
public fun KtExpression.unpackFunctionLiteral(allowParentheses: Boolean = false): KtFunctionLiteralExpression? {
return when (this) {
is KtFunctionLiteralExpression -> this
is KtLabeledExpression -> getBaseExpression()?.unpackFunctionLiteral()
is KtAnnotatedExpression -> getBaseExpression()?.unpackFunctionLiteral()
is KtLabeledExpression -> baseExpression?.unpackFunctionLiteral(allowParentheses)
is KtAnnotatedExpression -> baseExpression?.unpackFunctionLiteral(allowParentheses)
is KtParenthesizedExpression -> if (allowParentheses) expression?.unpackFunctionLiteral(allowParentheses) else null
else -> null
}
}