aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2023-02-28 17:26:10 +0200
committerGitHub <noreply@github.com>2023-02-28 17:26:10 +0200
commit8e313553a3435042cdf295d7436b01af4ea4938a (patch)
tree2396cbf22c33a6ec0613a3ad3002d922e834530b /plugins/base/src/main/kotlin
parent00c9142af2c39c9d3636722f1808a211bf971931 (diff)
downloaddokka-8e313553a3435042cdf295d7436b01af4ea4938a.tar.gz
dokka-8e313553a3435042cdf295d7436b01af4ea4938a.tar.bz2
dokka-8e313553a3435042cdf295d7436b01af4ea4938a.zip
Fix unresolved link to declaration from another source set (#2878)
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt27
1 files changed, 19 insertions, 8 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
index cae0ccaf..4934e8f4 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
@@ -89,24 +89,35 @@ open class DokkaLocationProvider(
private fun getLocalLocation(driWithSourceSets: DRIWithSourceSets, context: PageNode?): String? {
val (dri, originalSourceSet) = driWithSourceSets
- val allSourceSets =
+ val allSourceSets: List<Set<DisplaySourceSet>> =
listOf(originalSourceSet) + originalSourceSet.let { oss ->
dokkaContext.configuration.sourceSets.filter { it.sourceSetID in oss.sourceSetIDs }
.flatMap { it.dependentSourceSets }
.mapNotNull { ssid ->
dokkaContext.configuration.sourceSets.find { it.sourceSetID == ssid }?.toDisplaySourceSet()
+ }.map {
+ // be careful `data DisplaySourceSet: Set<DisplaySourceSet>` but `setOf(someDisplaySourceSet) != someDisplaySourceSet`
+ setOf(it)
}
}
- return allSourceSets.asSequence().mapNotNull { displaySourceSet ->
- pagesIndex[DRIWithSourceSets(dri, displaySourceSet)]?.let { page -> resolve(page, context) }
- ?: anchorsIndex[driWithSourceSets]?.let { (page, kind) ->
- val dci = DCI(setOf(dri), kind)
- resolve(page, context) + "#" + anchorForDCI(dci, displaySourceSet)
- }
- }.firstOrNull()
+ return getLocalPageLink(dri, allSourceSets, context)
+ ?: getLocalAnchor(dri, allSourceSets, context)
}
+ private fun getLocalPageLink(dri: DRI, allSourceSets: Iterable<Set<DisplaySourceSet>>, context: PageNode?) =
+ allSourceSets.mapNotNull { displaySourceSet ->
+ pagesIndex[DRIWithSourceSets(dri, displaySourceSet)]
+ }.firstOrNull()?.let { page -> resolve(page, context) }
+
+ private fun getLocalAnchor(dri: DRI, allSourceSets: Iterable<Set<DisplaySourceSet>>, context: PageNode?) =
+ allSourceSets.mapNotNull { displaySourceSet ->
+ anchorsIndex[DRIWithSourceSets(dri, displaySourceSet)]?.let { (page, kind) ->
+ val dci = DCI(setOf(dri), kind)
+ resolve(page, context) + "#" + anchorForDCI(dci, displaySourceSet)
+ }
+ }.firstOrNull()
+
override fun pathToRoot(from: PageNode): String =
pathTo(pageGraphRoot, from).removeSuffix(PAGE_WITH_CHILDREN_SUFFIX)