Introduce Common StringBuilder.append/insert(Byte/Short) extensions #KT-63341

This commit is contained in:
Abduqodiri Qurbonzoda
2023-11-13 23:06:57 +02:00
parent db6a662631
commit e94b247835
5 changed files with 193 additions and 0 deletions
+12
View File
@@ -46,10 +46,16 @@ public fun kotlin.text.StringBuilder.append(vararg value: kotlin.Any?): kotlin.t
public fun kotlin.text.StringBuilder.append(vararg value: kotlin.String?): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public inline fun kotlin.text.StringBuilder.append(value: kotlin.Byte): kotlin.text.StringBuilder
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use appendRange instead.", replaceWith = kotlin.ReplaceWith(expression = "this.appendRange(str, offset, offset + len)", imports = {}))
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.append(str: kotlin.CharArray, offset: kotlin.Int, len: kotlin.Int): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public inline fun kotlin.text.StringBuilder.append(value: kotlin.Short): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.4")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.Appendable.appendLine(): kotlin.text.Appendable
@@ -439,6 +445,12 @@ public inline fun kotlin.CharSequence.indexOfFirst(predicate: (kotlin.Char) -> k
public inline fun kotlin.CharSequence.indexOfLast(predicate: (kotlin.Char) -> kotlin.Boolean): kotlin.Int
@kotlin.SinceKotlin(version = "1.9")
public inline fun kotlin.text.StringBuilder.insert(index: kotlin.Int, value: kotlin.Byte): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public inline fun kotlin.text.StringBuilder.insert(index: kotlin.Int, value: kotlin.Short): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.4")
public inline fun kotlin.text.StringBuilder.insertRange(index: kotlin.Int, value: kotlin.CharArray, startIndex: kotlin.Int, endIndex: kotlin.Int): kotlin.text.StringBuilder
@@ -651,6 +651,50 @@ public actual class StringBuilder public actual constructor(content: String) : A
}
/**
* Appends the string representation of the specified byte [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "NOTHING_TO_INLINE")
@SinceKotlin("1.9")
public actual inline fun StringBuilder.append(value: Byte): StringBuilder = this.append(value)
/**
* Appends the string representation of the specified short [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "NOTHING_TO_INLINE")
@SinceKotlin("1.9")
public actual inline fun StringBuilder.append(value: Short): StringBuilder = this.append(value)
/**
* Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "NOTHING_TO_INLINE")
@SinceKotlin("1.9")
public actual inline fun StringBuilder.insert(index: Int, value: Byte): StringBuilder = this.insert(index, value)
/**
* Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "NOTHING_TO_INLINE")
@SinceKotlin("1.9")
public actual inline fun StringBuilder.insert(index: Int, value: Short): StringBuilder = this.insert(index, value)
/**
* Clears the content of this string builder making it empty and returns this instance.
*
@@ -8,6 +8,54 @@
package kotlin.text
/**
* Appends the string representation of the specified byte [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.append(value: Byte): StringBuilder = this.append(value.toInt())
/**
* Appends the string representation of the specified short [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.append(value: Short): StringBuilder = this.append(value.toInt())
/**
* Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.insert(index: Int, value: Byte): StringBuilder = this.insert(index, value.toInt())
/**
* Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.insert(index: Int, value: Short): StringBuilder = this.insert(index, value.toInt())
/**
* Clears the content of this string builder making it empty and returns this instance.
*
@@ -714,6 +714,55 @@ private constructor (private var array: CharArray) : CharSequence, Appendable {
}
}
/**
* Appends the string representation of the specified byte [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.append(value: Byte): StringBuilder = this.append(value)
/**
* Appends the string representation of the specified short [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.append(value: Short): StringBuilder = this.append(value)
/**
* Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.insert(index: Int, value: Byte): StringBuilder = this.insert(index, value)
/**
* Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.insert(index: Int, value: Short): StringBuilder = this.insert(index, value)
/**
* Clears the content of this string builder making it empty and returns this instance.
*
@@ -324,6 +324,46 @@ public expect class StringBuilder : Appendable, CharSequence {
}
/**
* Appends the string representation of the specified byte [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
public expect fun StringBuilder.append(value: Byte): StringBuilder
/**
* Appends the string representation of the specified short [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
public expect fun StringBuilder.append(value: Short): StringBuilder
/**
* Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
public expect fun StringBuilder.insert(index: Int, value: Byte): StringBuilder
/**
* Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
public expect fun StringBuilder.insert(index: Int, value: Short): StringBuilder
/**
* Clears the content of this string builder making it empty and returns this instance.
*