From 52890ca60178a8646067d9bb6910237d9007b354 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 31 Jan 2023 18:55:57 +0100 Subject: [PATCH] K2 Tests: Add rendering of FirSmartCastExpression in html dump Previously it was just skipped --- .../org/jetbrains/kotlin/fir/dump/colors.dark.css | 4 ++++ .../org/jetbrains/kotlin/fir/dump/colors.white.css | 4 ++++ .../dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.dark.css b/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.dark.css index efff8347bfe..afcc63866d8 100644 --- a/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.dark.css +++ b/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.dark.css @@ -102,4 +102,8 @@ body.dark { .dark .diagnostic-hover { background-color: #3a3a3a; color: #dfdfdf; +} + +.dark .smart-cast { + background-color: #223C23; } \ No newline at end of file diff --git a/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.white.css b/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.white.css index 026357d18f2..00bedc22b8a 100644 --- a/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.white.css +++ b/compiler/fir/dump/resources/org/jetbrains/kotlin/fir/dump/colors.white.css @@ -92,4 +92,8 @@ .white .diagnostic-hover { background-color: #eaeaea; color: #000; +} + +.white .smart-cast { + background-color: #DBFFDB; } \ No newline at end of file diff --git a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt index 8d8958e950b..ba92b1a5f16 100644 --- a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt +++ b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt @@ -1590,6 +1590,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver is FirCheckedSafeCallSubject -> { +"\$subj\$" } + is FirSmartCastExpression -> generate(expression) else -> inlineUnsupported(expression) } } @@ -1601,6 +1602,12 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver generate(comparisonExpression.right) } + private fun FlowContent.generate(smartCastExpression: FirSmartCastExpression) { + span(classes = "smart-cast") { + generate(smartCastExpression.originalExpression) + } + } + private fun FlowContent.generate(safeCallExpression: FirSafeCallExpression) { generate(safeCallExpression.receiver)