aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt6
-rw-r--r--kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRITargetFactory.kt6
-rw-r--r--plugins/base/src/test/kotlin/markdown/LinkTest.kt33
3 files changed, 39 insertions, 6 deletions
diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt
index f47bf34b..3dd28fed 100644
--- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt
+++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt
@@ -10,7 +10,9 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
fun DRI.Companion.from(descriptor: DeclarationDescriptor) = descriptor.parentsWithSelf.run {
- val callable = firstIsInstanceOrNull<CallableDescriptor>()
+ val parameter = firstIsInstanceOrNull<ValueParameterDescriptor>()
+ val callable = parameter?.containingDeclaration ?: firstIsInstanceOrNull<CallableDescriptor>()
+
DRI(
firstIsInstanceOrNull<PackageFragmentDescriptor>()?.fqName?.asString() ?: "",
(filterIsInstance<ClassDescriptor>() + filterIsInstance<TypeAliasDescriptor>()).toList()
@@ -18,7 +20,7 @@ fun DRI.Companion.from(descriptor: DeclarationDescriptor) = descriptor.parentsWi
?.asReversed()
?.joinToString(separator = ".") { it.name.asString() },
callable?.let { Callable.from(it) },
- DriTarget.from(descriptor)
+ DriTarget.from(parameter ?: descriptor)
)
}
diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRITargetFactory.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRITargetFactory.kt
index 031a5a32..e1e93962 100644
--- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRITargetFactory.kt
+++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRITargetFactory.kt
@@ -8,10 +8,7 @@ import org.jetbrains.dokka.links.DriTarget
import org.jetbrains.dokka.links.PointingToCallableParameters
import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.links.PointingToGenericParameters
-import org.jetbrains.kotlin.descriptors.CallableDescriptor
-import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
-import org.jetbrains.kotlin.descriptors.ParameterDescriptor
-import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
+import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
@@ -19,6 +16,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
fun DriTarget.Companion.from(descriptor: DeclarationDescriptor): DriTarget = descriptor.parentsWithSelf.run {
return when (descriptor) {
is TypeParameterDescriptor -> PointingToGenericParameters(descriptor.index)
+ is ValueParameterDescriptor -> PointingToCallableParameters(descriptor.index)
else -> {
val callable = firstIsInstanceOrNull<CallableDescriptor>()
val params =
diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt
index 6e0f47ed..2bcc0bf0 100644
--- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt
+++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt
@@ -6,6 +6,7 @@ import org.jetbrains.dokka.pages.ClasslikePageNode
import org.jetbrains.dokka.pages.ContentDRILink
import org.jetbrains.dokka.pages.MemberPageNode
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.model.doc.DocumentationLink
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Test
@@ -78,4 +79,36 @@ class LinkTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `link to parameter #238`() {
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/main/kotlin/Test.kt
+ |package example
+ |
+ |/**
+ |* Link to [waitAMinute]
+ |*/
+ |fun stop(hammerTime: String, waitAMinute: String) {}
+ |
+ """.trimMargin(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ val parameter = module.dfs { it.name == "waitAMinute" }
+ val link = module.dfs { it.name == "stop" }!!.documentation.values.single().dfs { it is DocumentationLink } as DocumentationLink
+
+ assertEquals(parameter!!.dri, link.dri)
+ }
+ }
+ }
}