Enable rainbow highlighting for destructuring declaration entries
#KT-17652 Fixed
This commit is contained in:
@@ -93,8 +93,10 @@ class KotlinRainbowVisitor : RainbowVisitor() {
|
|||||||
addInfo(getInfo(context, rainbowElement, rainbowElement.text, attributesKeyToUse))
|
addInfo(getInfo(context, rainbowElement, rainbowElement.text, attributesKeyToUse))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PsiElement?.isRainbowDeclaration() =
|
private fun PsiElement?.isRainbowDeclaration(): Boolean =
|
||||||
(this is KtProperty && isLocal) || (this is KtParameter && getStrictParentOfType<KtPrimaryConstructor>() == null)
|
(this is KtProperty && isLocal) ||
|
||||||
|
(this is KtParameter && getStrictParentOfType<KtPrimaryConstructor>() == null) ||
|
||||||
|
this is KtDestructuringDeclarationEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PsiElement.isAnonymousFunction(): Boolean = this is KtNamedFunction && nameIdentifier == null
|
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>)
|
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) {
|
private fun checkRainbow(code: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user