Skip to content

Commit 4ff0aac

Browse files
authored
Sort class signatures before dump the same way KotlinApiBuildTask does (#188)
1 parent bfe4803 commit 4ff0aac

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/main/kotlin/KotlinApiBuildTask.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,7 @@ public open class KotlinApiBuildTask @Inject constructor(
105105
.filterOutAnnotated(nonPublicMarkers.map(::replaceDots).toSet())
106106

107107
outputApiDir.resolve("$projectName.api").bufferedWriter().use { writer ->
108-
filteredSignatures
109-
.sortedBy { it.name }
110-
.forEach { api ->
111-
writer.append(api.signature).appendLine(" {")
112-
api.memberSignatures
113-
.sortedWith(MEMBER_SORT_ORDER)
114-
.forEach { writer.append("\t").appendLine(it.signature) }
115-
writer.appendLine("}\n")
116-
}
108+
filteredSignatures.dump(writer)
117109
}
118110
}
119111

src/main/kotlin/api/KotlinSignaturesLoading.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,16 @@ public fun List<ClassBinarySignature>.dump(): PrintStream = dump(to = System.out
313313

314314
@ExternalApi
315315
public fun <T : Appendable> List<ClassBinarySignature>.dump(to: T): T {
316-
forEach { classApi ->
317-
with(to) {
318-
append(classApi.signature).appendLine(" {")
319-
classApi.memberSignatures
320-
.sortedWith(MEMBER_SORT_ORDER)
321-
.forEach { append("\t").appendLine(it.signature) }
322-
appendLine("}\n")
316+
sortedBy { it.name }
317+
.forEach { classApi ->
318+
with(to) {
319+
append(classApi.signature).appendLine(" {")
320+
classApi.memberSignatures
321+
.sortedWith(MEMBER_SORT_ORDER)
322+
.forEach { append("\t").appendLine(it.signature) }
323+
appendLine("}\n")
324+
}
323325
}
324-
}
325326
return to
326327
}
327328

0 commit comments

Comments
 (0)