aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
authorSzymon Świstun <sswistun@virtuslab.com>2020-03-16 13:08:29 +0100
committerKamil Doległo <kamilok1965@users.noreply.github.com>2020-03-18 14:40:29 +0100
commit3de1182033ca5a5db374e16a6ab3555627faa79b (patch)
tree192580f4a08340466fd293a7199f110e34fe1dbf /plugins/base/src/main
parent03329b0eb98b309d208839344052633028e00984 (diff)
downloaddokka-3de1182033ca5a5db374e16a6ab3555627faa79b.tar.gz
dokka-3de1182033ca5a5db374e16a6ab3555627faa79b.tar.bz2
dokka-3de1182033ca5a5db374e16a6ab3555627faa79b.zip
Add default values for parameters
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt20
1 files changed, 16 insertions, 4 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 44679d8d..6d834f9c 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -19,16 +19,19 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies
import org.jetbrains.kotlin.idea.kdoc.findKDoc
+import org.jetbrains.kotlin.psi.KtConstantExpression
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.components.isVararg
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
-import org.jetbrains.kotlin.resolve.descriptorUtil.*
+import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
+import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny
+import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
+import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.MemberScope
+import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeProjection
-import org.jetbrains.dokka.model.Variance
-import org.jetbrains.kotlin.idea.kdoc.findKDoc
class DefaultDescriptorToDocumentableTranslator(
private val context: DokkaContext
@@ -367,7 +370,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
type = descriptor.type.toBound(),
documentation = descriptor.resolveDescriptorData(platformData),
platformData = listOf(platformData),
- extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations())
+ extra = PropertyContainer.withAll(
+ listOfNotNull(
+ descriptor.additionalExtras(),
+ descriptor.getAnnotations(),
+ descriptor.getDefaultValue()?.let { DefaultValue(it) })
+ )
)
private fun MemberScope.functions(parent: DRIWithPlatformInfo): List<DFunction> =
@@ -523,6 +531,10 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
)
}.let(::Annotations)
+ fun ValueParameterDescriptor.getDefaultValue(): String? = (source as? KotlinSourceElement)?.let {
+ it.psi.children.find { it is KtConstantExpression }?.text
+ }
+
data class ClassInfo(val supertypes: List<DRI>, val docs: PlatformDependent<DocumentationNode>)
private fun Visibility.toDokkaVisibility(): org.jetbrains.dokka.model.Visibility = when (this) {