diff options
Diffstat (limited to 'plugins')
3 files changed, 25 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt index 33bc96d8..c645157a 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt @@ -14,8 +14,10 @@ open class Dokka010ExternalLocationProvider( override fun resolve(dri: DRI): String? { val docURL = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" + val fqName = listOfNotNull(dri.packageName.takeIf { it?.isNotBlank() == true }, + dri.classNames.takeIf { it?.isNotBlank() == true }).joinToString(".") val relocationId = - "${dri.packageName}.${dri.classNames}".let { if (dri.callable != null) it + "$" + dri.callable!!.toOldString() else it } + fqName.let { if (dri.callable != null) it + "$" + dri.callable!!.toOldString() else it } externalDocumentation.packageList.locations[relocationId]?.let { path -> return "$docURL$path" } val classNamesChecked = dri.classNames ?: return "$docURL${dri.packageName ?: ""}/index$extension" @@ -26,5 +28,5 @@ open class Dokka010ExternalLocationProvider( return "$docURL$classLink/" + identifierToFilename(callableChecked.name) + extension } - private fun Callable.toOldString() = name + params.joinToString(", ", "(", ")") + receiver?.let { "#$it" } + private fun Callable.toOldString() = name + params.joinToString(", ", "(", ")") + (receiver?.let { "#$it" } ?: "") } diff --git a/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt index 280fcc24..0d419520 100644 --- a/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt +++ b/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt @@ -6,6 +6,7 @@ import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.base.resolvers.shared.PackageList import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.links.TypeConstructor import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions.assertEquals @@ -49,4 +50,23 @@ class Dokka010ExternalLocationProviderTest : AbstractCoreTest() { assertEquals("$kotlinLang/kotlin.relocated.text/-string-builder/index.html", locationProvider.resolve(dri)) } + + @Test + fun `method relocation in package list`() { + val locationProvider = getTestLocationProvider() + val dri = DRI( + "kotlin", + "", + Callable( + "minus", + null, + listOf( + TypeConstructor("java.math.BigDecimal", emptyList()), + TypeConstructor("java.math.BigDecimal", emptyList()) + ) + ) + ) + + assertEquals("$kotlinLang/kotlin/java.math.-big-decimal/minus.html", locationProvider.resolve(dri)) + } } diff --git a/plugins/base/src/test/resources/locationProvider/old-package-list b/plugins/base/src/test/resources/locationProvider/old-package-list index bf47a5bb..e2dfc92a 100644 --- a/plugins/base/src/test/resources/locationProvider/old-package-list +++ b/plugins/base/src/test/resources/locationProvider/old-package-list @@ -1,6 +1,7 @@ $dokka.format:kotlin-website-html $dokka.linkExtension:html $dokka.location:kotlin.text.StringBuilderkotlin.relocated.text/-string-builder/index.html +$dokka.location:kotlin$minus(java.math.BigDecimal, java.math.BigDecimal)kotlin/java.math.-big-decimal/minus.html kotlin kotlin.text kotlin.reflect |