From 0df3d37f88493b70ea6f0e5c4f38eb4a0ba6d370 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 1 Oct 2015 20:42:43 +0300 Subject: [PATCH] Drop deprecated API. --- .../src/kotlin/collections/ArraysJVM.kt | 24 ------ .../src/kotlin/collections/Exceptions.kt | 7 -- .../stdlib/src/kotlin/collections/JUtil.kt | 7 -- .../stdlib/src/kotlin/collections/Sequence.kt | 4 - .../stdlib/src/kotlin/concurrent/Locks.kt | 13 --- .../src/kotlin/properties/Properties.kt | 86 ------------------- libraries/stdlib/src/kotlin/text/CharJVM.kt | 6 -- libraries/stdlib/src/kotlin/util/Integers.kt | 13 --- .../stdlib/test/properties/PropertiesTest.kt | 50 ----------- .../properties/delegation/DelegationTest.kt | 23 ----- 10 files changed, 233 deletions(-) delete mode 100644 libraries/stdlib/src/kotlin/collections/Exceptions.kt delete mode 100644 libraries/stdlib/src/kotlin/properties/Properties.kt delete mode 100644 libraries/stdlib/test/properties/PropertiesTest.kt diff --git a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt index 03ff1b85b5a..70aa7a940f8 100644 --- a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt @@ -54,30 +54,6 @@ import kotlin.jvm.internal.Intrinsic */ @Intrinsic("kotlin.arrays.array") public fun booleanArrayOf(vararg content : Boolean) : BooleanArray = content -// TODO: Move inputStream to kotlin.io -/** - * Creates an input stream for reading data from this byte array. - */ -@Deprecated("Use inputStream() method instead.", ReplaceWith("this.inputStream()", "kotlin.io.inputStream")) -public val ByteArray.inputStream : ByteArrayInputStream - get() = inputStream() - -/** - * Creates an input stream for reading data from this byte array. - */ -@Deprecated("Use inputStream() method from kotlin.io package instead.", ReplaceWith("this.inputStream()", "kotlin.io.inputStream")) -@HiddenDeclaration -public fun ByteArray.inputStream(): ByteArrayInputStream = ByteArrayInputStream(this) - -/** - * Creates an input stream for reading data from the specified portion of this byte array. - * @param offset the start offset of the portion of the array to read. - * @param length the length of the portion of the array to read. - */ -@Deprecated("Use inputStream() method from kotlin.io package instead.", ReplaceWith("this.inputStream(offset, length)", "kotlin.io.inputStream")) -@HiddenDeclaration -public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length) - /** * Converts the contents of this byte array to a string using the specified [charset]. */ diff --git a/libraries/stdlib/src/kotlin/collections/Exceptions.kt b/libraries/stdlib/src/kotlin/collections/Exceptions.kt deleted file mode 100644 index a725b43f040..00000000000 --- a/libraries/stdlib/src/kotlin/collections/Exceptions.kt +++ /dev/null @@ -1,7 +0,0 @@ -package kotlin - -@Deprecated("This exception is no longer thrown by any standard library classes and is going to be removed") -public class EmptyIterableException(private val it: Iterable<*>) : RuntimeException("$it is empty") - -@Deprecated("This exception is no longer thrown by any standard library classes and is going to be removed") -public class DuplicateKeyException(message : String = "Duplicate keys detected") : RuntimeException(message) \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/collections/JUtil.kt b/libraries/stdlib/src/kotlin/collections/JUtil.kt index cc4332aa9e0..25feb204991 100644 --- a/libraries/stdlib/src/kotlin/collections/JUtil.kt +++ b/libraries/stdlib/src/kotlin/collections/JUtil.kt @@ -80,13 +80,6 @@ public fun listOfNotNull(vararg values: T?): List = values.filterNo public val Collection<*>.indices: IntRange get() = 0..size() - 1 -/** - * 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.", ReplaceWith("0..this - 1")) -public val Int.indices: IntRange - get() = 0..this - 1 - /** * Returns the index of the last item in the list or -1 if the list is empty. * diff --git a/libraries/stdlib/src/kotlin/collections/Sequence.kt b/libraries/stdlib/src/kotlin/collections/Sequence.kt index b315220824b..a7fb281eca1 100644 --- a/libraries/stdlib/src/kotlin/collections/Sequence.kt +++ b/libraries/stdlib/src/kotlin/collections/Sequence.kt @@ -29,10 +29,6 @@ public fun Iterator.asSequence(): Sequence { return iteratorSequence.constrainOnce() } -@Deprecated("Use asSequence() instead.", ReplaceWith("asSequence()")) -public fun Iterator.sequence(): Sequence = asSequence() - - /** * Creates a sequence that returns all values from this enumeration. The sequence is constrained to be iterated only once. */ diff --git a/libraries/stdlib/src/kotlin/concurrent/Locks.kt b/libraries/stdlib/src/kotlin/concurrent/Locks.kt index 426d92b9bbc..9d28db85996 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Locks.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Locks.kt @@ -54,16 +54,3 @@ public inline fun ReentrantReadWriteLock.write(action: () -> T): T { wl.unlock() } } - -/** - * Executes the given [operation] and awaits for CountDownLatch. - * - * @return the return value of the action. - */ -@Deprecated("Use CountDownLatch(Int) instead and await it manually.") -public fun Int.latch(operation: CountDownLatch.() -> T): T { - val latch = CountDownLatch(this) - val result = latch.operation() - latch.await() - return result -} diff --git a/libraries/stdlib/src/kotlin/properties/Properties.kt b/libraries/stdlib/src/kotlin/properties/Properties.kt deleted file mode 100644 index 9ceb9f8ef93..00000000000 --- a/libraries/stdlib/src/kotlin/properties/Properties.kt +++ /dev/null @@ -1,86 +0,0 @@ -package kotlin.properties - -import java.util.HashMap -import java.util.ArrayList - -@Deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") -public class ChangeEvent( - public val source: Any, - public val name: String, - public val oldValue: Any?, - public val newValue: Any? -) { - override fun toString(): String = "ChangeEvent($name, $oldValue, $newValue)" -} - -@Deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") -public interface ChangeListener { - public fun onPropertyChange(event: ChangeEvent): Unit -} - -/** - * Represents an object where properties can be listened to and notified on - * updates for easier binding to user interfaces, undo/redo command stacks and - * change tracking mechanisms for persistence or distributed change notifications. - */ -@Deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") -public abstract class ChangeSupport { - private var allListeners: MutableList? = null - private var nameListeners: MutableMap>? = null - - - public fun addChangeListener(listener: ChangeListener) { - if (allListeners == null) { - allListeners = ArrayList() - } - allListeners?.add(listener) - } - - public fun addChangeListener(name: String, listener: ChangeListener) { - if (nameListeners == null) { - nameListeners = HashMap>() - } - var listeners = nameListeners?.get(name) - if (listeners == null) { - listeners = arrayListOf() - nameListeners?.put(name, listeners!!) - } - listeners?.add(listener) - } - - protected fun changeProperty(name: String, oldValue: T?, newValue: T?): Unit { - if (oldValue != newValue) { - firePropertyChanged(ChangeEvent(this, name, oldValue, newValue)) - } - } - - protected fun firePropertyChanged(event: ChangeEvent): Unit { - if (nameListeners != null) { - val listeners = nameListeners?.get(event.name) - if (listeners != null) { - for (listener in listeners) { - listener.onPropertyChange(event) - } - } - } - if (allListeners != null) { - for (listener in allListeners!!) { - listener.onPropertyChange(event) - } - } - } - - protected fun property(init: T): ReadWriteProperty { - return Delegates.observable(init) { desc, oldValue, newValue -> changeProperty(desc.name, oldValue, newValue) } - } - - public fun onPropertyChange(fn: (ChangeEvent) -> Unit) { - // TODO - //addChangeListener(DelegateChangeListener(fn)) - } - - public fun onPropertyChange(name: String, fn: (ChangeEvent) -> Unit) { - // TODO - //addChangeListener(name, DelegateChangeListener(fn)) - } -} diff --git a/libraries/stdlib/src/kotlin/text/CharJVM.kt b/libraries/stdlib/src/kotlin/text/CharJVM.kt index 6f2d067fdc5..4699e8d6a45 100644 --- a/libraries/stdlib/src/kotlin/text/CharJVM.kt +++ b/libraries/stdlib/src/kotlin/text/CharJVM.kt @@ -61,12 +61,6 @@ public fun Char.isJavaIdentifierPart(): Boolean = Character.isJavaIdentifierPart */ public fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdentifierStart(this) -@Deprecated("Please use Char.isJavaIdentifierStart() instead") -public fun Char.isJavaLetter(): Boolean = Character.isJavaLetter(this) - -@Deprecated("Please use Char.isJavaIdentifierPart() instead") -public fun Char.isJavaLetterOrDigit(): Boolean = Character.isJavaLetterOrDigit(this) - /** * Determines whether a character is whitespace according to the Unicode standard. * Returns `true` if the character is whitespace. diff --git a/libraries/stdlib/src/kotlin/util/Integers.kt b/libraries/stdlib/src/kotlin/util/Integers.kt index 93b803e6b35..e593c54d592 100644 --- a/libraries/stdlib/src/kotlin/util/Integers.kt +++ b/libraries/stdlib/src/kotlin/util/Integers.kt @@ -2,19 +2,6 @@ @file:kotlin.jvm.JvmName("StandardKt") package kotlin -/** - * Executes the given function [body] the number of times equal to the value of this integer. - */ -@Deprecated("Use repeat(n) { body } instead.") -public inline fun Int.times(body : () -> Unit) { - var count = this; - while (count > 0) { - body() - count-- - } -} - - /** * Executes the given function [body] specified number of [times]. * diff --git a/libraries/stdlib/test/properties/PropertiesTest.kt b/libraries/stdlib/test/properties/PropertiesTest.kt deleted file mode 100644 index 03391a24706..00000000000 --- a/libraries/stdlib/test/properties/PropertiesTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -package test.properties - -import kotlin.* -import kotlin.properties.* -import kotlin.test.* -import java.util.* -import org.junit.Test as test - -class Customer : ChangeSupport() { - // TODO the setter code should be generated - // via KT-1299 - var name: String? = null - set(value) { - changeProperty("name", field, value) - field = value - } - - var city: String? = null - set(value) { - changeProperty("city", field, value) - field = value - } - - override fun toString() = "Customer($name, $city)" -} - -class MyChangeListener : ChangeListener { - val events = ArrayList() - - override fun onPropertyChange(event: ChangeEvent): Unit { - println("Property changed: $event") - events.add(event) - } -} - -class PropertiesTest { - - @test fun testModel() { - val c = Customer() - c.name = "James" - c.city = "Mells" - - val listener = MyChangeListener() - c.addChangeListener(listener) - c.name = "Andrey" - println("Customer $c and raised change events ${listener.events}") - - assertEquals(1, listener.events.size(), "Should have received a change event ${listener.events}") - } -} \ No newline at end of file diff --git a/libraries/stdlib/test/properties/delegation/DelegationTest.kt b/libraries/stdlib/test/properties/delegation/DelegationTest.kt index f8bcd715668..2df73609c12 100644 --- a/libraries/stdlib/test/properties/delegation/DelegationTest.kt +++ b/libraries/stdlib/test/properties/delegation/DelegationTest.kt @@ -22,29 +22,6 @@ private class NotNullVarTestGeneric(val a1: String, val b1: T) { } } -class ObservablePropertyInChangeSupportTest: ChangeSupport() { - - var b by property(init = 2) - var c by property(3) - - @test fun doTest() { - var result = false - addChangeListener("b", object: ChangeListener { - public override fun onPropertyChange(event: ChangeEvent) { - result = true - } - }) - addChangeListener("c", object: ChangeListener { - public override fun onPropertyChange(event: ChangeEvent) { - result = false - } - }) - b = 4 - assertTrue(b == 4, "fail: b != 4") - assertTrue(result, "fail: result should be true") - } -} - class ObservablePropertyTest { var result = false