Fix deprecated replaceAll and replaceFirst usages.

This commit is contained in:
Ilya Gorbunov
2015-05-13 23:15:15 +03:00
parent 36fb5b3c49
commit 79a5e0607d
13 changed files with 31 additions and 30 deletions
@@ -46,7 +46,7 @@ public abstract class AbstractPseudoValueTest : AbstractPseudocodeTest() {
}
fun elementText(element: JetElement?): String =
element?.getText()?.replaceAll("\\s+", " ") ?: ""
element?.getText()?.replace("\\s+".toRegex(), " ") ?: ""
fun valueDecl(value: PseudoValue): String {
val typePredicate = expectedTypePredicateMap.getOrPut(value) { getExpectedTypePredicate(value, bindingContext) }
@@ -28,6 +28,8 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import kotlin.Function1;
import kotlin.KotlinPackage;
import kotlin.text.Regex;
import kotlin.text.MatchResult;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cli.common.KotlinVersion;
@@ -39,8 +41,6 @@ import org.junit.Rule;
import java.io.File;
import java.io.IOException;
import java.util.regex.MatchResult;
import java.util.regex.Pattern;
import static org.junit.Assert.*;
@@ -79,12 +79,12 @@ public abstract class KotlinIntegrationTestBase {
String contentWithRelativePaths = content.replace(baseDir.getAbsolutePath(), pathId);
@Language("RegExp")
String RELATIVE_PATH_WITH_MIXED_SEPARATOR = Pattern.quote(pathId) + "[-.\\w/\\\\]*";
String RELATIVE_PATH_WITH_MIXED_SEPARATOR = Regex.Companion.escape(pathId) + "[-.\\w/\\\\]*";
return KotlinPackage.replaceAll(contentWithRelativePaths, RELATIVE_PATH_WITH_MIXED_SEPARATOR, new Function1<MatchResult, String>() {
return new Regex(RELATIVE_PATH_WITH_MIXED_SEPARATOR).replace(contentWithRelativePaths, new Function1<MatchResult, String>() {
@Override
public String invoke(MatchResult mr) {
return FileUtil.toSystemIndependentName(mr.group());
return FileUtil.toSystemIndependentName(mr.getValue());
}
});
}
@@ -57,7 +57,7 @@ public trait AbstractSMAPBaseTest {
if (InTextDirectivesUtils.isDirectiveDefined(fileContent, smapPrefix)) {
InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileContent, smapPrefix)
var smapData = fileContent.substring(fileContent.indexOf(smapPrefix))
smapData = smapData.replaceAll("//", "").trim()
smapData = smapData.replace("//", "").trim()
return SMAPAndFile(if (smapData.startsWith("SMAP ABSENT")) null else smapData,
SMAPAndFile.getPath(file.getVirtualFile().getCanonicalPath()!!))
@@ -27,9 +27,11 @@ import java.io.File
import java.util.ArrayDeque
import java.util.ArrayList
import java.util.regex.Pattern
import kotlin.text.Regex
private val START_PATTERN = Pattern.compile(">>>( *)(.*)$")
private val INCOMPLETE_PATTERN = Pattern.compile("\\.\\.\\.( *)(.*)$")
private val TRAILING_NEWLINE_REGEX = Regex("\n$")
private val INCOMPLETE_LINE_MESSAGE = "incomplete line"
@@ -89,8 +91,8 @@ public abstract class AbstractReplInterpreterTest : UsefulTestCase() {
Assert.assertEquals(
"After evaluation of: $code",
StringUtil.convertLineSeparators(expected).replaceFirst("\n$", ""),
StringUtil.convertLineSeparators(actual).replaceFirst("\n$", "")
StringUtil.convertLineSeparators(expected).replaceFirst(TRAILING_NEWLINE_REGEX, ""),
StringUtil.convertLineSeparators(actual).replaceFirst(TRAILING_NEWLINE_REGEX, "")
)
}
}