From 9021273001b6278dfe21ff5a25a8a30c4aed2db3 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Mon, 13 Apr 2020 14:23:22 +0300 Subject: [PATCH] Introduce StringBuilder.appendLine in stdlib-common #KT-37839 (#4068) (cherry picked from commit d0566e52051981caeffaa9f09a83f7028a9f485c) --- .../kotlin/kotlin/text/StringBuilderNative.kt | 69 ++++++++++++++++--- 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/runtime/src/main/kotlin/kotlin/text/StringBuilderNative.kt b/runtime/src/main/kotlin/kotlin/text/StringBuilderNative.kt index 55fcc40104f..f73b1c2f7f9 100644 --- a/runtime/src/main/kotlin/kotlin/text/StringBuilderNative.kt +++ b/runtime/src/main/kotlin/kotlin/text/StringBuilderNative.kt @@ -5,14 +5,63 @@ package kotlin.text -fun StringBuilder.appendln(it: String) = append(it).appendln() -fun StringBuilder.appendln(it: Boolean) = append(it).appendln() -fun StringBuilder.appendln(it: Byte) = append(it).appendln() -fun StringBuilder.appendln(it: Short) = append(it).appendln() -fun StringBuilder.appendln(it: Int) = append(it).appendln() -fun StringBuilder.appendln(it: Long) = append(it).appendln() -fun StringBuilder.appendln(it: Float) = append(it).appendln() -fun StringBuilder.appendln(it: Double) = append(it).appendln() -fun StringBuilder.appendln(it: Any?) = append(it).appendln() +/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */ +@SinceKotlin("1.4") +@kotlin.internal.InlineOnly +public inline fun StringBuilder.appendLine(value: Byte): StringBuilder = append(value).appendLine() -fun StringBuilder.appendln() = append('\n') +/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */ +@SinceKotlin("1.4") +@kotlin.internal.InlineOnly +public inline fun StringBuilder.appendLine(value: Short): StringBuilder = append(value).appendLine() + +/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */ +@SinceKotlin("1.4") +@kotlin.internal.InlineOnly +public inline fun StringBuilder.appendLine(value: Int): StringBuilder = append(value).appendLine() + +/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */ +@SinceKotlin("1.4") +@kotlin.internal.InlineOnly +public inline fun StringBuilder.appendLine(value: Long): StringBuilder = append(value).appendLine() + +/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */ +@SinceKotlin("1.4") +@kotlin.internal.InlineOnly +public inline fun StringBuilder.appendLine(value: Float): StringBuilder = append(value).appendLine() + +/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */ +@SinceKotlin("1.4") +@kotlin.internal.InlineOnly +public inline fun StringBuilder.appendLine(value: Double): StringBuilder = append(value).appendLine() + + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: String): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Boolean): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Byte): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Short): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Int): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Long): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Float): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Double): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine(it)"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(it: Any?): StringBuilder = appendLine(it) + +@Deprecated("Use appendLine instead", ReplaceWith("appendLine()"), level = DeprecationLevel.WARNING) +public fun StringBuilder.appendln(): StringBuilder = appendLine() \ No newline at end of file