Convrt anonymous function to lambda: fix incorrectly conversion

#KT-28618
This commit is contained in:
Toshiaki Kameyama
2018-12-05 21:17:39 +09:00
committed by Mikhail Glukhikh
parent f6323cdee4
commit 9ee9965c7a
4 changed files with 24 additions and 7 deletions
@@ -164,15 +164,15 @@ fun KtElement.blockExpressionsOrSingle(): Sequence<KtElement> =
fun KtExpression.lastBlockStatementOrThis(): KtExpression = (this as? KtBlockExpression)?.statements?.lastOrNull() ?: this
fun KtBlockExpression.contentRange(): PsiChildRange {
val first = (lBrace?.nextSibling ?: firstChild)
?.siblings(withItself = false)
?.firstOrNull { it !is PsiWhiteSpace }
val rBrace = rBrace
val lBrace = this.lBrace ?: return PsiChildRange.EMPTY
val rBrace = this.rBrace ?: return PsiChildRange.EMPTY
val first = lBrace.siblings(withItself = false).firstOrNull { it !is PsiWhiteSpace }
if (first == rBrace) return PsiChildRange.EMPTY
val last = rBrace!!
.siblings(forward = false, withItself = false)
.first { it !is PsiWhiteSpace }
val last = rBrace.siblings(forward = false, withItself = false).first { it !is PsiWhiteSpace }
if (last == lBrace) return PsiChildRange.EMPTY
return PsiChildRange(first, last)
}