Read package name in KotlinClassHeader and use it in decompiler
(cherry picked from commit 119d5ab)
This commit is contained in:
+2
-1
@@ -30,7 +30,8 @@ class KotlinClassHeader(
|
||||
val incompatibleData: Array<String>?,
|
||||
val strings: Array<String>?,
|
||||
val extraString: String?,
|
||||
val extraInt: Int
|
||||
val extraInt: Int,
|
||||
val packageName: String?
|
||||
) {
|
||||
// See kotlin.Metadata
|
||||
enum class Kind(val id: Int) {
|
||||
|
||||
+8
-1
@@ -52,6 +52,7 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
|
||||
private JvmBytecodeBinaryVersion bytecodeVersion = null;
|
||||
private String extraString = null;
|
||||
private int extraInt = 0;
|
||||
private String packageName = null;
|
||||
private String[] data = null;
|
||||
private String[] strings = null;
|
||||
private String[] incompatibleData = null;
|
||||
@@ -84,7 +85,8 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
|
||||
incompatibleData,
|
||||
strings,
|
||||
extraString,
|
||||
extraInt
|
||||
extraInt,
|
||||
packageName
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,6 +155,11 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
|
||||
extraInt = (Integer) value;
|
||||
}
|
||||
}
|
||||
else if (METADATA_PACKAGE_NAME_FIELD_NAME.equals(string)) {
|
||||
if (value instanceof String) {
|
||||
packageName = (String) value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -34,10 +34,10 @@ import org.jetbrains.kotlin.idea.decompiler.textBuilder.buildDecompiledText
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.defaultDecompilerRendererOptions
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.types.asFlexibleType
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
import java.io.IOException
|
||||
|
||||
class KotlinClassFileDecompiler : ClassFileDecompilers.Full() {
|
||||
private val stubBuilder = KotlinClsStubBuilder()
|
||||
@@ -80,7 +80,8 @@ fun buildDecompiledTextForClassFile(
|
||||
}
|
||||
|
||||
fun buildText(declarations: List<DeclarationDescriptor>) =
|
||||
buildDecompiledText(classId.packageFqName, declarations, decompilerRendererForClassFiles, listOf(ByDescriptorIndexer, BySignatureIndexer))
|
||||
buildDecompiledText(classHeader.packageName?.let(::FqName) ?: classId.packageFqName,
|
||||
declarations, decompilerRendererForClassFiles, listOf(ByDescriptorIndexer, BySignatureIndexer))
|
||||
|
||||
return when (classHeader.kind) {
|
||||
KotlinClassHeader.Kind.FILE_FACADE ->
|
||||
|
||||
Reference in New Issue
Block a user