com.google.devtools.ksp.impl.symbol.kotlin.KSCallableReferenceImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of symbol-processing-cmdline Show documentation
Show all versions of symbol-processing-cmdline Show documentation
Symbol processing for K/N and command line
package com.google.devtools.ksp.impl.symbol.kotlin
import com.google.devtools.ksp.common.IdKeyPair
import com.google.devtools.ksp.common.KSObjectCache
import com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSTypeArgumentResolvedImpl
import com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSTypeReferenceResolvedImpl
import com.google.devtools.ksp.symbol.*
import org.jetbrains.kotlin.analysis.api.types.KaFunctionType
import org.jetbrains.kotlin.analysis.api.types.KaType
// TODO: implement a psi based version, rename this class to resolved Impl.
class KSCallableReferenceImpl private constructor(
private val ktFunctionalType: KaFunctionType,
override val parent: KSNode?
) : KSCallableReference {
companion object : KSObjectCache, KSCallableReference>() {
fun getCached(ktFunctionalType: KaFunctionType, parent: KSNode?): KSCallableReference =
cache.getOrPut(IdKeyPair(ktFunctionalType, parent)) { KSCallableReferenceImpl(ktFunctionalType, parent) }
}
override val receiverType: KSTypeReference?
get() = ktFunctionalType.receiverType?.let { KSTypeReferenceResolvedImpl.getCached(it) }
override val functionParameters: List
get() = ktFunctionalType.parameterTypes.map {
KSValueParameterLiteImpl.getCached(it, this@KSCallableReferenceImpl)
}
override val returnType: KSTypeReference
get() = KSTypeReferenceResolvedImpl.getCached(ktFunctionalType.returnType)
override val typeArguments: List
get() = ktFunctionalType.typeArguments().map { KSTypeArgumentResolvedImpl.getCached(it, this) }
override val origin: Origin
get() = parent?.origin ?: Origin.SYNTHETIC
override val location: Location
get() = parent?.location ?: NonExistLocation
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy