aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt')
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
index 0a095153..6d3ad215 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.base.resolvers.local
import org.jetbrains.dokka.DokkaException
+import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider.Companion.identifierToFilename
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.pages.PageNode
@@ -10,6 +11,18 @@ interface LocationProvider {
fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String?
fun pathToRoot(from: PageNode): String
fun ancestors(node: PageNode): List<PageNode>
+
+ /**
+ * This method should return guessed filesystem location for a given [DRI]
+ * It is used to decide if a [DRI] should be present in the relocation list of the
+ * generated package-list so it is ok if the path differs from the one returned by [resolve]
+ * @return Path to a giver [DRI] or null if path should not be considered for relocations
+ */
+ fun expectedLocationForDri(dri: DRI): String =
+ (listOf(dri.packageName) +
+ dri.classNames?.split(".")?.map { identifierToFilename(it) }.orEmpty() +
+ listOf(dri.callable?.let { identifierToFilename(it.name) } ?: "index")
+ ).filterNotNull().joinToString("/")
}
fun LocationProvider.resolveOrThrow(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode? = null): String =