From afafdb31ee8ff02a70dd2f9c844350a8c7ffd88b Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 2 Mar 2015 18:17:17 +0100 Subject: [PATCH] deprecate some legacy code in the standard library --- .../kotlin/collections/AbstractIterator.kt | 2 +- .../src/kotlin/collections/Exceptions.kt | 4 +-- .../src/kotlin/concurrent/FunctionalList.kt | 2 +- .../src/kotlin/concurrent/FunctionalQueue.kt | 2 +- .../src/kotlin/properties/Properties.kt | 33 ++----------------- .../stdlib/src/kotlin/template/Templates.kt | 20 +++++------ 6 files changed, 18 insertions(+), 45 deletions(-) diff --git a/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt b/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt index d0692015fd2..1c078b0afd4 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt +++ b/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt @@ -16,7 +16,7 @@ private enum class State { * A base class to simplify implementing iterators so that implementations only have to implement [computeNext] * to implement the iterator, calling [done] when the iteration is complete. */ -public abstract class AbstractIterator: Iterator { +deprecated public abstract class AbstractIterator: Iterator { private var state = State.NotReady private var nextValue: T? = null diff --git a/libraries/stdlib/src/kotlin/collections/Exceptions.kt b/libraries/stdlib/src/kotlin/collections/Exceptions.kt index eac02e90037..0b096c8f6c5 100644 --- a/libraries/stdlib/src/kotlin/collections/Exceptions.kt +++ b/libraries/stdlib/src/kotlin/collections/Exceptions.kt @@ -1,5 +1,5 @@ package kotlin -public class EmptyIterableException(private val it: Iterable<*>) : RuntimeException("$it is empty") +deprecated public class EmptyIterableException(private val it: Iterable<*>) : RuntimeException("$it is empty") -public class DuplicateKeyException(message : String = "Duplicate keys detected") : RuntimeException(message) \ No newline at end of file +deprecated public class DuplicateKeyException(message : String = "Duplicate keys detected") : RuntimeException(message) diff --git a/libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt b/libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt index 19797e8ad52..462c1a30502 100644 --- a/libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt +++ b/libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt @@ -1,6 +1,6 @@ package kotlin.concurrent -public abstract class FunctionalList(public val size: Int) { +deprecated public abstract class FunctionalList(public val size: Int) { public abstract val head: T public abstract val tail: FunctionalList diff --git a/libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt b/libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt index 33d3c18a822..859104bb733 100644 --- a/libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt +++ b/libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt @@ -2,7 +2,7 @@ package kotlin.concurrent import java.util.concurrent.Executor -public class FunctionalQueue ( +deprecated public class FunctionalQueue ( private val input: FunctionalList = FunctionalList.emptyList(), private val output: FunctionalList = FunctionalList.emptyList() ) { diff --git a/libraries/stdlib/src/kotlin/properties/Properties.kt b/libraries/stdlib/src/kotlin/properties/Properties.kt index 1b5e288039e..a8e000a09ae 100644 --- a/libraries/stdlib/src/kotlin/properties/Properties.kt +++ b/libraries/stdlib/src/kotlin/properties/Properties.kt @@ -3,7 +3,7 @@ package kotlin.properties import java.util.HashMap import java.util.ArrayList -public class ChangeEvent( +deprecated public class ChangeEvent( public val source: Any, public val name: String, public val oldValue: Any?, @@ -12,7 +12,7 @@ public class ChangeEvent( override fun toString(): String = "ChangeEvent($name, $oldValue, $newValue)" } -public trait ChangeListener { +deprecated public trait ChangeListener { public fun onPropertyChange(event: ChangeEvent): Unit } @@ -21,7 +21,7 @@ public trait ChangeListener { * updates for easier binding to user interfaces, undo/redo command stacks and * change tracking mechanisms for persistence or distributed change notifications. */ -public abstract class ChangeSupport { +deprecated public abstract class ChangeSupport { private var allListeners: MutableList? = null private var nameListeners: MutableMap>? = null @@ -81,30 +81,3 @@ public abstract class ChangeSupport { //addChangeListener(name, DelegateChangeListener(fn)) } } - -/* -TODO this seems to generate a compiler barf! -see http://youtrack.jetbrains.com/issue/KT-1362 - - protected fun createChangeListener(fn: (ChangeEvent) -> Unit): ChangeListener { - return DelegateChangeListener(fn) - } - - protected fun createChangeListener(fn: (ChangeEvent) -> Unit): ChangeListener { - return ChangeListener { - public override fun onPropertyChange(event: ChangeEvent): Unit { - fn(event) - } - } - } - -} - - -class DelegateChangeListener(val f: (ChangeEvent) -> Unit) : ChangeListener { - public override fun onPropertyChange(event: ChangeEvent): Unit { - f(event) - } -} - - diff --git a/libraries/stdlib/src/kotlin/template/Templates.kt b/libraries/stdlib/src/kotlin/template/Templates.kt index f0890bf0c7f..1d41bf64b6a 100644 --- a/libraries/stdlib/src/kotlin/template/Templates.kt +++ b/libraries/stdlib/src/kotlin/template/Templates.kt @@ -10,7 +10,7 @@ import java.util.Date // TODO this class should move into the runtime // in kotlin.StringTemplate -public class StringTemplate(private val values: Array) { +deprecated public class StringTemplate(private val values: Array) { /** * Converts the template into a String @@ -38,7 +38,7 @@ public class StringTemplate(private val values: Array) { * * See [[HtmlFormatter] and [[LocaleFormatter] respectively. */ -public fun StringTemplate.toString(formatter: Formatter): String { +deprecated public fun StringTemplate.toString(formatter: Formatter): String { val buffer = StringBuilder() append(buffer, formatter) return buffer.toString() @@ -48,7 +48,7 @@ public fun StringTemplate.toString(formatter: Formatter): String { * Appends the text representation of this string template to the given output * using the supplied formatter */ -public fun StringTemplate.append(out: Appendable, formatter: Formatter): Unit { +deprecated public fun StringTemplate.append(out: Appendable, formatter: Formatter): Unit { var constantText = true this.forEach { if (constantText) { @@ -69,19 +69,19 @@ public fun StringTemplate.append(out: Appendable, formatter: Formatter): Unit { * Converts this string template to internationalised text using the supplied * [[LocaleFormatter]] */ -public fun StringTemplate.toLocale(formatter: LocaleFormatter = LocaleFormatter()): String = toString(formatter) +deprecated public fun StringTemplate.toLocale(formatter: LocaleFormatter = LocaleFormatter()): String = toString(formatter) /** * Converts this string template to HTML text */ -public fun StringTemplate.toHtml(formatter: HtmlFormatter = HtmlFormatter()): String = toString(formatter) +deprecated public fun StringTemplate.toHtml(formatter: HtmlFormatter = HtmlFormatter()): String = toString(formatter) /** * Represents a formatter and encoder of values in a [[StringTemplate]] which understands * how to format values for a particular [[Locale]] such as with the [[LocaleFormatter]] or * to escape particular characters in different output formats such as [[HtmlFormatter] */ -public trait Formatter { +deprecated public trait Formatter { public fun format(buffer: Appendable, value: Any?): Unit } @@ -89,7 +89,7 @@ public trait Formatter { * Formats strings with no special encoding other than allowing the null text to be * configured */ -public open class ToStringFormatter : Formatter { +deprecated public open class ToStringFormatter : Formatter { private val nullString: String = "null" @@ -114,12 +114,12 @@ public open class ToStringFormatter : Formatter { } } -public val defaultLocale: Locale = Locale.getDefault() +deprecated public val defaultLocale: Locale = Locale.getDefault() /** * Formats values using a given [[Locale]] for internationalisation */ -public open class LocaleFormatter(protected val locale: Locale = defaultLocale) : ToStringFormatter() { +deprecated public open class LocaleFormatter(protected val locale: Locale = defaultLocale) : ToStringFormatter() { override fun toString(): String = "LocaleFormatter{$locale}" @@ -149,7 +149,7 @@ public open class LocaleFormatter(protected val locale: Locale = defaultLocale) /** * Formats values for HTML encoding, escaping special characters in HTML. */ -public class HtmlFormatter(locale: Locale = defaultLocale) : LocaleFormatter(locale) { +deprecated public class HtmlFormatter(locale: Locale = defaultLocale) : LocaleFormatter(locale) { override fun toString(): String = "HtmlFormatter{$locale}"