[klib] Print package fq-name
This commit is contained in:
@@ -118,21 +118,29 @@ class PackageFragmentPrinter(val packageFragment: KonanLinkData.PackageFragment,
|
|||||||
get() = !isEnumEntry && !classId.let { it.isLocal || it.isNestedClass }
|
get() = !isEnumEntry && !classId.let { it.isLocal || it.isNestedClass }
|
||||||
|
|
||||||
fun print() {
|
fun print() {
|
||||||
|
if (packageFragment.isEmpty) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
TypeTables.push(packageFragment.`package`.typeTable)
|
TypeTables.push(packageFragment.`package`.typeTable)
|
||||||
// if (packageFragment.hasFqName()) printer.print("package ${packageFragment.fqName}\n")
|
if (packageFragment.hasFqName()) printer.print("package ${packageFragment.fqName}")
|
||||||
packageFragment.classes.classesList.forEach {if (it.isTopLevel) printer.println(it.asString()) }
|
val packageBody = StringBuilder().buildBody {
|
||||||
packageFragment.`package`.functionList.forEach { printer.println(it.asString()) }
|
packageFragment.classes.classesList.forEach {if (it.isTopLevel) appendln(it.asString()) }
|
||||||
packageFragment.`package`.propertyList.forEach { printer.println(it.asString()) }
|
packageFragment.`package`.functionList.forEach { appendln(it.asString()) }
|
||||||
|
packageFragment.`package`.propertyList.forEach { appendln(it.asString()) }
|
||||||
|
}
|
||||||
|
printer.print(packageBody.toString())
|
||||||
TypeTables.pop()
|
TypeTables.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
private fun StringBuilder.buildBody(body: StringBuilder.() -> Unit) {
|
private fun StringBuilder.buildBody(body: StringBuilder.() -> Unit): StringBuilder {
|
||||||
Indent.push()
|
Indent.push()
|
||||||
val result = StringBuilder().apply(body).toString()
|
val result = StringBuilder().apply(body).toString()
|
||||||
Indent.pop()
|
Indent.pop()
|
||||||
append(if (result.isEmpty()) "\n" else " {\n$result$Indent}\n")
|
append(if (result.isEmpty()) "\n" else " {\n$result$Indent}\n")
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
@@ -295,9 +303,8 @@ class PackageFragmentPrinter(val packageFragment: KonanLinkData.PackageFragment,
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
private fun annotationsToString(annotations: List<ProtoBuf.Annotation>, separator: String = " "): String {
|
private fun annotationsToString(annotations: List<ProtoBuf.Annotation>, separator: String = " ") =
|
||||||
return buildString { annotations.forEach { append(it.asString() + separator) } }
|
buildString { annotations.forEach { append(it.asString() + separator) } }
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user