Introduce PackagePartSource to store part class name in deserialized descriptors
Not used at the moment, will be in the following commits
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ public class ClassDeserializer(private val components: DeserializationComponents
|
||||
if (!fragment.hasTopLevelClass(classId.shortClassName)) return null
|
||||
}
|
||||
|
||||
components.createContext(fragment, nameResolver, TypeTable(classProto.typeTable))
|
||||
components.createContext(fragment, nameResolver, TypeTable(classProto.typeTable), packagePartSource = null)
|
||||
}
|
||||
|
||||
return DeserializedClassDescriptor(outerContext, classProto, nameResolver, sourceElement)
|
||||
|
||||
+2
-1
@@ -50,7 +50,8 @@ public abstract class DeserializedPackageFragment(
|
||||
internal val deserializedMemberScope by storageManager.createLazyValue {
|
||||
val packageStream = loadResourceSure(serializedResourcePaths.getPackageFilePath(fqName))
|
||||
val packageProto = ProtoBuf.Package.parseFrom(packageStream, serializedResourcePaths.extensionRegistry)
|
||||
DeserializedPackageMemberScope(this, packageProto, nameResolver, components, classNames = { loadClassNames(packageProto) })
|
||||
DeserializedPackageMemberScope(this, packageProto, nameResolver, packagePartSource = null, components = components,
|
||||
classNames = { loadClassNames(packageProto) })
|
||||
}
|
||||
|
||||
override fun getMemberScope() = deserializedMemberScope
|
||||
|
||||
+5
-4
@@ -47,7 +47,8 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
Flags.IS_CONST.get(flags),
|
||||
proto,
|
||||
c.nameResolver,
|
||||
c.typeTable
|
||||
c.typeTable,
|
||||
c.packagePartSource
|
||||
)
|
||||
|
||||
val local = c.childContext(property, proto.getTypeParameterList())
|
||||
@@ -142,7 +143,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
else Annotations.EMPTY
|
||||
val function = DeserializedSimpleFunctionDescriptor(
|
||||
c.containingDeclaration, /* original = */ null, annotations, c.nameResolver.getName(proto.name),
|
||||
Deserialization.memberKind(Flags.MEMBER_KIND.get(proto.flags)), proto, c.nameResolver, c.typeTable
|
||||
Deserialization.memberKind(Flags.MEMBER_KIND.get(proto.flags)), proto, c.nameResolver, c.typeTable, c.packagePartSource
|
||||
)
|
||||
val local = c.childContext(function, proto.typeParameterList)
|
||||
function.initialize(
|
||||
@@ -170,7 +171,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
val classDescriptor = c.containingDeclaration as ClassDescriptor
|
||||
val descriptor = DeserializedConstructorDescriptor(
|
||||
classDescriptor, null, getAnnotations(proto, proto.flags, AnnotatedCallableKind.FUNCTION),
|
||||
isPrimary, CallableMemberDescriptor.Kind.DECLARATION, proto, c.nameResolver, c.typeTable
|
||||
isPrimary, CallableMemberDescriptor.Kind.DECLARATION, proto, c.nameResolver, c.typeTable, c.packagePartSource
|
||||
)
|
||||
val local = c.childContext(descriptor, listOf())
|
||||
descriptor.initialize(
|
||||
@@ -243,7 +244,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.asProtoContainer(): ProtoContainer? = when (this) {
|
||||
is PackageFragmentDescriptor -> ProtoContainer.Package(fqName, c.nameResolver, c.typeTable)
|
||||
is PackageFragmentDescriptor -> ProtoContainer.Package(fqName, c.nameResolver, c.typeTable, c.packagePartSource)
|
||||
is DeserializedClassDescriptor -> ProtoContainer.Class(
|
||||
classProto, c.nameResolver, c.typeTable,
|
||||
isCompanionOfClass = DescriptorUtils.isCompanionObject(this) &&
|
||||
|
||||
+3
-1
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.PackagePartSource
|
||||
|
||||
sealed class ProtoContainer(
|
||||
val nameResolver: NameResolver,
|
||||
@@ -35,7 +36,8 @@ sealed class ProtoContainer(
|
||||
class Package(
|
||||
val fqName: FqName,
|
||||
nameResolver: NameResolver,
|
||||
typeTable: TypeTable
|
||||
typeTable: TypeTable,
|
||||
val packagePartSource: PackagePartSource?
|
||||
) : ProtoContainer(nameResolver, typeTable) {
|
||||
override fun debugFqName(): FqName = fqName
|
||||
}
|
||||
|
||||
+9
-6
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.PackagePartSource
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
class DeserializationComponents(
|
||||
@@ -46,9 +47,11 @@ class DeserializationComponents(
|
||||
fun createContext(
|
||||
descriptor: PackageFragmentDescriptor,
|
||||
nameResolver: NameResolver,
|
||||
typeTable: TypeTable
|
||||
typeTable: TypeTable,
|
||||
packagePartSource: PackagePartSource?
|
||||
): DeserializationContext =
|
||||
DeserializationContext(this, nameResolver, descriptor, typeTable, parentTypeDeserializer = null, typeParameters = listOf())
|
||||
DeserializationContext(this, nameResolver, descriptor, typeTable, packagePartSource,
|
||||
parentTypeDeserializer = null, typeParameters = listOf())
|
||||
}
|
||||
|
||||
|
||||
@@ -57,11 +60,12 @@ class DeserializationContext(
|
||||
val nameResolver: NameResolver,
|
||||
val containingDeclaration: DeclarationDescriptor,
|
||||
val typeTable: TypeTable,
|
||||
val packagePartSource: PackagePartSource?,
|
||||
parentTypeDeserializer: TypeDeserializer?,
|
||||
typeParameters: List<ProtoBuf.TypeParameter>
|
||||
) {
|
||||
val typeDeserializer = TypeDeserializer(this, parentTypeDeserializer, typeParameters,
|
||||
"Deserializer for ${containingDeclaration.getName()}")
|
||||
"Deserializer for ${containingDeclaration.name}")
|
||||
|
||||
val memberDeserializer = MemberDeserializer(this)
|
||||
|
||||
@@ -73,8 +77,7 @@ class DeserializationContext(
|
||||
nameResolver: NameResolver = this.nameResolver,
|
||||
typeTable: TypeTable = this.typeTable
|
||||
) = DeserializationContext(
|
||||
components, nameResolver, descriptor, typeTable,
|
||||
parentTypeDeserializer = this.typeDeserializer,
|
||||
typeParameters = typeParameterProtos
|
||||
components, nameResolver, descriptor, typeTable, this.packagePartSource,
|
||||
parentTypeDeserializer = this.typeDeserializer, typeParameters = typeParameterProtos
|
||||
)
|
||||
}
|
||||
|
||||
+16
-6
@@ -34,8 +34,14 @@ interface DeserializedCallableMemberDescriptor : CallableMemberDescriptor {
|
||||
val nameResolver: NameResolver
|
||||
|
||||
val typeTable: TypeTable
|
||||
|
||||
// Information about the origin of this top-level callable or null, if it's not top-level or there's no such information.
|
||||
// On JVM, this is JvmPackagePartSource which contains the internal name of the package part class
|
||||
val packagePartSource: PackagePartSource?
|
||||
}
|
||||
|
||||
interface PackagePartSource
|
||||
|
||||
class DeserializedSimpleFunctionDescriptor(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
original: SimpleFunctionDescriptor?,
|
||||
@@ -44,7 +50,8 @@ class DeserializedSimpleFunctionDescriptor(
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
override val proto: ProtoBuf.Function,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable
|
||||
override val typeTable: TypeTable,
|
||||
override val packagePartSource: PackagePartSource?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
SimpleFunctionDescriptorImpl(containingDeclaration, original, annotations, name, kind, SourceElement.NO_SOURCE) {
|
||||
|
||||
@@ -56,7 +63,8 @@ class DeserializedSimpleFunctionDescriptor(
|
||||
preserveSource: Boolean
|
||||
): FunctionDescriptorImpl {
|
||||
return DeserializedSimpleFunctionDescriptor(
|
||||
newOwner, original as SimpleFunctionDescriptor?, annotations, newName ?: name, kind, proto, nameResolver, typeTable
|
||||
newOwner, original as SimpleFunctionDescriptor?, annotations, newName ?: name, kind,
|
||||
proto, nameResolver, typeTable, packagePartSource
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -74,7 +82,8 @@ class DeserializedPropertyDescriptor(
|
||||
isConst: Boolean,
|
||||
override val proto: ProtoBuf.Property,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable
|
||||
override val typeTable: TypeTable,
|
||||
override val packagePartSource: PackagePartSource?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
PropertyDescriptorImpl(containingDeclaration, original, annotations,
|
||||
modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE, isLateInit, isConst) {
|
||||
@@ -88,7 +97,7 @@ class DeserializedPropertyDescriptor(
|
||||
): PropertyDescriptorImpl {
|
||||
return DeserializedPropertyDescriptor(
|
||||
newOwner, original, annotations, newModality, newVisibility, isVar, name, kind, isLateInit, isConst,
|
||||
proto, nameResolver, typeTable
|
||||
proto, nameResolver, typeTable, packagePartSource
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -101,7 +110,8 @@ class DeserializedConstructorDescriptor(
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
override val proto: ProtoBuf.Constructor,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable
|
||||
override val typeTable: TypeTable,
|
||||
override val packagePartSource: PackagePartSource?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
ConstructorDescriptorImpl(containingDeclaration, original, annotations, isPrimary, kind, SourceElement.NO_SOURCE) {
|
||||
|
||||
@@ -114,7 +124,7 @@ class DeserializedConstructorDescriptor(
|
||||
): DeserializedConstructorDescriptor {
|
||||
return DeserializedConstructorDescriptor(
|
||||
newOwner as ClassDescriptor, original as ConstructorDescriptor?, annotations, isPrimary, kind,
|
||||
proto, nameResolver, typeTable
|
||||
proto, nameResolver, typeTable, packagePartSource
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -36,10 +36,11 @@ public open class DeserializedPackageMemberScope(
|
||||
packageDescriptor: PackageFragmentDescriptor,
|
||||
proto: ProtoBuf.Package,
|
||||
nameResolver: NameResolver,
|
||||
packagePartSource: PackagePartSource?,
|
||||
components: DeserializationComponents,
|
||||
classNames: () -> Collection<Name>
|
||||
) : DeserializedMemberScope(
|
||||
components.createContext(packageDescriptor, nameResolver, TypeTable(proto.typeTable)),
|
||||
components.createContext(packageDescriptor, nameResolver, TypeTable(proto.typeTable), packagePartSource),
|
||||
proto.functionList, proto.propertyList
|
||||
) {
|
||||
private val packageFqName = packageDescriptor.fqName
|
||||
|
||||
Reference in New Issue
Block a user