Added "ReplaceWith" to deprecated library functions

This commit is contained in:
Valentin Kipyatkov
2015-05-20 19:17:04 +03:00
parent ec5256a0f0
commit b256329287
10 changed files with 75 additions and 75 deletions
@@ -94,7 +94,7 @@ public val Collection<*>.indices: IntRange
/**
* Returns an [IntRange] that starts with zero and ends at the value of this number but does not include it.
*/
deprecated("Use 0..n-1 range instead.")
deprecated("Use 0..n-1 range instead.", ReplaceWith("0..this - 1"))
public val Int.indices: IntRange
get() = 0..this - 1
@@ -41,7 +41,7 @@ public fun <T> Iterator<T>.asSequence(): Sequence<T> {
return iteratorSequence.constrainOnce()
}
deprecated("Use asSequence() instead.")
deprecated("Use asSequence() instead.", ReplaceWith("asSequence()"))
public fun <T> Iterator<T>.sequence(): Sequence<T> = asSequence()
@@ -596,7 +596,7 @@ public fun <T : Any> sequence(nextFunction: () -> T?): Sequence<T> {
return GeneratorSequence(nextFunction, { nextFunction() }).constrainOnce()
}
deprecated("Use sequence() instead")
deprecated("Use sequence() instead", ReplaceWith("sequence(nextFunction)"))
public fun <T : Any> stream(nextFunction: () -> T?): Sequence<T> = sequence(nextFunction)
/**
@@ -616,5 +616,5 @@ public /*inline*/ fun <T : Any> sequence(initialValue: T, nextFunction: (T) -> T
public fun <T: Any> sequence(initialValueFunction: () -> T?, nextFunction: (T) -> T?): Sequence<T> =
GeneratorSequence(initialValueFunction, nextFunction)
deprecated("Use sequence() instead")
deprecated("Use sequence() instead", ReplaceWith("sequence(initialValue, nextFunction)"))
public /*inline*/ fun <T : Any> stream(initialValue: T, nextFunction: (T) -> T?): Sequence<T> = sequence(initialValue, nextFunction)
@@ -2,10 +2,10 @@ package kotlin
import java.util.*
deprecated("Use firstOrNull function instead.")
deprecated("Use firstOrNull function instead.", ReplaceWith("firstOrNull(predicate)"))
public inline fun <T> Array<out T>.find(predicate: (T) -> Boolean): T? = firstOrNull(predicate)
deprecated("Use firstOrNull function instead.")
deprecated("Use firstOrNull function instead.", ReplaceWith("firstOrNull(predicate)"))
public inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? = firstOrNull(predicate)
deprecated("Use listOf(...) or arrayListOf(...) instead")
@@ -20,7 +20,7 @@ public fun <K, V> hashMap(vararg values: Pair<K, V>): HashMap<K, V> = hashMapOf(
deprecated("Use listOf(...) or linkedListOf(...) instead")
public fun linkedList<T>(vararg values: T): LinkedList<T> = linkedListOf(*values)
deprecated("Use linkedMapOf(...) instead")
deprecated("Use linkedMapOf(...) instead", ReplaceWith("linkedMapOf(*values)"))
public fun <K, V> linkedMap(vararg values: Pair<K, V>): LinkedHashMap<K, V> = linkedMapOf(*values)
/** Copies all characters into a [[Collection] */
@@ -61,7 +61,7 @@ public /*inline*/ fun runnable(action: () -> Unit): Runnable {
}
}
deprecated("Use forEachIndexed instead.")
deprecated("Use forEachIndexed instead.", ReplaceWith("forEachIndexed(operation)"))
public inline fun <T> List<T>.forEachWithIndex(operation: (Int, T) -> Unit): Unit = forEachIndexed(operation)
deprecated("Function with undefined semantic")
@@ -70,40 +70,40 @@ public fun <T> countTo(n: Int): (T) -> Boolean {
return { ++count; count <= n }
}
deprecated("Use contains() function instead")
deprecated("Use contains() function instead", ReplaceWith("contains(item)"))
public fun <T> Iterable<T>.containsItem(item : T) : Boolean = contains(item)
deprecated("Use sortBy() instead")
deprecated("Use sortBy() instead", ReplaceWith("sortBy(comparator)"))
public fun <T> Iterable<T>.sort(comparator: java.util.Comparator<T>) : List<T> = sortBy(comparator)
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val Array<*>.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val ByteArray.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val CharArray.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val ShortArray.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val IntArray.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val LongArray.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val FloatArray.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val DoubleArray.size: Int get() = size()
deprecated("Use size() instead")
deprecated("Use size() instead", ReplaceWith("size()"))
public val BooleanArray.size: Int get() = size()
deprecated("Use compareValuesBy() instead")
deprecated("Use compareValuesBy() instead", ReplaceWith("compareValuesBy(a, b, *functions)"))
public fun <T : Any> compareBy(a: T?, b: T?, vararg functions: (T) -> Comparable<*>?): Int = compareValuesBy(a, b, *functions)
@@ -112,7 +112,7 @@ public fun <T : Any> compareBy(a: T?, b: T?, vararg functions: (T) -> Comparable
*
* @includeFunctionBody ../../test/collections/ListSpecificTest.kt first
*/
deprecated("Use firstOrNull() function instead")
deprecated("Use firstOrNull() function instead", ReplaceWith("this.firstOrNull()"))
public val <T> List<T>.first: T?
get() = this.firstOrNull()
@@ -135,7 +135,7 @@ public val <T> List<T>.last: T?
*
* @includeFunctionBody ../../test/collections/ListSpecificTest.kt head
*/
deprecated("Use firstOrNull() function instead")
deprecated("Use firstOrNull() function instead", ReplaceWith("firstOrNull()"))
public val <T> List<T>.head: T?
get() = firstOrNull()
@@ -144,39 +144,39 @@ public val <T> List<T>.head: T?
*
* @includeFunctionBody ../../test/collections/ListSpecificTest.kt tail
*/
deprecated("Use drop(1) function call instead")
deprecated("Use drop(1) function call instead", ReplaceWith("drop(1)"))
public val <T> List<T>.tail: List<T>
get() {
return drop(1)
}
/** Returns true if this collection is empty */
deprecated("Use isEmpty() function call instead")
deprecated("Use isEmpty() function call instead", ReplaceWith("isEmpty()"))
public val Collection<*>.empty: Boolean
get() = isEmpty()
/** Returns the size of the collection */
deprecated("Use size() function call instead")
deprecated("Use size() function call instead", ReplaceWith("size()"))
public val Collection<*>.size: Int
get() = size()
/** Returns the size of the map */
deprecated("Use size() function call instead")
deprecated("Use size() function call instead", ReplaceWith("size()"))
public val Map<*, *>.size: Int
get() = size()
/** Returns true if this map is empty */
deprecated("Use isEmpty() function call instead")
deprecated("Use isEmpty() function call instead", ReplaceWith("isEmpty()"))
public val Map<*, *>.empty: Boolean
get() = isEmpty()
/** Returns true if this collection is not empty */
deprecated("Use isNotEmpty() function call instead")
deprecated("Use isNotEmpty() function call instead", ReplaceWith("isNotEmpty()"))
public val Collection<*>.notEmpty: Boolean
get() = isNotEmpty()
deprecated("Use length() instead")
deprecated("Use length() instead", ReplaceWith("length()"))
public val CharSequence.length: Int
get() = length()
@@ -2,40 +2,40 @@ package kotlin
// deprecated to be removed after M12
deprecated("Use arrayOf() instead.")
deprecated("Use arrayOf() instead.", ReplaceWith("arrayOf(*t)"))
inline public fun <reified T> array(vararg t : T) : Array<T> = arrayOf(*t)
suppress("NOTHING_TO_INLINE")
deprecated("Use doubleArrayOf() instead.")
deprecated("Use doubleArrayOf() instead.", ReplaceWith("doubleArrayOf(*content)"))
inline public fun doubleArray(vararg content : Double) : DoubleArray = doubleArrayOf(*content)
suppress("NOTHING_TO_INLINE")
deprecated("Use floatArrayOf() instead.")
deprecated("Use floatArrayOf() instead.", ReplaceWith("floatArrayOf(*content)"))
inline public fun floatArray(vararg content : Float) : FloatArray = floatArrayOf(*content)
suppress("NOTHING_TO_INLINE")
deprecated("Use longArrayOf() instead.")
deprecated("Use longArrayOf() instead.", ReplaceWith("longArrayOf(*content)"))
inline public fun longArray(vararg content : Long) : LongArray = longArrayOf(*content)
suppress("NOTHING_TO_INLINE")
deprecated("Use intArrayOf() instead.")
deprecated("Use intArrayOf() instead.", ReplaceWith("intArrayOf(*content)"))
inline public fun intArray(vararg content : Int) : IntArray = intArrayOf(*content)
suppress("NOTHING_TO_INLINE")
deprecated("Use charArrayOf() instead.")
deprecated("Use charArrayOf() instead.", ReplaceWith("charArrayOf(*content)"))
inline public fun charArray(vararg content : Char) : CharArray = charArrayOf(*content)
suppress("NOTHING_TO_INLINE")
deprecated("Use shortArrayOf() instead.")
deprecated("Use shortArrayOf() instead.", ReplaceWith("shortArrayOf(*content)"))
inline public fun shortArray(vararg content : Short) : ShortArray = shortArrayOf(*content)
suppress("NOTHING_TO_INLINE")
deprecated("Use byteArrayOf() instead.")
deprecated("Use byteArrayOf() instead.", ReplaceWith("byteArrayOf(*content)"))
inline public fun byteArray(vararg content : Byte) : ByteArray = byteArrayOf(*content)
suppress("NOTHING_TO_INLINE")
deprecated("Use booleanArrayOf() instead.")
deprecated("Use booleanArrayOf() instead.", ReplaceWith("booleanArrayOf(*content)"))
inline public fun booleanArray(vararg content : Boolean) : BooleanArray = booleanArrayOf(*content)
deprecated("Use toTypedArray() instead.")
deprecated("Use toTypedArray() instead.", ReplaceWith("toTypedArray()"))
inline public fun <reified T> Collection<T>.copyToArray(): Array<T> = toTypedArray()
@@ -19,13 +19,13 @@ package kotlin
import java.util.*
import java.util.concurrent.Callable
deprecated("Use sortedSetOf(...) instead")
deprecated("Use sortedSetOf(...) instead", ReplaceWith("sortedSetOf(*values)"))
public fun sortedSet<T>(vararg values: T): TreeSet<T> = sortedSetOf(*values)
deprecated("Use sortedSetOf(...) instead")
deprecated("Use sortedSetOf(...) instead", ReplaceWith("sortedSetOf(comparator, *values)"))
public fun sortedSet<T>(comparator: Comparator<T>, vararg values: T): TreeSet<T> = sortedSetOf(comparator, *values)
deprecated("Use sortedMapOf(...) instead")
deprecated("Use sortedMapOf(...) instead", ReplaceWith("sortedMapOf(*values)"))
public fun <K, V> sortedMap(vararg values: Pair<K, V>): SortedMap<K, V> = sortedMapOf(*values)
/**
@@ -38,11 +38,11 @@ public /*inline*/ fun <T> callable(action: () -> T): Callable<T> {
}
}
deprecated("Use length() instead")
deprecated("Use length() instead", ReplaceWith("length()"))
public val String.size: Int
get() = length()
deprecated("Use length() instead")
deprecated("Use length() instead", ReplaceWith("length()"))
public val CharSequence.size: Int
get() = length()
@@ -1,113 +1,113 @@
package kotlin
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun <T> Array<out T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun <T> Iterable<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinToString() instead")
deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
public fun <T> Sequence<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
return joinToString(separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun <T> Array<out T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun <T> Iterable<T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
deprecated("Use joinTo() instead")
deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)"))
public fun <T> Sequence<T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
joinTo(buffer, separator, prefix, postfix, limit, truncated)
}
+3 -3
View File
@@ -101,7 +101,7 @@ public fun Document?.elements(namespaceUri: String, localName: String): List<Ele
}
public fun NodeList?.asList() : List<Node> = if (this == null) emptyList() else NodeListAsList(this)
deprecated("use asList instead")
deprecated("use asList instead", ReplaceWith("asList()"))
public fun NodeList?.toList(): List<Node> = asList()
public fun NodeList?.toElementList(): List<Element> {
@@ -268,8 +268,8 @@ private class PreviousSiblings(private var node: Node) : Iterable<Node> {
}
/** Returns true if this node is a Text node or a CDATA node */
deprecated("use property isText instead")
public fun Node.isText() : Boolean = nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE
deprecated("use property isText instead", ReplaceWith("isText"))
public fun Node.isText() : Boolean = isText
/**
* it is *true* when [Node.nodeType] is TEXT_NODE or CDATA_SECTION_NODE
+4 -4
View File
@@ -79,10 +79,10 @@ public fun String.trimStart(vararg chars: Char): String = trimStart { it in char
*/
public fun String.trimEnd(vararg chars: Char): String = trimEnd { it in chars }
deprecated("Use removePrefix() instead")
deprecated("Use removePrefix() instead", ReplaceWith("removePrefix(prefix)"))
public fun String.trimLeading(prefix: String): String = removePrefix(prefix)
deprecated("Use removeSuffix() instead")
deprecated("Use removeSuffix() instead", ReplaceWith("removeSuffix(postfix)"))
public fun String.trimTrailing(postfix: String): String = removeSuffix(postfix)
/**
@@ -95,7 +95,7 @@ public fun String.trim(): String = trim { it.isWhitespace() }
*/
public fun String.trimStart(): String = trimStart { it.isWhitespace() }
deprecated("Use trimStart instead.")
deprecated("Use trimStart instead.", ReplaceWith("trimStart()"))
public fun String.trimLeading(): String = trimStart { it.isWhitespace() }
/**
@@ -103,7 +103,7 @@ public fun String.trimLeading(): String = trimStart { it.isWhitespace() }
*/
public fun String.trimEnd(): String = trimEnd { it.isWhitespace() }
deprecated("Use trimEnd instead.")
deprecated("Use trimEnd instead.", ReplaceWith("trimEnd()"))
public fun String.trimTrailing(): String = trimEnd { it.isWhitespace() }
/**
@@ -32,7 +32,7 @@ private fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this a
/**
* Compares this string to another string, ignoring case considerations.
*/
deprecated("Use equals(anotherString, ignoreCase = true) instead")
deprecated("Use equals(anotherString, ignoreCase = true) instead", ReplaceWith("equals(anotherString, ignoreCase = true)"))
public fun String.equalsIgnoreCase(anotherString: String): Boolean = equals(anotherString, ignoreCase = true)
/**
+1 -1
View File
@@ -64,7 +64,7 @@ public fun <T> compareBy(vararg functions: (T) -> Comparable<*>?): Comparator<T>
/**
* Creates a comparator using the sequence of functions to calculate a result of comparison.
*/
deprecated("Use compareBy() instead")
deprecated("Use compareBy() instead", ReplaceWith("compareBy(*functions)"))
public fun <T> comparator(vararg functions: (T) -> Comparable<*>?): Comparator<T> = compareBy(*functions)
/**