aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-08-19 15:23:53 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-08-20 15:36:07 +0200
commitfab2d4ba4f13454ab36ea7ee333579bf3441f2ed (patch)
treeb5ca2c962c8524e8708f63c4ad1eade282c6ac3a /plugins/base/src
parent45bec5b68c2da35860877c6298bff04a4cb3d1d6 (diff)
downloaddokka-fab2d4ba4f13454ab36ea7ee333579bf3441f2ed.tar.gz
dokka-fab2d4ba4f13454ab36ea7ee333579bf3441f2ed.tar.bz2
dokka-fab2d4ba4f13454ab36ea7ee333579bf3441f2ed.zip
Fix tests after bad rebase
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt43
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt18
2 files changed, 29 insertions, 32 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
index ca2332db..096104cc 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
@@ -2,6 +2,7 @@ package org.jetbrains.dokka.base.resolvers.local
import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.model.withDescendants
import org.jetbrains.dokka.pages.*
@@ -25,30 +26,38 @@ open class DokkaLocationProvider(
pageGraphRoot.children.forEach { registerPath(it, emptyList()) }
}
- protected open val pagesIndex: Map<DRI, ContentPage> = pageGraphRoot.withDescendants().filterIsInstance<ContentPage>()
- .flatMap { it.dri.map { dri -> dri to it } }
- .groupingBy { it.first }
- .aggregate { dri, _, (_, page), first ->
- if (first) page else throw AssertionError("Multiple pages associated with dri: $dri")
- }
-
- protected open val anchorsIndex: Map<DRI, ContentPage> = pageGraphRoot.withDescendants().filterIsInstance<ContentPage>()
- .flatMap { page ->
- page.content.withDescendants()
- .filter { it.extra[SymbolAnchorHint] != null }
- .mapNotNull { it.dci.dri.singleOrNull() }
- .distinct()
- .map { it to page }
- }.toMap()
+ protected open val pagesIndex: Map<DRI, ContentPage> =
+ pageGraphRoot.withDescendants().filterIsInstance<ContentPage>()
+ .flatMap { it.dri.map { dri -> dri to it } }
+ .groupingBy { it.first }
+ .aggregate { dri, _, (_, page), first ->
+ if (first) page else throw AssertionError("Multiple pages associated with dri: $dri")
+ }
+
+ protected open val anchorsIndex: Map<DRI, ContentPage> =
+ pageGraphRoot.withDescendants().filterIsInstance<ContentPage>()
+ .flatMap { page ->
+ page.content.withDescendants()
+ .filter { it.extra[SymbolAnchorHint] != null }
+ .mapNotNull { it.dci.dri.singleOrNull() }
+ .distinct()
+ .map { it to page }
+ }.toMap()
override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) =
pathTo(node, context) + if (!skipExtension) extension else ""
override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) =
- pagesIndex[dri]?.let { resolve(it, context) }
- ?: anchorsIndex[dri]?.let { resolve(it, context) + "#$dri" }
+ getLocalLocation(dri, context)
+ ?: getLocalLocation(dri.copy(target = PointingToDeclaration), context)
// Not found in PageGraph, that means it's an external link
?: getExternalLocation(dri, sourceSets)
+ ?: getExternalLocation(dri.copy(target = PointingToDeclaration), sourceSets)
+
+ private fun getLocalLocation(dri: DRI, context: PageNode?): String? =
+ pagesIndex[dri]?.let { resolve(it, context) }
+ ?: anchorsIndex[dri]?.let { resolve(it, context) + "#$dri" }
+
override fun pathToRoot(from: PageNode): String =
pathTo(pageGraphRoot, from).removeSuffix(PAGE_WITH_CHILDREN_SUFFIX)
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index f33ad5bd..52211998 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -453,15 +453,6 @@ class SignatureTest : AbstractCoreTest() {
@Test
fun `generic constructor params`() {
- val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- moduleName = "test"
- name = "common"
- sourceRoots = listOf("src/main/kotlin/common/Test.kt")
- }
- }
- }
val writerPlugin = TestOutputWriterPlugin()
@@ -470,8 +461,6 @@ class SignatureTest : AbstractCoreTest() {
|/src/main/kotlin/common/Test.kt
|package example
|
- |import java.util.*
- |
|class GenericClass<T>(val x: Int) {
| constructor(x: T) : this(1)
|
@@ -481,7 +470,7 @@ class SignatureTest : AbstractCoreTest() {
|
| constructor(x: Boolean, y: Int, z: String) : this(1)
|
- | constructor(x: List<Comparable<ServiceLoader<T>>>?) : this(1)
+ | constructor(x: List<Comparable<Lazy<T>>>?) : this(1)
|}
|
""".trimMargin(),
@@ -489,16 +478,15 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("test/example/-generic-class/-generic-class.html").signature().zip(
+ writerPlugin.writer.renderedContent("root/example/-generic-class/-generic-class.html").signature().zip(
listOf(
arrayOf("fun <", A("T"), "> ", A("GenericClass"), "(x: ", A("T"), ")", Span()),
arrayOf("fun ", A("GenericClass"), "(x: ", A("Int"), ", y: ", A("String"), ")", Span()),
arrayOf("fun <", A("T"), "> ", A("GenericClass"), "(x: ", A("Int"), ", y: ", A("List"), "<", A("T"), ">)", Span()),
arrayOf("fun ", A("GenericClass"), "(x: ", A("Boolean"), ", y: ", A("Int"), ", z:", A("String"), ")", Span()),
arrayOf("fun <", A("T"), "> ", A("GenericClass"), "(x: ", A("List"), "<", A("Comparable"),
- "<", A("ServiceLoader"), "<", A("T"), ">>>?)", Span()),
+ "<", A("Lazy"), "<", A("T"), ">>>?)", Span()),
arrayOf("fun ", A("GenericClass"), "(x: ", A("Int"), ")", Span()),
-
)
).forEach {
it.first.match(*it.second)