From 45fec9257a2441704f2ee9ed04207332938e6360 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 4 Feb 2015 15:37:03 +0300 Subject: [PATCH] Minor, move replaceHashWithStar to JetTestUtils --- .../org/jetbrains/kotlin/test/JetTestUtils.java | 12 ++++++++++++ .../jps/build/AbstractIncrementalJpsTest.kt | 17 ++--------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java index 33193141267..cac3c0590e2 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java @@ -237,6 +237,9 @@ public class JetTestUtils { @SuppressWarnings("unchecked") private static final Class[] NO_INNER_CLASSES = ArrayUtil.EMPTY_CLASS_ARRAY; + // We suspect sequences of eight consecutive hexadecimal digits to be a package part hash code + private static final Pattern STRIP_PACKAGE_PART_HASH_PATTERN = Pattern.compile("\\$([0-9a-f]{8})"); + private JetTestUtils() { } @@ -877,4 +880,13 @@ public class JetTestUtils { public static File replaceExtension(@NotNull File file, @Nullable String newExtension) { return new File(file.getParentFile(), FileUtil.getNameWithoutExtension(file) + (newExtension == null ? "" : "." + newExtension)); } + + @NotNull + public static String replaceHashWithStar(@NotNull String string) { + Matcher matcher = STRIP_PACKAGE_PART_HASH_PATTERN.matcher(string); + if (matcher.find()) { + return matcher.replaceAll("\\$*"); + } + return string; + } } diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt index d147c27c157..9ca202a651b 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -20,6 +20,7 @@ import org.jetbrains.jps.builders.JpsBuildTestCase import kotlin.properties.Delegates import com.intellij.openapi.util.io.FileUtil import java.io.File +import org.jetbrains.kotlin.test.JetTestUtils import org.jetbrains.jps.builders.CompileScopeTestBuilder import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerBase import org.jetbrains.jps.builders.logging.BuildLoggingManager @@ -34,7 +35,6 @@ import java.util.HashMap import org.jetbrains.kotlin.utils.keysToMap import org.jetbrains.jps.incremental.messages.BuildMessage import kotlin.test.assertFalse -import java.util.regex.Pattern import kotlin.test.assertEquals import org.jetbrains.jps.model.JpsModuleRootModificationUtil import com.intellij.openapi.util.io.FileUtilRt @@ -347,20 +347,7 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { override fun isEnabled(): Boolean = true override fun logLine(message: String?) { - fun String.replaceHashWithStar(): String { - val matcher = STRIP_PACKAGE_PART_HASH_PATTERN.matcher(this) - if (matcher.find()) { - return matcher.replaceAll("\\$*") - } - return this - } - - logBuf.append(message!!.trimLeading(rootPath + "/").replaceHashWithStar()).append('\n') - } - - class object { - // We suspect sequences of eight consecutive hexadecimal digits to be a package part hash code - val STRIP_PACKAGE_PART_HASH_PATTERN = Pattern.compile("\\$([0-9a-f]{8})") + logBuf.append(JetTestUtils.replaceHashWithStar(message!!.trimLeading(rootPath + "/"))).append('\n') } }