Harden deprecations to prepare for cleanup.

This commit is contained in:
Ilya Gorbunov
2017-01-18 20:41:07 +03:00
parent 1ccc655cdc
commit 70f3cee9ff
7 changed files with 30 additions and 28 deletions
+5 -5
View File
@@ -19,25 +19,25 @@ package kotlin.js
import kotlin.annotation.AnnotationTarget.*
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, VALUE_PARAMETER, PROPERTY_GETTER, PROPERTY_SETTER)
@Deprecated("Use `external` modifier instead")
@Deprecated("Use `external` modifier instead", level = DeprecationLevel.ERROR)
public annotation class native(@Deprecated public val name: String = "")
@Target(FUNCTION)
@Deprecated("Use inline extension function with body using dynamic")
@Deprecated("Use inline extension function with body using dynamic", level = DeprecationLevel.ERROR)
public annotation class nativeGetter
@Target(FUNCTION)
@Deprecated("Use inline extension function with body using dynamic")
@Deprecated("Use inline extension function with body using dynamic", level = DeprecationLevel.ERROR)
public annotation class nativeSetter
@Target(FUNCTION)
@Deprecated("Use inline extension function with body using dynamic")
@Deprecated("Use inline extension function with body using dynamic", level = DeprecationLevel.ERROR)
public annotation class nativeInvoke
@Target(CLASS, FUNCTION, PROPERTY)
internal annotation class library(public val name: String = "")
@Deprecated("It is no longer has any effect and will be dropped in a future version")
@Deprecated("It is no longer has any effect and will be dropped in a future version", level = DeprecationLevel.ERROR)
@Target(PROPERTY)
public annotation class enumerable()
+3 -3
View File
@@ -64,7 +64,7 @@ public class Regex(pattern: String, options: Set<RegexOption>) {
return nativePattern.test(input.toString())
}
@Deprecated("Use containsMatchIn() or 'in' operator instead.", ReplaceWith("this in input"))
@Deprecated("Use containsMatchIn() or 'in' operator instead.", ReplaceWith("this in input"), level = DeprecationLevel.ERROR)
public fun hasMatch(input: CharSequence): Boolean = containsMatchIn(input)
/** Returns the first match of a regular expression in the [input], beginning at the specified [startIndex].
@@ -74,14 +74,14 @@ public class Regex(pattern: String, options: Set<RegexOption>) {
*/
public fun find(input: CharSequence, startIndex: Int = 0): MatchResult? = nativePattern.findNext(input.toString(), startIndex)
@Deprecated("Use find() instead.", ReplaceWith("find(input, startIndex)"))
@Deprecated("Use find() instead.", ReplaceWith("find(input, startIndex)"), level = DeprecationLevel.ERROR)
public fun match(input: CharSequence, startIndex: Int = 0): MatchResult? = find(input, startIndex)
/** Returns a sequence of all occurrences of a regular expression within the [input] string, beginning at the specified [startIndex].
*/
public fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = generateSequence({ find(input, startIndex) }, { match -> match.next() })
@Deprecated("Use findAll() instead.", ReplaceWith("findAll(input, startIndex)"))
@Deprecated("Use findAll() instead.", ReplaceWith("findAll(input, startIndex)"), level = DeprecationLevel.ERROR)
public fun matchAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = findAll(input, startIndex)
/**
+1 -1
View File
@@ -111,7 +111,7 @@ public fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolea
public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String =
nativeReplace(RegExp(Regex.escape(oldChar.toString()), if (ignoreCase) "gi" else "g"), newChar.toString())
@Deprecated("Use replaceFirst(String, String) instead.", ReplaceWith("replaceFirst(oldValue, newValue, ignoreCase = ignoreCase)"))
@Deprecated("Use replaceFirst(String, String) instead.", ReplaceWith("replaceFirst(oldValue, newValue, ignoreCase = ignoreCase)"), level = DeprecationLevel.ERROR)
public fun String.replaceFirstLiteral(oldValue: String, newValue: String, ignoreCase: Boolean = false): String =
nativeReplace(RegExp(Regex.escape(oldValue), if (ignoreCase) "i" else ""), Regex.escapeReplacement(newValue))
+6 -4
View File
@@ -3,16 +3,18 @@ package kotlin.dom
import org.w3c.dom.Document
import org.w3c.dom.Node
@Deprecated("use declarations from org.w3c.dom instead: create document directly via constructor Document() or use document.implementation.createDocument")
@Deprecated("use declarations from org.w3c.dom instead: create document directly via constructor Document() or use document.implementation.createDocument", level = DeprecationLevel.ERROR)
public fun createDocument(): Document = Document()
@Deprecated("use member property outerHTML of Element class instead")
@Deprecated("use member property outerHTML of Element class instead", level = DeprecationLevel.ERROR)
public inline val Node.outerHTML: String get() = asDynamic().outerHTML
/** Converts the node to an XML String */
@Deprecated("use outerHTML directly")
@Deprecated("use outerHTML directly", level = DeprecationLevel.ERROR)
@Suppress("DEPRECATION_ERROR")
public fun Node.toXmlString(): String = this.outerHTML
/** Converts the node to an XML String */
@Deprecated("use outerHTML directly")
@Deprecated("use outerHTML directly", level = DeprecationLevel.ERROR)
@Suppress("DEPRECATION_ERROR")
public fun Node.toXmlString(xmlDeclaration: Boolean): String = this.outerHTML
+11 -11
View File
@@ -34,16 +34,16 @@ fun Element?.childElements(): List<Element> = this?.childNodes?.filterElements()
fun Element?.childElements(name: String): List<Element> = this?.childNodes?.filterElements()?.filter { it.nodeName == name } ?: emptyList()
/** The descendant elements of this document */
@Deprecated("Use elements() function instead", ReplaceWith("this.elements()"))
@Deprecated("Use elements() function instead", ReplaceWith("this.elements()"), level = DeprecationLevel.ERROR)
val Document?.elements: List<Element>
get() = this.elements()
/** The descendant elements of this elements */
@Deprecated("Use elements() function instead", ReplaceWith("this?.elements() ?: emptyList()"))
@Deprecated("Use elements() function instead", ReplaceWith("this?.elements() ?: emptyList()"), level = DeprecationLevel.ERROR)
val Element?.elements: List<Element>
get() = this?.elements() ?: emptyList()
@Deprecated("Use non-nullable receiver version elements()", ReplaceWith("this?.elements(localName) ?: emptyList()"))
@Deprecated("Use non-nullable receiver version elements()", ReplaceWith("this?.elements(localName) ?: emptyList()"), level = DeprecationLevel.ERROR)
@JsName("deprecated_elements")
fun Element?.elements(localName: String): List<Element> = this?.elements(localName) ?: emptyList()
@@ -58,7 +58,7 @@ fun Document?.elements(localName: String = "*"): List<Element> {
return this?.getElementsByTagName(localName)?.asElementList() ?: emptyList()
}
@Deprecated("Use non-nullable elements function instead", ReplaceWith("this?.elements(namespaceUri, localName) ?: emptyList()"))
@Deprecated("Use non-nullable elements function instead", ReplaceWith("this?.elements(namespaceUri, localName) ?: emptyList()"), level = DeprecationLevel.ERROR)
@JsName("deprecated_elements_2")
fun Element?.elements(namespaceUri: String, localName: String): List<Element> = this?.elements(namespaceUri, localName) ?: emptyList()
@@ -72,13 +72,13 @@ fun Document?.elements(namespaceUri: String, localName: String): List<Element> {
return this?.getElementsByTagNameNS(namespaceUri, localName)?.asElementList() ?: emptyList()
}
@Deprecated("Use non-null function instead with elvis", ReplaceWith("this?.asList() ?: emptyList()"))
@Deprecated("Use non-null function instead with elvis", ReplaceWith("this?.asList() ?: emptyList()"), level = DeprecationLevel.ERROR)
@JsName("deprecated_asList")
fun NodeList?.asList(): List<Node> = this?.asList() ?: emptyList()
fun NodeList.asList(): List<Node> = NodeListAsList(this)
@Deprecated("Use asElementList() instead", ReplaceWith("this?.asElementList() ?: emptyList()"))
@Deprecated("Use asElementList() instead", ReplaceWith("this?.asElementList() ?: emptyList()"), level = DeprecationLevel.ERROR)
fun NodeList?.toElementList(): List<Element> = this?.asElementList() ?: emptyList()
/**
@@ -164,23 +164,23 @@ val Node.isElement: Boolean
get() = nodeType == Node.ELEMENT_NODE
/** Returns the attribute value or empty string if its not present */
@Deprecated("Use getAttribute with elvis operator", ReplaceWith("this.getAttribute(name) ?: \"\""))
@Deprecated("Use getAttribute with elvis operator", ReplaceWith("this.getAttribute(name) ?: \"\""), level = DeprecationLevel.ERROR)
fun Element.attribute(name: String): String {
return this.getAttribute(name) ?: ""
}
@Deprecated("Use asList().firstOrNull() instead", ReplaceWith("this?.asList()?.firstOrNull()"))
@Deprecated("Use asList().firstOrNull() instead", ReplaceWith("this?.asList()?.firstOrNull()"), level = DeprecationLevel.ERROR)
val NodeList?.head: Node?
get() = this?.asList()?.firstOrNull()
@Deprecated("Use asList().firstOrNull() instead", ReplaceWith("this?.asList()?.firstOrNull()"))
@Deprecated("Use asList().firstOrNull() instead", ReplaceWith("this?.asList()?.firstOrNull()"), level = DeprecationLevel.ERROR)
val NodeList?.first: Node?
get() = this?.asList()?.firstOrNull()
@Deprecated("Use asList().lastOrNull() instead", ReplaceWith("this?.asList()?.lastOrNull()"))
@Deprecated("Use asList().lastOrNull() instead", ReplaceWith("this?.asList()?.lastOrNull()"), level = DeprecationLevel.ERROR)
val NodeList?.last: Node?
get() = this?.asList()?.lastOrNull()
@Deprecated("Use asList().lastOrNull() instead instead", ReplaceWith("last"))
@Deprecated("Use asList().lastOrNull() instead instead", ReplaceWith("last"), level = DeprecationLevel.ERROR)
val NodeList?.tail: Node?
get() = this?.asList()?.lastOrNull()
+2 -2
View File
@@ -35,13 +35,13 @@ fun Node.ownerDocument(doc: Document? = null): Document = when {
/**
* Adds a newly created text node to an element which either already has an owner Document or one must be provided as a parameter
*/
@Deprecated("Use appendText() instead", ReplaceWith("appendText(text, doc)"))
@Deprecated("Use appendText() instead", ReplaceWith("appendText(text, doc)"), level = DeprecationLevel.ERROR)
fun Element.addText(text: String, doc: Document? = null): Element = appendText(text, doc)
/**
* Adds a newly created text node to an element which either already has an owner Document or one must be provided as a parameter
*/
@Deprecated("Use appendText() instead", ReplaceWith("appendText(text)"))
@Deprecated("Use appendText() instead", ReplaceWith("appendText(text)"), level = DeprecationLevel.ERROR)
fun Element.addText(text: String): Element = appendText(text)
+2 -2
View File
@@ -24,10 +24,10 @@ external interface JsClass<T : Any> {
val name: String
}
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("T::class.js"))
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("T::class.js"), level = DeprecationLevel.WARNING)
external fun <T : Any> jsClass(): JsClass<T>
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("this::class.js"))
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("this::class.js"), level = DeprecationLevel.WARNING)
val <T : Any> T.jsClass: JsClass<T>
get() = js("Object").getPrototypeOf(this).constructor