Serialize descriptors for local/anonymous classes on JVM
Reflection needs this information to work for local classes and anonymous objects
This commit is contained in:
+8
-6
@@ -23,7 +23,6 @@ import com.intellij.psi.stubs.PsiFileStub
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.impl.compiled.ClassFileStubBuilder
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.LocalClassFinder
|
||||
@@ -32,6 +31,9 @@ import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.LoggingErrorReporter
|
||||
import org.jetbrains.kotlin.idea.decompiler.isKotlinInternalCompiledFile
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatiblePackageFacadeKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleClassKind
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
|
||||
public class KotlinClsStubBuilder : ClsStubBuilder() {
|
||||
override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 1
|
||||
@@ -62,19 +64,19 @@ public class KotlinClsStubBuilder : ClsStubBuilder() {
|
||||
LOG.error("Corrupted kotlin header for file ${file.getName()}")
|
||||
return null
|
||||
}
|
||||
return when (header.kind) {
|
||||
KotlinClassHeader.Kind.PACKAGE_FACADE -> {
|
||||
return when {
|
||||
header.isCompatiblePackageFacadeKind() -> {
|
||||
val packageData = JvmProtoBufUtil.readPackageDataFrom(annotationData)
|
||||
val context = components.createContext(packageData.getNameResolver(), packageFqName)
|
||||
createPackageFacadeFileStub(packageData.getPackageProto(), packageFqName, context)
|
||||
}
|
||||
|
||||
KotlinClassHeader.Kind.CLASS -> {
|
||||
header.isCompatibleClassKind() -> {
|
||||
if (header.classKind != JvmAnnotationNames.KotlinClass.Kind.CLASS) return null
|
||||
val classData = JvmProtoBufUtil.readClassDataFrom(annotationData)
|
||||
val context = components.createContext(classData.getNameResolver(), packageFqName)
|
||||
createTopLevelClassStub(classId, classData.getClassProto(), context)
|
||||
}
|
||||
else -> throw IllegalStateException("Should have processed " + file.getPath() + " with ${header.kind}")
|
||||
else -> throw IllegalStateException("Should have processed " + file.getPath() + " with header $header")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user