Promote common StringBuilder to stable

This commit is contained in:
Abduqodiri Qurbonzoda
2020-05-30 01:33:39 +03:00
parent 4568e438a9
commit e05eeea6cd
5 changed files with 168 additions and 178 deletions
@@ -42,16 +42,15 @@ expect interface Appendable {
/**
* Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance.
*
* @param value the character sequence from which a subsequence is appended. If [value] is `null`,
* then characters are appended as if [value] contained the four characters `"null"`.
* @param value the character sequence from which a subsequence is appended.
* @param startIndex the beginning (inclusive) of the subsequence to append.
* @param endIndex the end (exclusive) of the subsequence to append.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public fun <T : Appendable> T.appendRange(value: CharSequence?, startIndex: Int, endIndex: Int): T {
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public fun <T : Appendable> T.appendRange(value: CharSequence, startIndex: Int, endIndex: Int): T {
@Suppress("UNCHECKED_CAST")
return append(value, startIndex, endIndex) as T
}
@@ -64,7 +64,6 @@ expect class StringBuilder : Appendable, CharSequence {
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.3")
// @ExperimentalStdlibApi
fun append(value: Boolean): StringBuilder
/**
@@ -72,15 +71,14 @@ expect class StringBuilder : Appendable, CharSequence {
*
* Characters are appended in order, starting at the index 0.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun append(value: CharArray): StringBuilder
/**
* Appends the specified string [value] to this string builder and returns this instance.
*/
@SinceKotlin("1.3")
// @ExperimentalStdlibApi
fun append(value: String): StringBuilder
/**
@@ -88,8 +86,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* The capacity is the maximum length this string builder can have before an allocation occurs.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun capacity(): Int
/**
@@ -98,8 +96,8 @@ expect class StringBuilder : Appendable, CharSequence {
* If the current capacity is less than the [minimumCapacity], a new backing storage is allocated with greater capacity.
* Otherwise, this method takes no action and simply returns.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun ensureCapacity(minimumCapacity: Int)
/**
@@ -107,8 +105,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* Returns `-1` if the specified [string] does not occur in this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun indexOf(string: String): Int
/**
@@ -117,8 +115,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* Returns `-1` if the specified [string] does not occur in this string builder starting at the specified [startIndex].
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun indexOf(string: String, startIndex: Int): Int
/**
@@ -127,8 +125,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* Returns `-1` if the specified [string] does not occur in this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun lastIndexOf(string: String): Int
/**
@@ -137,8 +135,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* Returns `-1` if the specified [string] does not occur in this string builder starting at the specified [startIndex].
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun lastIndexOf(string: String, startIndex: Int): Int
/**
@@ -149,8 +147,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun insert(index: Int, value: Boolean): StringBuilder
/**
@@ -158,8 +156,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun insert(index: Int, value: Char): StringBuilder
/**
@@ -169,8 +167,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun insert(index: Int, value: CharArray): StringBuilder
/**
@@ -183,8 +181,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun insert(index: Int, value: CharSequence?): StringBuilder
/**
@@ -195,8 +193,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun insert(index: Int, value: Any?): StringBuilder
/**
@@ -204,8 +202,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun insert(index: Int, value: String): StringBuilder
/**
@@ -219,8 +217,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] if [newLength] is less than zero.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun setLength(newLength: Int)
/**
@@ -228,8 +226,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException if [startIndex] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun substring(startIndex: Int): String
/**
@@ -237,8 +235,8 @@ expect class StringBuilder : Appendable, CharSequence {
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this string builder indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun substring(startIndex: Int, endIndex: Int): String
/**
@@ -248,8 +246,8 @@ expect class StringBuilder : Appendable, CharSequence {
* then it may be resized to become more space efficient.
* Calling this method may, but is not required to, affect the value of the [capacity] property.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
fun trimToSize()
}
@@ -267,8 +265,8 @@ public expect fun StringBuilder.clear(): StringBuilder
*
* @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect operator fun StringBuilder.set(index: Int, value: Char)
/**
@@ -280,8 +278,8 @@ public expect operator fun StringBuilder.set(index: Int, value: Char)
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] if [startIndex] is less than zero, greater than the length of this string builder, or `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.setRange(startIndex: Int, endIndex: Int, value: String): StringBuilder
/**
@@ -293,8 +291,8 @@ public expect fun StringBuilder.setRange(startIndex: Int, endIndex: Int, value:
*
* @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.deleteAt(index: Int): StringBuilder
/**
@@ -305,8 +303,8 @@ public expect fun StringBuilder.deleteAt(index: Int): StringBuilder
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] is out of range of this string builder indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.deleteRange(startIndex: Int, endIndex: Int): StringBuilder
/**
@@ -321,8 +319,8 @@ public expect fun StringBuilder.deleteRange(startIndex: Int, endIndex: Int): Str
* @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],
* or when that index is out of the [destination] array indices range.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)
/**
@@ -336,23 +334,22 @@ public expect fun StringBuilder.toCharArray(destination: CharArray, destinationO
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] array indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.appendRange(value: CharArray, startIndex: Int, endIndex: Int): StringBuilder
/**
* Appends a subsequence of the specified character sequence [value] to this string builder and returns this instance.
*
* @param value the character sequence from which a subsequence is appended. If [value] is `null`,
* then characters are appended as if [value] contained the four characters `"null"`.
* @param value the character sequence from which a subsequence is appended.
* @param startIndex the beginning (inclusive) of the subsequence to append.
* @param endIndex the end (exclusive) of the subsequence to append.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public expect fun StringBuilder.appendRange(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.appendRange(value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder
/**
* Inserts characters in a subarray of the specified character array [value] into this string builder at the specified [index] and returns this instance.
@@ -367,8 +364,8 @@ public expect fun StringBuilder.appendRange(value: CharSequence?, startIndex: In
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] array indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.insertRange(index: Int, value: CharArray, startIndex: Int, endIndex: Int): StringBuilder
/**
@@ -377,17 +374,16 @@ public expect fun StringBuilder.insertRange(index: Int, value: CharArray, startI
* The inserted characters go in the same order as in the [value] character sequence, starting at [index].
*
* @param index the position in this string builder to insert at.
* @param value the character sequence from which a subsequence is inserted. If [value] is `null`,
* then characters will be inserted as if [value] contained the four characters `"null"`.
* @param value the character sequence from which a subsequence is inserted.
* @param startIndex the beginning (inclusive) of the subsequence to insert.
* @param endIndex the end (exclusive) of the subsequence to insert.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public expect fun StringBuilder.insertRange(index: Int, value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder
@SinceKotlin("1.4")
@WasExperimental(ExperimentalStdlibApi::class)
public expect fun StringBuilder.insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@Deprecated("Use append(value: Any?) instead", ReplaceWith("append(value = obj)"), DeprecationLevel.WARNING)
@@ -450,7 +446,6 @@ public inline fun StringBuilder.appendLine(value: String?): StringBuilder = appe
public inline fun StringBuilder.appendLine(value: Any?): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@OptIn(ExperimentalStdlibApi::class)
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: CharArray): StringBuilder = append(value).appendLine()