[Swift export][KT-65672] Print import declarations
This commit is contained in:
committed by
Space Team
parent
168e4414a1
commit
996f47502c
@@ -20,7 +20,16 @@ public class SirAsSwiftSourcesPrinter(private val printer: SmartPrinter) : SirVi
|
||||
}
|
||||
|
||||
override fun visitModule(module: SirModule): Unit = with(printer) {
|
||||
module.declarations.forEach {
|
||||
// We have to write imports before other declarations.
|
||||
val (imports, declarations) = module.declarations.partition { it is SirImport }
|
||||
|
||||
imports.forEach {
|
||||
it.accept(this@SirAsSwiftSourcesPrinter)
|
||||
}
|
||||
if (imports.isNotEmpty()) {
|
||||
println()
|
||||
}
|
||||
declarations.forEach {
|
||||
it.accept(this@SirAsSwiftSourcesPrinter)
|
||||
if (module.declarations.last() != it) {
|
||||
println()
|
||||
@@ -28,6 +37,10 @@ public class SirAsSwiftSourcesPrinter(private val printer: SmartPrinter) : SirVi
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitImport(import: SirImport): Unit = with(printer) {
|
||||
println("import ${import.moduleName}")
|
||||
}
|
||||
|
||||
override fun visitVariable(variable: SirVariable): Unit = with(printer) {
|
||||
print(
|
||||
variable.visibility.takeIf { it != SirVisibility.INTERNAL }?.let { "${it.swift} " } ?: "",
|
||||
|
||||
Reference in New Issue
Block a user