Fix ISE in KotlinPairMatcher.getCodeConstructStart()

This commit is contained in:
Dmitry Jemerov
2018-02-21 10:13:08 +01:00
parent 2fdadb0f5a
commit 9e30ede998
2 changed files with 7 additions and 1 deletions
@@ -44,7 +44,9 @@ class KotlinPairMatcher : PairedBraceMatcher {
if (element == null || element is PsiFile) return openingBraceOffset
val parent = element.parent
return when (parent) {
is KtClassBody, is KtBlockExpression -> DeclarationRangeUtil.getDeclarationRange(parent.parent).startOffset
is KtClassBody, is KtBlockExpression ->
DeclarationRangeUtil.getPossibleDeclarationAtRange(parent.parent)?.startOffset ?: openingBraceOffset
else -> openingBraceOffset
}
}
@@ -38,4 +38,8 @@ class KotlinPairMatcherTest : KotlinLightCodeInsightFixtureTestCase() {
fun testFun() {
doTest("/* Doc comment */ <start>fun xyzzy(x: Int, y: String): Any <brace>{ }")
}
fun testFor() {
doTest("fun xyzzy() { for (x in 0..1)<start><brace>{ } }")
}
}