[cls] include annotation arguments in cls stubs
^ KTIJ-24666 this would allow to build fir based on stubs, do not keep ProtoBuf in memory and search in decompiled code by stubs
This commit is contained in:
-7
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.load.kotlin
|
||||
import org.jetbrains.kotlin.SpecialJvmAnnotations
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.load.kotlin.AbstractBinaryClassAnnotationAndConstantLoader.AnnotationsContainerWithConstants
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
@@ -161,11 +160,5 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any>(
|
||||
val normalClass = containerKClassValue.value as? KClassValue.Value.NormalClass ?: return false
|
||||
return isImplicitRepeatableContainer(normalClass.classId)
|
||||
}
|
||||
|
||||
class AnnotationsContainerWithConstants<out A, out C>(
|
||||
override val memberAnnotations: Map<MemberSignature, List<A>>,
|
||||
val propertyConstants: Map<MemberSignature, C>,
|
||||
val annotationParametersDefaultValues: Map<MemberSignature, C>
|
||||
) : AbstractBinaryClassAnnotationLoader.AnnotationsContainer<A>()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class BinaryClassAnnotationAndConstantLoaderImpl(
|
||||
|
||||
override var jvmMetadataVersion: JvmMetadataVersion = JvmMetadataVersion.INSTANCE
|
||||
|
||||
override fun loadTypeAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): AnnotationDescriptor =
|
||||
override fun loadAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): AnnotationDescriptor =
|
||||
annotationDeserializer.deserializeAnnotation(proto, nameResolver)
|
||||
|
||||
override fun loadConstant(desc: String, initializer: Any): ConstantValue<*>? {
|
||||
|
||||
+9
-3
@@ -36,7 +36,7 @@ abstract class AbstractBinaryClassAnnotationLoader<A : Any, S : AbstractBinaryCl
|
||||
result: MutableList<A>
|
||||
): KotlinJvmBinaryClass.AnnotationArgumentVisitor?
|
||||
|
||||
protected abstract fun loadTypeAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): A
|
||||
abstract override fun loadAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): A
|
||||
|
||||
protected fun loadAnnotationIfNotSpecial(
|
||||
annotationClassId: ClassId,
|
||||
@@ -194,11 +194,11 @@ abstract class AbstractBinaryClassAnnotationLoader<A : Any, S : AbstractBinaryCl
|
||||
}
|
||||
|
||||
override fun loadTypeAnnotations(proto: ProtoBuf.Type, nameResolver: NameResolver): List<A> {
|
||||
return proto.getExtension(JvmProtoBuf.typeAnnotation).map { loadTypeAnnotation(it, nameResolver) }
|
||||
return proto.getExtension(JvmProtoBuf.typeAnnotation).map { loadAnnotation(it, nameResolver) }
|
||||
}
|
||||
|
||||
override fun loadTypeParameterAnnotations(proto: ProtoBuf.TypeParameter, nameResolver: NameResolver): List<A> {
|
||||
return proto.getExtension(JvmProtoBuf.typeParameterAnnotation).map { loadTypeAnnotation(it, nameResolver) }
|
||||
return proto.getExtension(JvmProtoBuf.typeParameterAnnotation).map { loadAnnotation(it, nameResolver) }
|
||||
}
|
||||
|
||||
protected fun findClassWithAnnotationsAndInitializers(
|
||||
@@ -309,6 +309,12 @@ abstract class AbstractBinaryClassAnnotationLoader<A : Any, S : AbstractBinaryCl
|
||||
}
|
||||
}
|
||||
|
||||
class AnnotationsContainerWithConstants<out A, out C>(
|
||||
override val memberAnnotations: Map<MemberSignature, List<A>>,
|
||||
val propertyConstants: Map<MemberSignature, C>,
|
||||
val annotationParametersDefaultValues: Map<MemberSignature, C>
|
||||
) : AbstractBinaryClassAnnotationLoader.AnnotationsContainer<A>()
|
||||
|
||||
fun getPropertySignature(
|
||||
proto: ProtoBuf.Property,
|
||||
nameResolver: NameResolver,
|
||||
|
||||
+2
@@ -60,4 +60,6 @@ interface AnnotationLoader<out A : Any> {
|
||||
proto: ProtoBuf.TypeParameter,
|
||||
nameResolver: NameResolver
|
||||
): List<A>
|
||||
|
||||
fun loadAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): A
|
||||
}
|
||||
+4
@@ -39,6 +39,10 @@ class AnnotationAndConstantLoaderImpl(
|
||||
return annotations.map { proto -> deserializer.deserializeAnnotation(proto, container.nameResolver) }
|
||||
}
|
||||
|
||||
override fun loadAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): AnnotationDescriptor {
|
||||
return deserializer.deserializeAnnotation(proto, nameResolver)
|
||||
}
|
||||
|
||||
override fun loadCallableAnnotations(
|
||||
container: ProtoContainer,
|
||||
proto: MessageLite,
|
||||
|
||||
Reference in New Issue
Block a user