aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/Kotlin')
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt7
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt17
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt9
3 files changed, 31 insertions, 2 deletions
diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
index 2b085769..275972fa 100644
--- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka
import com.google.inject.Inject
+import org.jetbrains.dokka.Model.DescriptorSignatureProvider
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
@@ -10,7 +11,8 @@ class DeclarationLinkResolver
val refGraph: NodeReferenceGraph,
val logger: DokkaLogger,
val options: DocumentationOptions,
- val externalDocumentationLinkResolver: ExternalDocumentationLinkResolver) {
+ val externalDocumentationLinkResolver: ExternalDocumentationLinkResolver,
+ val descriptorSignatureProvider: DescriptorSignatureProvider) {
fun tryResolveContentLink(fromDescriptor: DeclarationDescriptor, href: String): ContentBlock? {
@@ -29,7 +31,8 @@ class DeclarationLinkResolver
if (externalHref != null) {
return ContentExternalLink(externalHref)
}
- return ContentNodeLazyLink(href, { -> refGraph.lookupOrWarn(symbol.signature(), logger) })
+ val signature = descriptorSignatureProvider.signature(symbol)
+ return ContentNodeLazyLink(href, { -> refGraph.lookupOrWarn(signature, logger) })
}
if ("/" in href) {
return ContentExternalLink(href)
diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt
new file mode 100644
index 00000000..ca15b89f
--- /dev/null
+++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt
@@ -0,0 +1,17 @@
+package org.jetbrains.dokka.Kotlin
+
+import org.jetbrains.dokka.Model.DescriptorSignatureProvider
+import org.jetbrains.dokka.getSignature
+import org.jetbrains.dokka.sourcePsi
+import org.jetbrains.kotlin.asJava.toLightElements
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.psi.KtElement
+
+class KotlinAsJavaDescriptorSignatureProvider : DescriptorSignatureProvider {
+ override fun signature(forDesc: DeclarationDescriptor): String {
+
+ val sourcePsi = forDesc.sourcePsi() as? KtElement
+ return getSignature(sourcePsi?.toLightElements().orEmpty().firstOrNull()) ?:
+ throw UnsupportedOperationException("Don't know how to calculate signature for $forDesc")
+ }
+} \ No newline at end of file
diff --git a/core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt
new file mode 100644
index 00000000..7ecd0389
--- /dev/null
+++ b/core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt
@@ -0,0 +1,9 @@
+package org.jetbrains.dokka.Kotlin
+
+import org.jetbrains.dokka.Model.DescriptorSignatureProvider
+import org.jetbrains.dokka.signature
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+
+class KotlinDescriptorSignatureProvider : DescriptorSignatureProvider {
+ override fun signature(forDesc: DeclarationDescriptor): String = forDesc.signature()
+} \ No newline at end of file