Reformat module 'serialization', fix inspections

This commit is contained in:
Alexander Udalov
2019-03-07 14:23:54 +01:00
parent a269e9bc00
commit e942bff4a2
6 changed files with 109 additions and 112 deletions
@@ -61,7 +61,7 @@ class AnnotationSerializer(private val stringTable: DescriptorAwareStringTable)
override fun visitBooleanValue(value: BooleanValue, data: Unit) { override fun visitBooleanValue(value: BooleanValue, data: Unit) {
type = Type.BOOLEAN type = Type.BOOLEAN
setIntValue(if (value.value) 1 else 0) intValue = if (value.value) 1 else 0
} }
override fun visitByteValue(value: ByteValue, data: Unit) { override fun visitByteValue(value: ByteValue, data: Unit) {
@@ -63,10 +63,10 @@ class ContractSerializer {
is ReturnsEffectDeclaration -> { is ReturnsEffectDeclaration -> {
when { when {
effectDeclaration.value == ConstantReference.NOT_NULL -> builder.effectType = effectDeclaration.value == ConstantReference.NOT_NULL ->
ProtoBuf.Effect.EffectType.RETURNS_NOT_NULL builder.effectType = ProtoBuf.Effect.EffectType.RETURNS_NOT_NULL
effectDeclaration.value == ConstantReference.WILDCARD -> builder.effectType = effectDeclaration.value == ConstantReference.WILDCARD ->
ProtoBuf.Effect.EffectType.RETURNS_CONSTANT builder.effectType = ProtoBuf.Effect.EffectType.RETURNS_CONSTANT
else -> { else -> {
builder.effectType = ProtoBuf.Effect.EffectType.RETURNS_CONSTANT builder.effectType = ProtoBuf.Effect.EffectType.RETURNS_CONSTANT
builder.addEffectConstructorArgument(contractExpressionProto(effectDeclaration.value, contractDescription)) builder.addEffectConstructorArgument(contractExpressionProto(effectDeclaration.value, contractDescription))
@@ -41,18 +41,20 @@ import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes
import java.util.* import java.util.*
class DescriptorSerializer private constructor( class DescriptorSerializer private constructor(
private val containingDeclaration: DeclarationDescriptor?, private val containingDeclaration: DeclarationDescriptor?,
private val typeParameters: Interner<TypeParameterDescriptor>, private val typeParameters: Interner<TypeParameterDescriptor>,
private val extension: SerializerExtension, private val extension: SerializerExtension,
val typeTable: MutableTypeTable, val typeTable: MutableTypeTable,
private val versionRequirementTable: MutableVersionRequirementTable, private val versionRequirementTable: MutableVersionRequirementTable,
private val serializeTypeTableToFunction: Boolean private val serializeTypeTableToFunction: Boolean
) { ) {
private val contractSerializer = ContractSerializer() private val contractSerializer = ContractSerializer()
fun createChildSerializer(descriptor: DeclarationDescriptor): DescriptorSerializer = private fun createChildSerializer(descriptor: DeclarationDescriptor): DescriptorSerializer =
DescriptorSerializer(descriptor, Interner(typeParameters), extension, typeTable, versionRequirementTable, DescriptorSerializer(
serializeTypeTableToFunction = false) descriptor, Interner(typeParameters), extension, typeTable, versionRequirementTable,
serializeTypeTableToFunction = false
)
val stringTable: DescriptorAwareStringTable val stringTable: DescriptorAwareStringTable
get() = extension.stringTable get() = extension.stringTable
@@ -84,8 +86,7 @@ class DescriptorSerializer private constructor(
for (supertype in classDescriptor.typeConstructor.supertypes) { for (supertype in classDescriptor.typeConstructor.supertypes) {
if (useTypeTable()) { if (useTypeTable()) {
builder.addSupertypeId(typeId(supertype)) builder.addSupertypeId(typeId(supertype))
} } else {
else {
builder.addSupertype(type(supertype)) builder.addSupertype(type(supertype))
} }
} }
@@ -98,10 +99,10 @@ class DescriptorSerializer private constructor(
} }
val callableMembers = val callableMembers =
extension.customClassMembersProducer?.getCallableMembers(classDescriptor) extension.customClassMembersProducer?.getCallableMembers(classDescriptor)
?: sort( ?: sort(
DescriptorUtils.getAllDescriptors(classDescriptor.defaultType.memberScope) DescriptorUtils.getAllDescriptors(classDescriptor.defaultType.memberScope)
.filterIsInstance<CallableMemberDescriptor>() .filterIsInstance<CallableMemberDescriptor>()
) )
for (descriptor in callableMembers) { for (descriptor in callableMembers) {
@@ -117,8 +118,7 @@ class DescriptorSerializer private constructor(
for (descriptor in nestedClassifiers) { for (descriptor in nestedClassifiers) {
if (descriptor is TypeAliasDescriptor) { if (descriptor is TypeAliasDescriptor) {
typeAliasProto(descriptor)?.let { builder.addTypeAlias(it) } typeAliasProto(descriptor)?.let { builder.addTypeAlias(it) }
} } else {
else {
if (descriptor is ClassDescriptor && !extension.shouldSerializeNestedClass(descriptor)) { if (descriptor is ClassDescriptor && !extension.shouldSerializeNestedClass(descriptor)) {
continue continue
} }
@@ -126,8 +126,7 @@ class DescriptorSerializer private constructor(
val name = getSimpleNameIndex(descriptor.name) val name = getSimpleNameIndex(descriptor.name)
if (isEnumEntry(descriptor)) { if (isEnumEntry(descriptor)) {
builder.addEnumEntry(enumEntryProto(descriptor as ClassDescriptor)) builder.addEnumEntry(enumEntryProto(descriptor as ClassDescriptor))
} } else {
else {
builder.addNestedClassName(name) builder.addNestedClassName(name)
} }
} }
@@ -168,7 +167,7 @@ class DescriptorSerializer private constructor(
if (!classDescriptor.isInline && !classDescriptor.hasInlineClassTypesInSignature()) return if (!classDescriptor.isInline && !classDescriptor.hasInlineClassTypesInSignature()) return
builder.addVersionRequirement( builder.addVersionRequirement(
DescriptorSerializer.writeLanguageVersionRequirement(LanguageFeature.InlineClasses, versionRequirementTable) writeLanguageVersionRequirement(LanguageFeature.InlineClasses, versionRequirementTable)
) )
} }
@@ -246,8 +245,7 @@ class DescriptorSerializer private constructor(
if (useTypeTable()) { if (useTypeTable()) {
builder.returnTypeId = local.typeId(descriptor.type) builder.returnTypeId = local.typeId(descriptor.type)
} } else {
else {
builder.setReturnType(local.type(descriptor.type)) builder.setReturnType(local.type(descriptor.type))
} }
@@ -259,8 +257,7 @@ class DescriptorSerializer private constructor(
if (receiverParameter != null) { if (receiverParameter != null) {
if (useTypeTable()) { if (useTypeTable()) {
builder.receiverTypeId = local.typeId(receiverParameter.type) builder.receiverTypeId = local.typeId(receiverParameter.type)
} } else {
else {
builder.setReceiverType(local.type(receiverParameter.type)) builder.setReceiverType(local.type(receiverParameter.type))
} }
} }
@@ -281,11 +278,11 @@ class DescriptorSerializer private constructor(
} }
private fun normalizeVisibility(descriptor: DeclarationDescriptorWithVisibility) = private fun normalizeVisibility(descriptor: DeclarationDescriptorWithVisibility) =
// It can be necessary for Java classes serialization having package-private visibility // It can be necessary for Java classes serialization having package-private visibility
if (extension.shouldUseNormalizedVisibility()) if (extension.shouldUseNormalizedVisibility())
descriptor.visibility.normalize() descriptor.visibility.normalize()
else else
descriptor.visibility descriptor.visibility
fun functionProto(descriptor: FunctionDescriptor): ProtoBuf.Function.Builder? { fun functionProto(descriptor: FunctionDescriptor): ProtoBuf.Function.Builder? {
if (!extension.shouldSerializeFunction(descriptor)) return null if (!extension.shouldSerializeFunction(descriptor)) return null
@@ -310,8 +307,7 @@ class DescriptorSerializer private constructor(
if (useTypeTable()) { if (useTypeTable()) {
builder.returnTypeId = local.typeId(descriptor.returnType!!) builder.returnTypeId = local.typeId(descriptor.returnType!!)
} } else {
else {
builder.setReturnType(local.type(descriptor.returnType!!)) builder.setReturnType(local.type(descriptor.returnType!!))
} }
@@ -323,8 +319,7 @@ class DescriptorSerializer private constructor(
if (receiverParameter != null) { if (receiverParameter != null) {
if (useTypeTable()) { if (useTypeTable()) {
builder.receiverTypeId = local.typeId(receiverParameter.type) builder.receiverTypeId = local.typeId(receiverParameter.type)
} } else {
else {
builder.setReceiverType(local.type(receiverParameter.type)) builder.setReceiverType(local.type(receiverParameter.type))
} }
} }
@@ -357,7 +352,7 @@ class DescriptorSerializer private constructor(
return builder return builder
} }
fun constructorProto(descriptor: ConstructorDescriptor): ProtoBuf.Constructor.Builder { private fun constructorProto(descriptor: ConstructorDescriptor): ProtoBuf.Constructor.Builder {
val builder = ProtoBuf.Constructor.newBuilder() val builder = ProtoBuf.Constructor.newBuilder()
val local = createChildSerializer(descriptor) val local = createChildSerializer(descriptor)
@@ -430,16 +425,14 @@ class DescriptorSerializer private constructor(
val underlyingType = descriptor.underlyingType val underlyingType = descriptor.underlyingType
if (useTypeTable()) { if (useTypeTable()) {
builder.underlyingTypeId = local.typeId(underlyingType) builder.underlyingTypeId = local.typeId(underlyingType)
} } else {
else {
builder.setUnderlyingType(local.type(underlyingType)) builder.setUnderlyingType(local.type(underlyingType))
} }
val expandedType = descriptor.expandedType val expandedType = descriptor.expandedType
if (useTypeTable()) { if (useTypeTable()) {
builder.expandedTypeId = local.typeId(expandedType) builder.expandedTypeId = local.typeId(expandedType)
} } else {
else {
builder.setExpandedType(local.type(expandedType)) builder.setExpandedType(local.type(expandedType))
} }
@@ -475,8 +468,7 @@ class DescriptorSerializer private constructor(
if (useTypeTable()) { if (useTypeTable()) {
builder.typeId = typeId(descriptor.type) builder.typeId = typeId(descriptor.type)
} } else {
else {
builder.setType(type(descriptor.type)) builder.setType(type(descriptor.type))
} }
@@ -484,8 +476,7 @@ class DescriptorSerializer private constructor(
if (varargElementType != null) { if (varargElementType != null) {
if (useTypeTable()) { if (useTypeTable()) {
builder.varargElementTypeId = typeId(varargElementType) builder.varargElementTypeId = typeId(varargElementType)
} } else {
else {
builder.setVarargElementType(type(varargElementType)) builder.setVarargElementType(type(varargElementType))
} }
} }
@@ -518,8 +509,7 @@ class DescriptorSerializer private constructor(
for (upperBound in upperBounds) { for (upperBound in upperBounds) {
if (useTypeTable()) { if (useTypeTable()) {
builder.addUpperBoundId(typeId(upperBound)) builder.addUpperBoundId(typeId(upperBound))
} } else {
else {
builder.addUpperBound(type(upperBound)) builder.addUpperBound(type(upperBound))
} }
} }
@@ -545,8 +535,7 @@ class DescriptorSerializer private constructor(
extension.serializeFlexibleType(flexibleType, lowerBound, upperBound) extension.serializeFlexibleType(flexibleType, lowerBound, upperBound)
if (useTypeTable()) { if (useTypeTable()) {
lowerBound.flexibleUpperBoundId = typeTable[upperBound] lowerBound.flexibleUpperBoundId = typeTable[upperBound]
} } else {
else {
lowerBound.setFlexibleUpperBound(upperBound) lowerBound.setFlexibleUpperBound(upperBound)
} }
return lowerBound return lowerBound
@@ -558,8 +547,7 @@ class DescriptorSerializer private constructor(
return functionType return functionType
} }
val descriptor = type.constructor.declarationDescriptor when (val descriptor = type.constructor.declarationDescriptor) {
when (descriptor) {
is ClassDescriptor, is TypeAliasDescriptor -> { is ClassDescriptor, is TypeAliasDescriptor -> {
val possiblyInnerType = type.buildPossiblyInnerType() ?: error("possiblyInnerType should not be null: $type") val possiblyInnerType = type.buildPossiblyInnerType() ?: error("possiblyInnerType should not be null: $type")
fillFromPossiblyInnerType(builder, possiblyInnerType) fillFromPossiblyInnerType(builder, possiblyInnerType)
@@ -567,8 +555,7 @@ class DescriptorSerializer private constructor(
is TypeParameterDescriptor -> { is TypeParameterDescriptor -> {
if (descriptor.containingDeclaration === containingDeclaration) { if (descriptor.containingDeclaration === containingDeclaration) {
builder.typeParameterName = getSimpleNameIndex(descriptor.name) builder.typeParameterName = getSimpleNameIndex(descriptor.name)
} } else {
else {
builder.typeParameter = getTypeParameterId(descriptor) builder.typeParameter = getTypeParameterId(descriptor)
} }
@@ -584,8 +571,7 @@ class DescriptorSerializer private constructor(
if (abbreviation != null) { if (abbreviation != null) {
if (useTypeTable()) { if (useTypeTable()) {
builder.abbreviatedTypeId = typeId(abbreviation) builder.abbreviatedTypeId = typeId(abbreviation)
} } else {
else {
builder.setAbbreviatedType(type(abbreviation)) builder.setAbbreviatedType(type(abbreviation))
} }
} }
@@ -612,8 +598,7 @@ class DescriptorSerializer private constructor(
fillFromPossiblyInnerType(outerBuilder, type.outerType!!) fillFromPossiblyInnerType(outerBuilder, type.outerType!!)
if (useTypeTable()) { if (useTypeTable()) {
builder.outerTypeId = typeTable[outerBuilder] builder.outerTypeId = typeTable[outerBuilder]
} } else {
else {
builder.setOuterType(outerBuilder) builder.setOuterType(outerBuilder)
} }
} }
@@ -624,8 +609,7 @@ class DescriptorSerializer private constructor(
if (typeProjection.isStarProjection) { if (typeProjection.isStarProjection) {
builder.projection = ProtoBuf.Type.Argument.Projection.STAR builder.projection = ProtoBuf.Type.Argument.Projection.STAR
} } else {
else {
val projection = projection(typeProjection.projectionKind) val projection = projection(typeProjection.projectionKind)
if (projection != builder.projection) { if (projection != builder.projection) {
@@ -634,8 +618,7 @@ class DescriptorSerializer private constructor(
if (useTypeTable()) { if (useTypeTable()) {
builder.typeId = typeId(typeProjection.type) builder.typeId = typeId(typeProjection.type)
} } else {
else {
builder.setType(type(typeProjection.type)) builder.setType(type(typeProjection.type))
} }
} }
@@ -691,8 +674,8 @@ class DescriptorSerializer private constructor(
val proto = ProtoBuf.VersionRequirement.newBuilder() val proto = ProtoBuf.VersionRequirement.newBuilder()
VersionRequirement.Version(major, minor, patch).encode( VersionRequirement.Version(major, minor, patch).encode(
writeVersion = { proto.version = it }, writeVersion = { proto.version = it },
writeVersionFull = { proto.versionFull = it } writeVersionFull = { proto.versionFull = it }
) )
val message = (args[RequireKotlinNames.MESSAGE] as? StringValue)?.value val message = (args[RequireKotlinNames.MESSAGE] as? StringValue)?.value
@@ -700,16 +683,18 @@ class DescriptorSerializer private constructor(
proto.message = stringTable.getStringIndex(message) proto.message = stringTable.getStringIndex(message)
} }
val level = (args[RequireKotlinNames.LEVEL] as? EnumValue)?.enumEntryName?.asString() when ((args[RequireKotlinNames.LEVEL] as? EnumValue)?.enumEntryName?.asString()) {
when (level) { DeprecationLevel.ERROR.name -> {
DeprecationLevel.ERROR.name -> { /* ERROR is the default level */ } // ERROR is the default level
}
DeprecationLevel.WARNING.name -> proto.level = ProtoBuf.VersionRequirement.Level.WARNING DeprecationLevel.WARNING.name -> proto.level = ProtoBuf.VersionRequirement.Level.WARNING
DeprecationLevel.HIDDEN.name -> proto.level = ProtoBuf.VersionRequirement.Level.HIDDEN DeprecationLevel.HIDDEN.name -> proto.level = ProtoBuf.VersionRequirement.Level.HIDDEN
} }
val versionKind = (args[RequireKotlinNames.VERSION_KIND] as? EnumValue)?.enumEntryName?.asString() when ((args[RequireKotlinNames.VERSION_KIND] as? EnumValue)?.enumEntryName?.asString()) {
when (versionKind) { ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION.name -> {
ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION.name -> { /* LANGUAGE_VERSION is the default kind */ } // LANGUAGE_VERSION is the default kind
}
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION.name -> ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION.name ->
proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION
ProtoBuf.VersionRequirement.VersionKind.API_VERSION.name -> ProtoBuf.VersionRequirement.VersionKind.API_VERSION.name ->
@@ -725,13 +710,13 @@ class DescriptorSerializer private constructor(
} }
private fun getClassifierId(descriptor: ClassifierDescriptorWithTypeParameters): Int = private fun getClassifierId(descriptor: ClassifierDescriptorWithTypeParameters): Int =
stringTable.getFqNameIndex(descriptor) stringTable.getFqNameIndex(descriptor)
private fun getSimpleNameIndex(name: Name): Int = private fun getSimpleNameIndex(name: Name): Int =
stringTable.getStringIndex(name.asString()) stringTable.getStringIndex(name.asString())
private fun getTypeParameterId(descriptor: TypeParameterDescriptor): Int = private fun getTypeParameterId(descriptor: TypeParameterDescriptor): Int =
typeParameters.intern(descriptor) typeParameters.intern(descriptor)
private fun getAccessorFlags(accessor: PropertyAccessorDescriptor): Int = Flags.getAccessorFlags( private fun getAccessorFlags(accessor: PropertyAccessorDescriptor): Int = Flags.getAccessorFlags(
hasAnnotations(accessor), hasAnnotations(accessor),
@@ -745,14 +730,18 @@ class DescriptorSerializer private constructor(
companion object { companion object {
@JvmStatic @JvmStatic
fun createTopLevel(extension: SerializerExtension): DescriptorSerializer { fun createTopLevel(extension: SerializerExtension): DescriptorSerializer {
return DescriptorSerializer(null, Interner(), extension, MutableTypeTable(), MutableVersionRequirementTable(), return DescriptorSerializer(
serializeTypeTableToFunction = false) null, Interner(), extension, MutableTypeTable(), MutableVersionRequirementTable(),
serializeTypeTableToFunction = false
)
} }
@JvmStatic @JvmStatic
fun createForLambda(extension: SerializerExtension): DescriptorSerializer { fun createForLambda(extension: SerializerExtension): DescriptorSerializer {
return DescriptorSerializer(null, Interner(), extension, MutableTypeTable(), MutableVersionRequirementTable(), return DescriptorSerializer(
serializeTypeTableToFunction = true) null, Interner(), extension, MutableTypeTable(), MutableVersionRequirementTable(),
serializeTypeTableToFunction = true
)
} }
@JvmStatic @JvmStatic
@@ -801,10 +790,10 @@ class DescriptorSerializer private constructor(
descriptor != null && descriptor.nonSourceAnnotations.isNotEmpty() descriptor != null && descriptor.nonSourceAnnotations.isNotEmpty()
fun <T : DeclarationDescriptor> sort(descriptors: Collection<T>): List<T> = fun <T : DeclarationDescriptor> sort(descriptors: Collection<T>): List<T> =
ArrayList(descriptors).apply { ArrayList(descriptors).apply {
//NOTE: the exact comparator does matter here //NOTE: the exact comparator does matter here
Collections.sort(this, MemberComparator.INSTANCE) Collections.sort(this, MemberComparator.INSTANCE)
} }
fun writeLanguageVersionRequirement( fun writeLanguageVersionRequirement(
languageFeature: LanguageFeature, languageFeature: LanguageFeature,
@@ -36,31 +36,35 @@ abstract class SerializerExtension {
open fun serializeClass( open fun serializeClass(
descriptor: ClassDescriptor, descriptor: ClassDescriptor,
proto: ProtoBuf.Class.Builder, proto: ProtoBuf.Class.Builder,
versionRequirementTable: MutableVersionRequirementTable, versionRequirementTable: MutableVersionRequirementTable,
childSerializer: DescriptorSerializer childSerializer: DescriptorSerializer
) { ) {
} }
open fun serializePackage(packageFqName: FqName, proto: ProtoBuf.Package.Builder) { open fun serializePackage(packageFqName: FqName, proto: ProtoBuf.Package.Builder) {
} }
open fun serializeConstructor(descriptor: ConstructorDescriptor, open fun serializeConstructor(
proto: ProtoBuf.Constructor.Builder, descriptor: ConstructorDescriptor,
childSerializer: DescriptorSerializer) { proto: ProtoBuf.Constructor.Builder,
childSerializer: DescriptorSerializer
) {
} }
open fun serializeFunction(descriptor: FunctionDescriptor, open fun serializeFunction(
proto: ProtoBuf.Function.Builder, descriptor: FunctionDescriptor,
childSerializer: DescriptorSerializer) { proto: ProtoBuf.Function.Builder,
childSerializer: DescriptorSerializer
) {
} }
open fun serializeProperty( open fun serializeProperty(
descriptor: PropertyDescriptor, descriptor: PropertyDescriptor,
proto: ProtoBuf.Property.Builder, proto: ProtoBuf.Property.Builder,
versionRequirementTable: MutableVersionRequirementTable, versionRequirementTable: MutableVersionRequirementTable,
childSerializer: DescriptorSerializer childSerializer: DescriptorSerializer
) { ) {
} }
@@ -28,10 +28,10 @@ abstract class KotlinSerializerExtensionBase(private val protocol: SerializerExt
override val stringTable = StringTableImpl() override val stringTable = StringTableImpl()
override fun serializeClass( override fun serializeClass(
descriptor: ClassDescriptor, descriptor: ClassDescriptor,
proto: ProtoBuf.Class.Builder, proto: ProtoBuf.Class.Builder,
versionRequirementTable: MutableVersionRequirementTable, versionRequirementTable: MutableVersionRequirementTable,
childSerializer: DescriptorSerializer childSerializer: DescriptorSerializer
) { ) {
for (annotation in descriptor.nonSourceAnnotations) { for (annotation in descriptor.nonSourceAnnotations) {
proto.addExtension(protocol.classAnnotation, annotationSerializer.serializeAnnotation(annotation)) proto.addExtension(protocol.classAnnotation, annotationSerializer.serializeAnnotation(annotation))
@@ -42,27 +42,31 @@ abstract class KotlinSerializerExtensionBase(private val protocol: SerializerExt
proto.setExtension(protocol.packageFqName, stringTable.getPackageFqNameIndex(packageFqName)) proto.setExtension(protocol.packageFqName, stringTable.getPackageFqNameIndex(packageFqName))
} }
override fun serializeConstructor(descriptor: ConstructorDescriptor, override fun serializeConstructor(
proto: ProtoBuf.Constructor.Builder, descriptor: ConstructorDescriptor,
childSerializer: DescriptorSerializer) { proto: ProtoBuf.Constructor.Builder,
childSerializer: DescriptorSerializer
) {
for (annotation in descriptor.nonSourceAnnotations) { for (annotation in descriptor.nonSourceAnnotations) {
proto.addExtension(protocol.constructorAnnotation, annotationSerializer.serializeAnnotation(annotation)) proto.addExtension(protocol.constructorAnnotation, annotationSerializer.serializeAnnotation(annotation))
} }
} }
override fun serializeFunction(descriptor: FunctionDescriptor, override fun serializeFunction(
proto: ProtoBuf.Function.Builder, descriptor: FunctionDescriptor,
childSerializer: DescriptorSerializer) { proto: ProtoBuf.Function.Builder,
childSerializer: DescriptorSerializer
) {
for (annotation in descriptor.nonSourceAnnotations) { for (annotation in descriptor.nonSourceAnnotations) {
proto.addExtension(protocol.functionAnnotation, annotationSerializer.serializeAnnotation(annotation)) proto.addExtension(protocol.functionAnnotation, annotationSerializer.serializeAnnotation(annotation))
} }
} }
override fun serializeProperty( override fun serializeProperty(
descriptor: PropertyDescriptor, descriptor: PropertyDescriptor,
proto: ProtoBuf.Property.Builder, proto: ProtoBuf.Property.Builder,
versionRequirementTable: MutableVersionRequirementTable, versionRequirementTable: MutableVersionRequirementTable,
childSerializer: DescriptorSerializer childSerializer: DescriptorSerializer
) { ) {
for (annotation in descriptor.nonSourceAnnotations) { for (annotation in descriptor.nonSourceAnnotations) {
proto.addExtension(protocol.propertyAnnotation, annotationSerializer.serializeAnnotation(annotation)) proto.addExtension(protocol.propertyAnnotation, annotationSerializer.serializeAnnotation(annotation))
@@ -37,8 +37,8 @@ open class StringTableImpl : DescriptorAwareStringTable {
val otherFqName = other.fqName val otherFqName = other.fqName
return fqName.parentQualifiedName == otherFqName.parentQualifiedName return fqName.parentQualifiedName == otherFqName.parentQualifiedName
&& fqName.shortName == otherFqName.shortName && fqName.shortName == otherFqName.shortName
&& fqName.kind == otherFqName.kind && fqName.kind == otherFqName.kind
} }
} }
@@ -55,7 +55,7 @@ open class StringTableImpl : DescriptorAwareStringTable {
builder.kind = QualifiedName.Kind.CLASS builder.kind = QualifiedName.Kind.CLASS
builder.parentQualifiedName = builder.parentQualifiedName =
classId.outerClassId?.let(this::getQualifiedClassNameIndex) classId.outerClassId?.let(this::getQualifiedClassNameIndex)
?: getPackageFqNameIndex(classId.packageFqName) ?: getPackageFqNameIndex(classId.packageFqName)
builder.shortName = getStringIndex(classId.shortClassName.asString()) builder.shortName = getStringIndex(classId.shortClassName.asString())