1 package org.jetbrains.dokka 2 3 import com.intellij.psi.PsiElement 4 import org.jetbrains.kotlin.asJava.toLightElements 5 import org.jetbrains.kotlin.descriptors.DeclarationDescriptor 6 import org.jetbrains.kotlin.psi.KtElement 7 8 class KotlinAsJavaElementSignatureProvider : ElementSignatureProvider { 9 javaLikePsinull10 private fun PsiElement.javaLikePsi() = when { 11 this is KtElement -> toLightElements().firstOrNull() 12 else -> this 13 } 14 signaturenull15 override fun signature(forPsi: PsiElement): String { 16 return getSignature(forPsi.javaLikePsi()) ?: 17 "not implemented for $forPsi" 18 } 19 signaturenull20 override fun signature(forDesc: DeclarationDescriptor): String { 21 val sourcePsi = forDesc.sourcePsi() 22 return getSignature(sourcePsi?.javaLikePsi()) ?: 23 "not implemented for $forDesc with psi: $sourcePsi" 24 } 25 }