aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2019-03-18 21:56:14 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2019-03-18 21:56:14 +0300
commit4b22ebab09ce3b934443d063df6b905e5347c390 (patch)
treef353662dc777107773adf8a5b3cac07b09ab3255 /core/src/main/kotlin/Kotlin/KotlinAsJavaElementSignatureProvider.kt
parent0fa9b69b6afe762e5aee7b7cf801a38ebe74b2c9 (diff)
parentb566f8852e94f9a17be86bf845aeff6c36bd8378 (diff)
downloaddokka-4b22ebab09ce3b934443d063df6b905e5347c390.tar.gz
dokka-4b22ebab09ce3b934443d063df6b905e5347c390.tar.bz2
dokka-4b22ebab09ce3b934443d063df6b905e5347c390.zip
Merge branch 'dev-pre' into dev
# Conflicts: # core/src/main/kotlin/Model/PackageDocs.kt
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