Store outer class in ProtoContainer instead of only its kind
This commit is contained in:
+12
-8
@@ -37,7 +37,10 @@ import org.jetbrains.kotlin.psi.stubs.impl.KotlinObjectStubImpl
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinPlaceHolderStubImpl
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.serialization.deserialization.supertypes
|
||||
|
||||
fun createClassStub(
|
||||
parent: StubElement<out PsiElement>,
|
||||
@@ -58,9 +61,14 @@ private class ClassClsStubBuilder(
|
||||
private val source: SourceElement?,
|
||||
private val outerContext: ClsStubBuilderContext
|
||||
) {
|
||||
private val classKind = Flags.CLASS_KIND[classProto.flags]
|
||||
private val c = outerContext.child(classProto.typeParameterList, classKind, classId.shortClassName, nameResolver,
|
||||
TypeTable(classProto.typeTable))
|
||||
private val thisAsProtoContainer = ProtoContainer.Class(
|
||||
classProto, nameResolver, TypeTable(classProto.typeTable), source, outerContext.protoContainer
|
||||
)
|
||||
private val classKind = thisAsProtoContainer.kind
|
||||
|
||||
private val c = outerContext.child(
|
||||
classProto.typeParameterList, classId.shortClassName, nameResolver, thisAsProtoContainer.typeTable, thisAsProtoContainer
|
||||
)
|
||||
private val typeStubBuilder = TypeClsStubBuilder(c)
|
||||
private val supertypeIds = run {
|
||||
val supertypeIds = classProto.supertypes(c.typeTable).map { c.nameResolver.getClassId(it.className) }
|
||||
@@ -76,10 +84,6 @@ private class ClassClsStubBuilder(
|
||||
private val companionObjectName =
|
||||
if (classProto.hasCompanionObjectName()) c.nameResolver.getName(classProto.companionObjectName) else null
|
||||
|
||||
private val thisAsProtoContainer = ProtoContainer.Class(
|
||||
classProto, c.nameResolver, c.typeTable, source, outerContext.classKind?.let { Deserialization.classKind(it) }
|
||||
)
|
||||
|
||||
private val classOrObjectStub = createClassOrObjectStubAndModifierListStub()
|
||||
|
||||
fun build() {
|
||||
|
||||
+6
-9
@@ -22,10 +22,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AnnotationAndConstantLoader
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ClassDataFinder
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
|
||||
data class ClassIdWithTarget(val classId: ClassId, val target: AnnotationUseSiteTarget?)
|
||||
|
||||
@@ -39,7 +36,7 @@ class ClsStubBuilderComponents(
|
||||
packageFqName: FqName,
|
||||
typeTable: TypeTable
|
||||
): ClsStubBuilderContext {
|
||||
return ClsStubBuilderContext(this, nameResolver, packageFqName, EmptyTypeParameters, typeTable, classKind = null)
|
||||
return ClsStubBuilderContext(this, nameResolver, packageFqName, EmptyTypeParameters, typeTable, protoContainer = null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,15 +67,15 @@ class ClsStubBuilderContext(
|
||||
val containerFqName: FqName,
|
||||
val typeParameters: TypeParameters,
|
||||
val typeTable: TypeTable,
|
||||
val classKind: ProtoBuf.Class.Kind?
|
||||
val protoContainer: ProtoContainer.Class?
|
||||
)
|
||||
|
||||
internal fun ClsStubBuilderContext.child(
|
||||
typeParameterList: List<ProtoBuf.TypeParameter>,
|
||||
classKind: ProtoBuf.Class.Kind? = null,
|
||||
name: Name? = null,
|
||||
nameResolver: NameResolver = this.nameResolver,
|
||||
typeTable: TypeTable = this.typeTable
|
||||
typeTable: TypeTable = this.typeTable,
|
||||
protoContainer: ProtoContainer.Class? = this.protoContainer
|
||||
): ClsStubBuilderContext {
|
||||
return ClsStubBuilderContext(
|
||||
this.components,
|
||||
@@ -86,6 +83,6 @@ internal fun ClsStubBuilderContext.child(
|
||||
if (name != null) this.containerFqName.child(name) else this.containerFqName,
|
||||
this.typeParameters.child(nameResolver, typeParameterList),
|
||||
typeTable,
|
||||
classKind
|
||||
protoContainer
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user