aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin
diff options
context:
space:
mode:
authorDmitry Jemerov <intelliyole@gmail.com>2015-07-27 15:13:11 +0200
committerDmitry Jemerov <intelliyole@gmail.com>2015-07-27 15:13:11 +0200
commitbefbe69c3863b1048b585e795ec2f99d5a10390e (patch)
treed2392c9a9fafbd5b2e7b9c5c35c593fd73d59d0d /src/Kotlin
parent28a3891ffa2c4984a9d49be41d76fe97854872c9 (diff)
parent2930cd9685c5e6296b24e9530b296c7ce3ea89fa (diff)
downloaddokka-befbe69c3863b1048b585e795ec2f99d5a10390e.tar.gz
dokka-befbe69c3863b1048b585e795ec2f99d5a10390e.tar.bz2
dokka-befbe69c3863b1048b585e795ec2f99d5a10390e.zip
Merge pull request #31 from cy6erGn0m/javadoc
Kotlin upgrade + source position in documentation node
Diffstat (limited to 'src/Kotlin')
-rw-r--r--src/Kotlin/DocumentationBuilder.kt21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index bea2f6fa..eda69841 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -18,6 +18,8 @@ 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.ConstantValue
+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 +687,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.toDocumentationNode()
if (valueNode != null) {
val paramNode = DocumentationNode(it.first.getName().asString(), Content.Empty, DocumentationNode.Kind.Parameter)
paramNode.append(valueNode, DocumentationReference.Kind.Detail)
@@ -695,15 +697,20 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade,
return node
}
- fun CompileTimeConstant<out Any?>.build(): DocumentationNode? {
- val value = getValue()
- val valueString = when(value) {
+ fun CompileTimeConstant<Any?>.build(): DocumentationNode? = when (this) {
+ is TypedCompileTimeConstant -> constantValue.toDocumentationNode()
+ else -> null
+ }
+
+ fun ConstantValue<*>.toDocumentationNode(): DocumentationNode? = value?.let { value ->
+ when (value) {
is String ->
"\"" + StringUtil.escapeStringCharacters(value) + "\""
is EnumEntrySyntheticClassDescriptor ->
- value.getContainingDeclaration().getName().asString() + "." + value.getName()
- else -> value?.toString()
+ value.containingDeclaration.name.asString() + "." + value.name.asString()
+ else -> value.toString()
+ }.let { valueString ->
+ DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value)
}
- return if (valueString != null) DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) else null
}
}