All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.dokka.analysis.CallableFactory.kt Maven / Gradle / Ivy

Go to download

Dokka is an API documentation engine for Kotlin and Java, performing the same function as Javadoc for Java

There is a newer version: 1.8.20
Show newest version
package org.jetbrains.dokka.analysis

import com.intellij.psi.PsiField
import com.intellij.psi.PsiMethod
import org.jetbrains.dokka.links.Callable
import org.jetbrains.dokka.links.JavaClassReference
import org.jetbrains.dokka.links.TypeReference
import org.jetbrains.kotlin.descriptors.CallableDescriptor

fun Callable.Companion.from(descriptor: CallableDescriptor, name: String? = null) = with(descriptor) {
    Callable(
        name ?: descriptor.name.asString(),
        extensionReceiverParameter?.let { TypeReference.from(it) },
        valueParameters.mapNotNull { TypeReference.from(it) }
    )
}

fun Callable.Companion.from(psi: PsiMethod) = with(psi) {
    Callable(
        name,
        null,
        parameterList.parameters.map { param -> JavaClassReference(param.type.canonicalText) })
}

fun Callable.Companion.from(psi: PsiField): Callable {
    return Callable(
        name = psi.name,
        receiver = null,
        params = emptyList()
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy