Analysis API: introduce annotation value for KClass
This commit is contained in:
+11
-3
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedType
|
||||
@@ -280,8 +281,16 @@ internal fun ConstantValue<*>.toKtConstantValue(): KtConstantValue {
|
||||
|
||||
internal fun ConstantValue<*>.toKtAnnotationValue(): KtAnnotationValue {
|
||||
return when (this) {
|
||||
is ArrayValue -> KtArrayAnnotationValue(value.map { it.toKtAnnotationValue() }, null)
|
||||
is EnumValue -> KtEnumEntryAnnotationValue(CallableId(enumClassId, enumEntryName), null)
|
||||
is ArrayValue -> KtArrayAnnotationValue(value.map { it.toKtAnnotationValue() }, sourcePsi = null)
|
||||
is EnumValue -> KtEnumEntryAnnotationValue(CallableId(enumClassId, enumEntryName), sourcePsi = null)
|
||||
is KClassValue -> when (val value = value) {
|
||||
is KClassValue.Value.LocalClass -> {
|
||||
val descriptor = value.type.constructor.declarationDescriptor as ClassDescriptor
|
||||
KtLocalKClassAnnotationValue(descriptor.source.getPsi() as KtClassOrObject, sourcePsi = null)
|
||||
}
|
||||
is KClassValue.Value.NormalClass -> KtNonLocalKClassAnnotationValue(value.classId, sourcePsi = null)
|
||||
}
|
||||
|
||||
is AnnotationValue -> {
|
||||
KtAnnotationApplicationValue(
|
||||
KtAnnotationApplication(
|
||||
@@ -292,7 +301,6 @@ internal fun ConstantValue<*>.toKtAnnotationValue(): KtAnnotationValue {
|
||||
)
|
||||
)
|
||||
}
|
||||
is KClassValue -> KtKClassValue(cl)
|
||||
else -> {
|
||||
KtConstantAnnotationValue(toKtConstantValue())
|
||||
}
|
||||
|
||||
+2
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
internal class KtFe10TypeRenderer(private val options: KtTypeRendererOptions, private val isDebugText: Boolean = false) {
|
||||
private companion object {
|
||||
@@ -118,6 +119,7 @@ internal class KtFe10TypeRenderer(private val options: KtTypeRendererOptions, pr
|
||||
is KtEnumEntryAnnotationValue -> append(value.callableId)
|
||||
is KtConstantAnnotationValue -> append(value.constantValue.constantValueKind.asString).append("(").append(value.constantValue.value).append(")")
|
||||
KtUnsupportedAnnotationValue -> append(KtUnsupportedAnnotationValue::class.java.simpleName)
|
||||
is KtKClassAnnotationValue -> append(value.render())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user