Introduce infrastructure to separate string table from metadata on JVM
Nothing especially helpful happens here, this is only a big refactoring introducing a separate string array for the string table, which is currently always empty, but will contain actual strings soon
This commit is contained in:
+8
-3
@@ -70,20 +70,25 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() {
|
||||
LOG.error("Corrupted kotlin header for file ${file.getName()}")
|
||||
return null
|
||||
}
|
||||
val strings = header.strings
|
||||
if (strings == null) {
|
||||
LOG.error("String table not found in file ${file.getName()}")
|
||||
return null
|
||||
}
|
||||
return when {
|
||||
header.isCompatiblePackageFacadeKind() -> {
|
||||
val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData)
|
||||
val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData, strings)
|
||||
val context = components.createContext(nameResolver, packageFqName)
|
||||
createPackageFacadeStub(packageProto, packageFqName, context)
|
||||
}
|
||||
header.isCompatibleClassKind() -> {
|
||||
if (header.classKind != JvmAnnotationNames.KotlinClass.Kind.CLASS) return null
|
||||
val (nameResolver, classProto) = JvmProtoBufUtil.readClassDataFrom(annotationData)
|
||||
val (nameResolver, classProto) = JvmProtoBufUtil.readClassDataFrom(annotationData, strings)
|
||||
val context = components.createContext(nameResolver, packageFqName)
|
||||
createTopLevelClassStub(classId, classProto, context)
|
||||
}
|
||||
header.isCompatibleFileFacadeKind() -> {
|
||||
val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData)
|
||||
val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData, strings)
|
||||
val context = components.createContext(nameResolver, packageFqName)
|
||||
createFileFacadeStub(packageProto, classId.asSingleFqName(), context)
|
||||
}
|
||||
|
||||
+1
-2
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.idea.stubindex.KotlinFileStubForIde
|
||||
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -87,7 +86,7 @@ fun createMultifileClassStub(
|
||||
val multifileClassContainer = ProtoContainer(null, packageFqName)
|
||||
for (partFile in partFiles) {
|
||||
val partHeader = partFile.classHeader
|
||||
val partData = JvmProtoBufUtil.readPackageDataFrom(partHeader.annotationData!!)
|
||||
val partData = JvmProtoBufUtil.readPackageDataFrom(partHeader.annotationData!!, partHeader.strings!!)
|
||||
val partContext = components.createContext(partData.nameResolver, packageFqName)
|
||||
for (partMember in partData.packageProto.memberList) {
|
||||
createCallableStub(fileStub, partMember, partContext, multifileClassContainer)
|
||||
|
||||
+6
-4
@@ -62,12 +62,14 @@ public class DeserializerForDecompiler(
|
||||
"Was called for $facadeFqName; only members of $directoryPackageFqName package are expected."
|
||||
}
|
||||
val binaryClassForPackageClass = classFinder.findKotlinClass(ClassId.topLevel(facadeFqName))
|
||||
val annotationData = binaryClassForPackageClass?.classHeader?.annotationData
|
||||
if (annotationData == null) {
|
||||
LOG.error("Could not read annotation data for $facadeFqName from ${binaryClassForPackageClass?.classId}")
|
||||
val header = binaryClassForPackageClass?.classHeader
|
||||
val annotationData = header?.annotationData
|
||||
val strings = header?.strings
|
||||
if (annotationData == null || strings == null) {
|
||||
LOG.error("Could not read annotation data for $facadeFqName from ${binaryClassForPackageClass?.getClassId()}")
|
||||
return emptyList()
|
||||
}
|
||||
val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData)
|
||||
val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData, strings)
|
||||
val membersScope = DeserializedPackageMemberScope(
|
||||
createDummyPackageFragment(packageFqName), packageProto, nameResolver, deserializationComponents
|
||||
) { emptyList() }
|
||||
|
||||
+9
-4
@@ -73,14 +73,19 @@ class DirectoryBasedDataFinder(
|
||||
) : ClassDataFinder {
|
||||
override fun findClassData(classId: ClassId): ClassDataWithSource? {
|
||||
val binaryClass = classFinder.findKotlinClass(classId) ?: return null
|
||||
val data = binaryClass.getClassHeader().annotationData
|
||||
val classHeader = binaryClass.classHeader
|
||||
val data = classHeader.annotationData
|
||||
if (data == null) {
|
||||
log.error("Annotation data missing for ${binaryClass.getClassId()}")
|
||||
log.error("Annotation data missing for ${binaryClass.classId}")
|
||||
return null
|
||||
}
|
||||
val strings = classHeader.strings
|
||||
if (strings == null) {
|
||||
log.error("String table not found in class ${binaryClass.classId}")
|
||||
return null
|
||||
}
|
||||
|
||||
val classData = JvmProtoBufUtil.readClassDataFrom(data)
|
||||
return ClassDataWithSource(classData)
|
||||
return ClassDataWithSource(JvmProtoBufUtil.readClassDataFrom(data, strings))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user