Read package name in KotlinClassHeader and use it in decompiler

(cherry picked from commit 119d5ab)
This commit is contained in:
Dmitry Jemerov
2017-10-24 14:02:16 +02:00
parent d59276671f
commit f93f502ebe
3 changed files with 13 additions and 4 deletions
@@ -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 ->