Apply rainbow highlighting in anonymous initializers

#KT-18839 Fixed
This commit is contained in:
Dmitry Jemerov
2017-12-19 15:22:55 +01:00
parent 94a7673c2d
commit 0159d19539
2 changed files with 21 additions and 1 deletions
@@ -91,7 +91,9 @@ class KotlinRainbowVisitor : RainbowVisitor() {
return
}
val context = target.getStrictParentOfType<KtDeclarationWithBody>() ?: return
val context = target.getStrictParentOfType<KtDeclarationWithBody>()
?: target.getStrictParentOfType<KtAnonymousInitializer>()
?: return
addInfo(getInfo(context, rainbowElement, rainbowElement.text, attributesKeyToUse))
}
@@ -83,6 +83,24 @@ class KotlinRainbowHighlighterTest : KotlinLightCodeInsightFixtureTestCase() {
""")
}
fun testInitBlock() {
checkRainbow("""
class Some {
init {
val <rainbow color='ff000004'>x</rainbow> = 128
println(<rainbow color='ff000004'>x</rainbow>)
run {
println(<rainbow color='ff000004'>x</rainbow>)
}
fun some() {
val <rainbow color='ff000003'>b</rainbow> = 299
println(<rainbow color='ff000003'>b</rainbow> + <rainbow color='ff000004'>x</rainbow>)
}
}
}""")
}
private fun checkRainbow(code: String) {
myFixture.testRainbow("rainbow.kt", code, true, true)
}