aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt
diff options
context:
space:
mode:
authorEugene Petrenko <eugene.petrenko@gmail.com>2018-09-11 14:03:29 +0300
committerEugene Petrenko <eugene.petrenko@gmail.com>2018-09-11 14:03:29 +0300
commita54070f5db04d05b48c369b211efe044fbc02a8d (patch)
treeaac5889906f49f68c39e1416ea39d4d19bad008e /core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt
parente29f1c966056b0f7ee31dd9bd7d55f9e526fa7fe (diff)
parent0df19264ccae3d294946caf634ee15eea0c4fe4a (diff)
downloaddokka-a54070f5db04d05b48c369b211efe044fbc02a8d.tar.gz
dokka-a54070f5db04d05b48c369b211efe044fbc02a8d.tar.bz2
dokka-a54070f5db04d05b48c369b211efe044fbc02a8d.zip
Merge remote-tracking branch 'zub/dev-multiplatf' into kotlin-website-jonnyzzz
Diffstat (limited to 'core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt')
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt
new file mode 100644
index 00000000..20ea179e
--- /dev/null
+++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt
@@ -0,0 +1,25 @@
+package org.jetbrains.dokka
+
+import com.intellij.psi.PsiElement
+import org.jetbrains.kotlin.asJava.toLightElements
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.psi.KtElement
+
+class KotlinAsJavaElementSignatureProvider : ElementSignatureProvider {
+
+ private fun PsiElement.javaLikePsi() = when {
+ this is KtElement -> toLightElements().firstOrNull()
+ else -> this
+ }
+
+ override fun signature(forPsi: PsiElement): String {
+ return getSignature(forPsi.javaLikePsi()) ?:
+ "not implemented for $forPsi"
+ }
+
+ override fun signature(forDesc: DeclarationDescriptor): String {
+ val sourcePsi = forDesc.sourcePsi()
+ return getSignature(sourcePsi?.javaLikePsi()) ?:
+ "not implemented for $forDesc with psi: $sourcePsi"
+ }
+} \ No newline at end of file