diff options
10 files changed, 15 insertions, 15 deletions
diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt index 513817f3..217a3b7d 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt @@ -1,9 +1,6 @@ package org.jetbrains.dokka.analysis -import com.intellij.psi.PsiClass -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiField -import com.intellij.psi.PsiMethod +import com.intellij.psi.* import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.DriTarget @@ -28,7 +25,7 @@ fun DRI.Companion.from(descriptor: DeclarationDescriptor) = descriptor.parentsWi fun DRI.Companion.from(psi: PsiElement) = psi.parentsWithSelf.run { val psiMethod = firstIsInstanceOrNull<PsiMethod>() val psiField = firstIsInstanceOrNull<PsiField>() - val classes = filterIsInstance<PsiClass>().toList() + val classes = filterIsInstance<PsiClass>().filterNot { it is PsiTypeParameter }.toList() // We only want exact PsiClass types, not PsiTypeParameter subtype DRI( classes.lastOrNull()?.qualifiedName?.substringBeforeLast('.', ""), classes.toList().takeIf { it.isNotEmpty() }?.asReversed()?.mapNotNull { it.name }?.joinToString("."), 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 } ) } } } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt index 96616794..d9aed18f 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt @@ -95,7 +95,7 @@ class JavadocSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLo modifiers { text(f.modifier[it]?.takeIf { it !in ignoredModifiers }?.name?.plus(" ") ?: "") text(f.modifiers()[it]?.toSignatureString() ?: "") - 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/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt index 2ae5302d..30a9f764 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt @@ -312,7 +312,7 @@ internal class JavadocClasslikeTemplateMapTest : AbstractJavadocTemplateMapTest( val ownMethods = assertIsInstance<List<*>>(methods["own"]).first() val sampleFunction = assertIsInstance<Map<String, Any?>>(ownMethods) - assertEquals("final <D extends <a href=Generic.html>T</a>> <a href=Generic.html#sampleFunction()>D</a> <a href=Generic.html#sampleFunction()>sampleFunction</a>()", sampleFunction.signatureWithModifiers()) + assertEquals("final <D extends <a href=Generic.html#Generic>T</a>> <a href=Generic.html#sampleFunction()>D</a> <a href=Generic.html#sampleFunction()>sampleFunction</a>()", sampleFunction.signatureWithModifiers()) } } diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt index afea5914..cd0a8e8f 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt @@ -110,7 +110,7 @@ class JavadocTest : AbstractCoreTest() { .firstChildOfType<JavadocClasslikePageNode> { it.name == "Test" } val testFunctionNode = testClassNode.methods.first { it.name == "test3" } assertEquals( - """<a href=Test.html#test3(A,T)>test3</a>(<a href=Test.html>A</a> a, <a href=Test.html#test3(A,T)>T</a> t)""", + """<a href=Test.html#test3(A,T)>test3</a>(<a href=Test.html#Test>A</a> a, <a href=Test.html#test3(A,T)>T</a> t)""", transformer.htmlForContentNode( testFunctionNode.signature.signatureWithoutModifiers, testClassNode diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index b15e1a0d..5134bd4d 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -122,7 +122,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge signatureForProjection(returnType) text(nbsp.toString()) link(f.name, f.dri) - 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) } |