aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-19 13:15:49 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-19 13:34:10 +0200
commit3100728f92e8d4ce828609d7447c3b486230218a (patch)
tree9ae9fcf8c4a91898f46d4473d17efdc07d73bae2 /plugins
parenta3216f85650e1b4ed6c6cb73186d6d05ebd4e99e (diff)
downloaddokka-3100728f92e8d4ce828609d7447c3b486230218a.tar.gz
dokka-3100728f92e8d4ce828609d7447c3b486230218a.tar.bz2
dokka-3100728f92e8d4ce828609d7447c3b486230218a.zip
LocationProvider: Implement new `resolveOrThrow` API
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt9
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt9
2 files changed, 14 insertions, 4 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
index 3775e94e..0a095153 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.base.resolvers.local
+import org.jetbrains.dokka.DokkaException
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.pages.PageNode
@@ -10,3 +11,11 @@ interface LocationProvider {
fun pathToRoot(from: PageNode): String
fun ancestors(node: PageNode): List<PageNode>
}
+
+fun LocationProvider.resolveOrThrow(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode? = null): String =
+ resolve(dri = dri, sourceSets = sourceSets, context = context)
+ ?: throw DokkaException("Cannot resolve path for $dri")
+
+fun LocationProvider.resolveOrThrow(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String =
+ resolve(node = node, context = context, skipExtension = skipExtension)
+ ?: throw DokkaException("Cannot resolve path for ${node.name}")
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
index c811ace3..589aeb51 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
@@ -6,6 +6,7 @@ import org.jetbrains.dokka.javadoc.renderer.SearchRecord.Companion.allTypes
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.DokkaException
import org.jetbrains.dokka.base.renderers.sourceSets
+import org.jetbrains.dokka.base.resolvers.local.resolveOrThrow
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.model.Documentable
@@ -105,7 +106,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
packageName = it.first.name,
classlikeName = it.second.name,
input = function,
- url = locationProvider.resolve(function.dri, it.first.sourceSets()) ?: throw DokkaException("Cannot resolve path for ${function.dri}")
+ url = locationProvider.resolveOrThrow(function.dri, it.first.sourceSets())
)
}
}
@@ -116,7 +117,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
packageName = it.first.name,
classlikeName = it.second.name,
property,
- locationProvider.resolve(property.dri, it.first.sourceSets())?: throw DokkaException("Cannot resolve path for ${property.dri}")
+ locationProvider.resolveOrThrow(property.dri, it.first.sourceSets())
)
}
}
@@ -127,7 +128,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
packageName = it.first.name,
classlikeName = it.second.name,
entry,
- locationProvider.resolve(entry.dri, it.first.sourceSets()) ?: throw DokkaException("Cannot resolve path for ${entry.dri}")
+ locationProvider.resolveOrThrow(entry.dri, it.first.sourceSets())
)
}
}
@@ -187,7 +188,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
sourceSets: Set<DisplaySourceSet>,
label: String
): String =
- locationProvider.resolve(dri, sourceSets)!!.formatToEndWithHtml() + "#" + label
+ locationProvider.resolveOrThrow(dri, sourceSets).formatToEndWithHtml() + "#" + label
}
private data class SearchRecord(