From 355acd296ac16902f588a879e99efd548f0dc0e7 Mon Sep 17 00:00:00 2001 From: vmishenev Date: Fri, 23 Jul 2021 15:26:40 +0300 Subject: Add numeric types of annotation parameter value (#2035) --- .../kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins/base/src/main/kotlin/translators/psi') diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index be7b826b..d2fb0271 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -602,6 +602,15 @@ class DefaultPsiToDocumentableTranslator( val psiClass = ((type as PsiImmediateClassType).parameters.single() as PsiClassReferenceType).resolve() psiClass?.let { ClassValue(text ?: "", DRI.from(psiClass)) } } + is PsiLiteralExpression -> toValue() + else -> StringValue(text ?: "") + } + + private fun PsiLiteralExpression.toValue(): AnnotationParameterValue? = when (type) { + PsiType.INT -> (value as? Int)?.let { IntValue(it) } + PsiType.LONG -> (value as? Long)?.let { LongValue(it) } + PsiType.FLOAT -> (value as? Float)?.let { FloatValue(it) } + PsiType.DOUBLE -> (value as? Double)?.let { DoubleValue(it) } else -> StringValue(text ?: "") } -- cgit