aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-08-19 12:57:38 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-08-20 15:36:07 +0200
commit45bec5b68c2da35860877c6298bff04a4cb3d1d6 (patch)
treed99b27e6c6100ef93c2989caac66b55ef3ba3e21 /plugins/base
parente4fc2c274fd982b2742eac46581b504b56b2b48f (diff)
downloaddokka-45bec5b68c2da35860877c6298bff04a4cb3d1d6.tar.gz
dokka-45bec5b68c2da35860877c6298bff04a4cb3d1d6.tar.bz2
dokka-45bec5b68c2da35860877c6298bff04a4cb3d1d6.zip
Fix LinkProvider to link properly all nested generic parameters
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt2
-rw-r--r--plugins/base/src/test/kotlin/basic/DRITest.kt2
-rw-r--r--plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt3
-rw-r--r--plugins/base/src/test/kotlin/markdown/LinkTest.kt6
5 files changed, 9 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 823e1e8f..82eeb296 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -239,7 +239,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
)
text(f.modifiers()[it]?.toSignatureString() ?: "")
text("fun ")
- val usedGenerics = f.generics.filter { f uses it }
+ val usedGenerics = if (f.isConstructor) f.generics.filter { f uses it } else f.generics
list(usedGenerics, prefix = "<", suffix = "> ") {
+buildSignature(it)
}
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index b172cebc..05c99af1 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -590,7 +590,7 @@ private class DokkaDescriptorVisitor(
private fun TypeParameterDescriptor.toTypeParameter() =
DTypeParameter(
- DRI.from(this),
+ DRI.from(this).withPackageFallbackTo(fallbackPackageName()),
name.identifier,
resolveDescriptorData(),
null,
diff --git a/plugins/base/src/test/kotlin/basic/DRITest.kt b/plugins/base/src/test/kotlin/basic/DRITest.kt
index ba40a200..7083609a 100644
--- a/plugins/base/src/test/kotlin/basic/DRITest.kt
+++ b/plugins/base/src/test/kotlin/basic/DRITest.kt
@@ -271,7 +271,7 @@ class DRITest : AbstractCoreTest() {
val foo = sampleInner.children.first { it.name == "foo" } as MemberPageNode
val documentable = foo.documentable as DFunction
- assertEquals(sampleClass.dri.first().toString(), (documentable.type as TypeParameter).dri.toString())
+ assertEquals((sampleClass.documentable as WithGenerics).generics.first().dri.toString(), (documentable.type as TypeParameter).dri.toString())
assertEquals(0, documentable.generics.size)
}
}
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index 42d10549..4a7e059c 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -5,6 +5,7 @@ import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.transformers.pages.samples.DefaultSamplesTransformer
import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransformer
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
+import org.jetbrains.dokka.model.WithGenerics
import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.plugin
@@ -220,7 +221,7 @@ class LinkableContentTest : AbstractCoreTest() {
child?.text == "S"
}?.safeAs<ContentDRILink>()
- Assertions.assertEquals(sample.dri.first(), returnTypeNode?.address)
+ Assertions.assertEquals((sample.documentable as WithGenerics).generics.first().dri, returnTypeNode?.address)
}
}
}
diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt
index 32cf01a8..deef1d2d 100644
--- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt
+++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt
@@ -1,5 +1,6 @@
package markdown
+import org.jetbrains.dokka.model.WithGenerics
import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.ClasslikePageNode
import org.jetbrains.dokka.pages.ContentDRILink
@@ -70,9 +71,10 @@ class LinkTest : AbstractCoreTest() {
val root = rootPageNode.children.single().children.single() as ClasslikePageNode
val innerClass = root.children.first { it is ClasslikePageNode }
val foo = innerClass.children.first { it.name == "foo" } as MemberPageNode
+ val destinationDri = (root.documentable as WithGenerics).generics.first().dri.toString()
- assertEquals(root.dri.first().toString(), "[JVM root]/Outer///PointingToDeclaration/")
- assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == root.dri.first().toString() } )
+ assertEquals(destinationDri, "[JVM root]/Outer///PointingToGenericParameters(0)/")
+ assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == destinationDri } )
}
}
}