diff --git a/js/js.libraries/src/core/annotations.kt b/js/js.libraries/src/core/annotations.kt index 890bcecd8b7..586de4d8e1e 100644 --- a/js/js.libraries/src/core/annotations.kt +++ b/js/js.libraries/src/core/annotations.kt @@ -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() diff --git a/js/js.libraries/src/core/regex.kt b/js/js.libraries/src/core/regex.kt index d304de4bd83..16b3272269d 100644 --- a/js/js.libraries/src/core/regex.kt +++ b/js/js.libraries/src/core/regex.kt @@ -64,7 +64,7 @@ public class Regex(pattern: String, options: Set) { 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) { */ 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 = 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 = findAll(input, startIndex) /** diff --git a/js/js.libraries/src/core/stringsCode.kt b/js/js.libraries/src/core/stringsCode.kt index 8b15b72010b..dd5c0e87112 100644 --- a/js/js.libraries/src/core/stringsCode.kt +++ b/js/js.libraries/src/core/stringsCode.kt @@ -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)) diff --git a/js/js.libraries/src/deprecated/domCode.kt b/js/js.libraries/src/deprecated/domCode.kt index 78f566910ce..228130e136c 100644 --- a/js/js.libraries/src/deprecated/domCode.kt +++ b/js/js.libraries/src/deprecated/domCode.kt @@ -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 diff --git a/js/js.libraries/src/dom/Dom.kt b/js/js.libraries/src/dom/Dom.kt index f8ada9b343b..bef8f26898c 100644 --- a/js/js.libraries/src/dom/Dom.kt +++ b/js/js.libraries/src/dom/Dom.kt @@ -34,16 +34,16 @@ fun Element?.childElements(): List = this?.childNodes?.filterElements() fun Element?.childElements(name: String): List = 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 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 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 = this?.elements(localName) ?: emptyList() @@ -58,7 +58,7 @@ fun Document?.elements(localName: String = "*"): List { 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 = this?.elements(namespaceUri, localName) ?: emptyList() @@ -72,13 +72,13 @@ fun Document?.elements(namespaceUri: String, localName: String): List { 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 = this?.asList() ?: emptyList() fun NodeList.asList(): List = 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 = 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() diff --git a/js/js.libraries/src/dom/Mutations.kt b/js/js.libraries/src/dom/Mutations.kt index 00037aff7b3..4240d8e1722 100644 --- a/js/js.libraries/src/dom/Mutations.kt +++ b/js/js.libraries/src/dom/Mutations.kt @@ -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) diff --git a/js/js.libraries/src/reflect/JsClass.kt b/js/js.libraries/src/reflect/JsClass.kt index 1ac26afbe12..77e84deeeca 100644 --- a/js/js.libraries/src/reflect/JsClass.kt +++ b/js/js.libraries/src/reflect/JsClass.kt @@ -24,10 +24,10 @@ external interface JsClass { 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 jsClass(): JsClass -@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.jsClass: JsClass get() = js("Object").getPrototypeOf(this).constructor