diff options
author | Sergey Mashkov <sergey.mashkov@jetbrains.com> | 2015-07-22 20:00:50 +0300 |
---|---|---|
committer | Sergey Mashkov <sergey.mashkov@jetbrains.com> | 2015-07-22 20:00:50 +0300 |
commit | f822c51af0ca775a260f8aab010c9ccc9be8d52e (patch) | |
tree | 89341a5de0f5297528cf7bb44e0aec35c202b536 /src/Kotlin/DocumentationBuilder.kt | |
parent | 28a3891ffa2c4984a9d49be41d76fe97854872c9 (diff) | |
download | dokka-f822c51af0ca775a260f8aab010c9ccc9be8d52e.tar.gz dokka-f822c51af0ca775a260f8aab010c9ccc9be8d52e.tar.bz2 dokka-f822c51af0ca775a260f8aab010c9ccc9be8d52e.zip |
Upgrade to latest kotlin
Diffstat (limited to 'src/Kotlin/DocumentationBuilder.kt')
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index bea2f6fa..6c0b7b03 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.JetParameter import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.source.PsiSourceElement import org.jetbrains.kotlin.resolve.source.getPsi @@ -685,7 +686,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, val node = DocumentationNode(annotationClass.getName().asString(), Content.Empty, DocumentationNode.Kind.Annotation) val arguments = getAllValueArguments().toList().sortBy { it.first.getIndex() } arguments.forEach { - val valueNode = it.second.build() + val valueNode = it.second.value.toDocumentationNode() if (valueNode != null) { val paramNode = DocumentationNode(it.first.getName().asString(), Content.Empty, DocumentationNode.Kind.Parameter) paramNode.append(valueNode, DocumentationReference.Kind.Detail) @@ -695,15 +696,18 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, return node } - fun CompileTimeConstant<out Any?>.build(): DocumentationNode? { - val value = getValue() - val valueString = when(value) { - is String -> - "\"" + StringUtil.escapeStringCharacters(value) + "\"" - is EnumEntrySyntheticClassDescriptor -> - value.getContainingDeclaration().getName().asString() + "." + value.getName() - else -> value?.toString() - } - return if (valueString != null) DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) else null + fun CompileTimeConstant<Any?>.build(): DocumentationNode? { + val value: Any? = if (this is TypedCompileTimeConstant) getValue(type) else null + return value.toDocumentationNode() + } + + private fun Any?.toDocumentationNode(): DocumentationNode? = when (this) { + is String -> + "\"" + StringUtil.escapeStringCharacters(this) + "\"" + is EnumEntrySyntheticClassDescriptor -> + getContainingDeclaration().getName().asString() + "." + getName() + else -> this?.toString() + }.let { valueString -> + if (valueString != null) DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) else null } } |