Enable rainbow highlighting for destructuring declaration entries

#KT-17652 Fixed
This commit is contained in:
Dmitry Jemerov
2017-05-08 15:56:55 +02:00
parent 382bf9a500
commit b33c544fdf
2 changed files with 14 additions and 2 deletions
@@ -93,8 +93,10 @@ class KotlinRainbowVisitor : RainbowVisitor() {
addInfo(getInfo(context, rainbowElement, rainbowElement.text, attributesKeyToUse))
}
private fun PsiElement?.isRainbowDeclaration() =
(this is KtProperty && isLocal) || (this is KtParameter && getStrictParentOfType<KtPrimaryConstructor>() == null)
private fun PsiElement?.isRainbowDeclaration(): Boolean =
(this is KtProperty && isLocal) ||
(this is KtParameter && getStrictParentOfType<KtPrimaryConstructor>() == null) ||
this is KtDestructuringDeclarationEntry
}
private fun PsiElement.isAnonymousFunction(): Boolean = this is KtNamedFunction && nameIdentifier == null
@@ -70,7 +70,17 @@ class KotlinRainbowHighlighterTest : KotlinLightCodeInsightFixtureTestCase() {
System.out.println(<rainbow color='ff000004'>foo</rainbow>)
}
""")
}
fun testDestructuring() {
checkRainbow("""
fun foo() {
val (<rainbow color='ff000003'>a</rainbow>, <rainbow color='ff000004'>b</rainbow>) = 1 to 2
println(<rainbow color='ff000003'>a</rainbow>)
println(<rainbow color='ff000004'>b</rainbow>)
}
""")
}
private fun checkRainbow(code: String) {