diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2019-11-04 19:59:18 +0100 |
---|---|---|
committer | Paweł Marks <pmarks@virtuslab.com> | 2019-11-04 19:59:18 +0100 |
commit | 78ef161062eefe33633ad912817ad5c0e1555ed6 (patch) | |
tree | 1026a340548b8038038c8d40881869f098eafceb /core/src/main/kotlin/links | |
parent | 93af17aba8858806f197a7e8b8383566a1debdeb (diff) | |
download | dokka-78ef161062eefe33633ad912817ad5c0e1555ed6.tar.gz dokka-78ef161062eefe33633ad912817ad5c0e1555ed6.tar.bz2 dokka-78ef161062eefe33633ad912817ad5c0e1555ed6.zip |
Some parsing for markdown links
Diffstat (limited to 'core/src/main/kotlin/links')
-rw-r--r-- | core/src/main/kotlin/links/DRI.kt | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index 7ab25444..fced7dde 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -1,7 +1,9 @@ package org.jetbrains.dokka.links -import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.text.ParseException /** @@ -48,6 +50,19 @@ data class DRI( throw ParseException(s, 0) } + fun from(descriptor: DeclarationDescriptor) = descriptor.parentsWithSelf.run { + val callable = firstIsInstanceOrNull<CallableDescriptor>() + val params = callable?.let { listOfNotNull(it.extensionReceiverParameter) + it.valueParameters }.orEmpty() + DRI( + firstIsInstanceOrNull<PackageFragmentDescriptor>()?.fqName?.asString(), + filterIsInstance<ClassDescriptor>().toList().takeIf { it.isNotEmpty() }?.asReversed() + ?.joinToString(separator = ".") { it.name.asString() }, + callable?.let { Callable.from(it) }, + firstIsInstanceOrNull<ParameterDescriptor>()?.let { params.indexOf(it) }, + null + ) + } + val topLevel = DRI() } } |