Intentions: Fix contentRange() on empty KtBlockExpression

#KT-10776 Fixed
This commit is contained in:
Alexey Sedunov
2016-01-27 15:27:34 +03:00
parent c5b1d205a2
commit 1c65797950
4 changed files with 17 additions and 0 deletions
@@ -179,6 +179,7 @@ fun KtBlockExpression.contentRange(): PsiChildRange {
val last = rBrace!!
.siblings(forward = false, withItself = false)
.first { it !is PsiWhiteSpace }
if (last == lBrace) return PsiChildRange.EMPTY
return PsiChildRange(first, last)
}
@@ -0,0 +1,5 @@
fun acceptLambda(f: () -> Unit) = f()
fun foo() {
acceptLambda(<caret>fun(): Unit {})
}
@@ -0,0 +1,5 @@
fun acceptLambda(f: () -> Unit) = f()
fun foo() {
acceptLambda { }
}
@@ -439,6 +439,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("emptyBody.kt")
public void testEmptyBody() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/anonymousFunctionToLambda/emptyBody.kt");
doTest(fileName);
}
@TestMetadata("expressionBody.kt")
public void testExpressionBody() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/anonymousFunctionToLambda/expressionBody.kt");