Sort top-level descriptors by name

This commit is contained in:
Pavel Punegov
2020-12-16 15:05:49 +03:00
committed by Stanislav Erokhin
parent 43fe8c4931
commit d09b0b7042
2 changed files with 6 additions and 4 deletions
@@ -47,7 +47,9 @@ class DeclarationPrinter(
}
override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor, data: Unit) {
val children = descriptor.getMemberScope().getContributedDescriptors().filter { it.shouldBePrinted }
val children = descriptor.getMemberScope().getContributedDescriptors()
.filter { it.shouldBePrinted }
.sortedBy { it.name }
if (children.isNotEmpty()) {
printer.printWithBody(header = headerRenderer.render(descriptor)) {
children.forEach { it.accept(this, data) }
@@ -48,6 +48,7 @@ class ContentsTest {
package <root> {
@A @B fun a()
fun Foo.e()
fun f1(x: Foo)
fun f2(x: Foo, y: Foo): Int
inline fun i1(block: () -> Foo)
@@ -62,7 +63,6 @@ class ContentsTest {
fun <T, F> t3(x: T, y: F)
inline fun <reified T> t4(x: T)
fun <T : Number> t5(x: T)
fun Foo.e()
}
""".trimIndent()
}
@@ -325,9 +325,9 @@ class ContentsTest {
fun topLevelPropertiesWithClassesCustomPackage() = klibContents(testLibrary("TopLevelPropertiesWithClassesCustomPackage")) {
"""
package custom.pkg {
typealias MyTransformer = (String) -> Int
object Bar
class Foo constructor()
typealias MyTransformer = (String) -> Int
}
package custom.pkg {
@@ -343,9 +343,9 @@ class ContentsTest {
fun topLevelPropertiesWithClassesRootPackage() = klibContents(testLibrary("TopLevelPropertiesWithClassesRootPackage")) {
"""
package <root> {
typealias MyTransformer = (String) -> Int
object Bar
class Foo constructor()
typealias MyTransformer = (String) -> Int
}
package <root> {