Add ConstantValueKind to KtSimpleConstantValue
This commit is contained in:
+1
-1
@@ -58,7 +58,7 @@ object DebugSymbolRenderer {
|
|||||||
}
|
}
|
||||||
"${value::class.simpleName!!}($symbolTag)"
|
"${value::class.simpleName!!}($symbolTag)"
|
||||||
}
|
}
|
||||||
is KtSimpleConstantValue<*> -> renderValue(value.constant)
|
is KtSimpleConstantValue<*> -> renderValue(value.value)
|
||||||
is KtNamedConstantValue -> "${renderValue(value.name)} = ${renderValue(value.expression)}"
|
is KtNamedConstantValue -> "${renderValue(value.name)} = ${renderValue(value.expression)}"
|
||||||
is KtAnnotationCall ->
|
is KtAnnotationCall ->
|
||||||
"${renderValue(value.classId)}${value.arguments.joinToString(prefix = "(", postfix = ")") { renderValue(it) }}"
|
"${renderValue(value.classId)}${value.arguments.joinToString(prefix = "(", postfix = ")") { renderValue(it) }}"
|
||||||
|
|||||||
+3
-1
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.frontend.api.symbols.markers
|
package org.jetbrains.kotlin.idea.frontend.api.symbols.markers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||||
|
|
||||||
sealed class KtConstantValue
|
sealed class KtConstantValue
|
||||||
object KtUnsupportedConstantValue : KtConstantValue()
|
object KtUnsupportedConstantValue : KtConstantValue()
|
||||||
|
|
||||||
data class KtSimpleConstantValue<T>(val constant: T?) : KtConstantValue()
|
data class KtSimpleConstantValue<T>(val constantValueKind: ConstantValueKind<T>, val value: T) : KtConstantValue()
|
||||||
+1
-3
@@ -17,10 +17,8 @@ import org.jetbrains.kotlin.fir.references.FirNamedReference
|
|||||||
import org.jetbrains.kotlin.idea.frontend.api.fir.symbols.KtFirSymbol
|
import org.jetbrains.kotlin.idea.frontend.api.fir.symbols.KtFirSymbol
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.fir.utils.mapAnnotationParameters
|
import org.jetbrains.kotlin.idea.frontend.api.fir.utils.mapAnnotationParameters
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFileSymbol
|
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFileSymbol
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtPropertySymbol
|
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtAnnotatedSymbol
|
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtAnnotatedSymbol
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSimpleConstantValue
|
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSimpleConstantValue
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
|
|
||||||
internal fun KtAnnotatedSymbol.hasJvmSyntheticAnnotation(annotationUseSiteTarget: AnnotationUseSiteTarget? = null): Boolean =
|
internal fun KtAnnotatedSymbol.hasJvmSyntheticAnnotation(annotationUseSiteTarget: AnnotationUseSiteTarget? = null): Boolean =
|
||||||
hasAnnotation("kotlin/jvm/JvmSynthetic", annotationUseSiteTarget)
|
hasAnnotation("kotlin/jvm/JvmSynthetic", annotationUseSiteTarget)
|
||||||
@@ -36,7 +34,7 @@ internal fun KtAnnotatedSymbol.getJvmNameFromAnnotation(annotationUseSiteTarget:
|
|||||||
}
|
}
|
||||||
|
|
||||||
return annotation?.let {
|
return annotation?.let {
|
||||||
(it.arguments.firstOrNull()?.expression as? KtSimpleConstantValue<*>)?.constant as? String
|
(it.arguments.firstOrNull()?.expression as? KtSimpleConstantValue<*>)?.value as? String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ private fun escapeString(str: String): String = buildString {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun KtSimpleConstantValue<*>.asStringForPsiLiteral(): String =
|
private fun KtSimpleConstantValue<*>.asStringForPsiLiteral(): String =
|
||||||
when (val value = this.constant) {
|
when (val value = this.value) {
|
||||||
is String -> "\"${escapeString(value)}\""
|
is String -> "\"${escapeString(value)}\""
|
||||||
is Long -> "${value}L"
|
is Long -> "${value}L"
|
||||||
is Float -> "${value}f"
|
is Float -> "${value}f"
|
||||||
|
|||||||
+3
-1
@@ -48,8 +48,10 @@ internal fun mapAnnotationParameters(annotationCall: FirAnnotationCall, session:
|
|||||||
return resultSet
|
return resultSet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun <T> FirConstExpression<T>.convertConstantExpression(): KtSimpleConstantValue<T> = KtSimpleConstantValue(kind, value)
|
||||||
|
|
||||||
internal fun FirExpression.convertConstantExpression(): KtConstantValue =
|
internal fun FirExpression.convertConstantExpression(): KtConstantValue =
|
||||||
when (this) {
|
when (this) {
|
||||||
is FirConstExpression<*> -> KtSimpleConstantValue(value)
|
is FirConstExpression<*> -> convertConstantExpression()
|
||||||
else -> KtUnsupportedConstantValue
|
else -> KtUnsupportedConstantValue
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user