Prepare to hide native specific regex methods from public API

This commit is contained in:
Ilya Gorbunov
2018-11-21 18:04:11 +03:00
committed by Nikolay Igotti
parent 1c62b882bd
commit 6f6bfd15ed
2 changed files with 7 additions and 5 deletions
@@ -32,13 +32,11 @@ class PatternTest2 {
var testString = "foo123"
assertTrue(regex.matches(testString))
assertTrue(regex.containsMatchIn(testString, 0))
assertTrue(regex.lookingAt(testString))
assertTrue(regex in testString)
testString = "fox"
assertFalse(regex.matches(testString))
assertFalse(regex.containsMatchIn(testString, 0))
assertFalse(regex.lookingAt(testString))
assertFalse(regex in testString)
assertTrue(Regex("foo.*").matches("foo123"))
assertFalse(Regex("foo.*").matches("fox"))
@@ -880,7 +878,7 @@ class PatternTest2 {
@Test fun testCompile2() {
val findString = "\\Qimport\\E"
val regex = Regex(findString)
regex.containsMatchIn("import a.A;\n\n import b.B;\nclass C {}", 0)
assertTrue(regex in "import a.A;\n\n import b.B;\nclass C {}")
}
@Test fun testCompile3() {
@@ -256,6 +256,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
*
* @param replacement A replacement expression that can include substitutions.
*/
@Suppress("DEPRECATION_ERROR")
actual fun replaceFirst(input: CharSequence, replacement: String): String
= replaceFirst(input) { match -> processReplacement(match, replacement) }
@@ -297,9 +298,11 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
override fun toString(): String = nativePattern.toString()
// Native specific =================================================================================================
@Deprecated("The function is going to be removed from public API", level = DeprecationLevel.ERROR)
fun lookingAt(input: CharSequence): Boolean = doMatch(input, Mode.FIND) != null
/** Indicates whether the regular expression can find at least one match in the specified [input] starting with [index]. */
@Deprecated("The function is going to be removed from public API", level = DeprecationLevel.ERROR)
fun containsMatchIn(input: CharSequence, index: Int): Boolean = find(input, index) != null
/**
@@ -307,6 +310,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
* the given function [transform] that takes a [MatchResult] representing the occurrence and returns a string to be used as a
* replacement for that occurrence.
*/
@Deprecated("The function is going to be removed from public API", level = DeprecationLevel.ERROR)
fun replaceFirst(input: CharSequence, transform: (MatchResult) -> CharSequence): String {
val match = find(input) ?: return input.toString()
val length = input.length