Remove KotlinTestUtils.replaceHash
Both package parts and SAM wrappers have no hashes in their names for a long time already
This commit is contained in:
+11
-22
@@ -45,29 +45,18 @@ class BytecodeListingTextCollectingVisitor(val filter: Filter, val withSignature
|
||||
companion object {
|
||||
@JvmOverloads
|
||||
fun getText(
|
||||
factory: ClassFileFactory,
|
||||
filter: Filter = Filter.EMPTY,
|
||||
replaceHash: Boolean = true,
|
||||
withSignatures: Boolean = false
|
||||
) =
|
||||
factory.getClassFiles()
|
||||
.sortedBy { it.relativePath }
|
||||
.mapNotNull {
|
||||
val cr = ClassReader(it.asByteArray())
|
||||
val visitor = BytecodeListingTextCollectingVisitor(filter, withSignatures)
|
||||
cr.accept(visitor, ClassReader.SKIP_CODE)
|
||||
factory: ClassFileFactory,
|
||||
filter: Filter = Filter.EMPTY,
|
||||
withSignatures: Boolean = false
|
||||
) = factory.getClassFiles()
|
||||
.sortedBy { it.relativePath }
|
||||
.mapNotNull {
|
||||
val cr = ClassReader(it.asByteArray())
|
||||
val visitor = BytecodeListingTextCollectingVisitor(filter, withSignatures)
|
||||
cr.accept(visitor, ClassReader.SKIP_CODE)
|
||||
|
||||
if (!filter.shouldWriteClass(cr.access, cr.className)) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
|
||||
if (replaceHash) {
|
||||
KotlinTestUtils.replaceHash(visitor.text, "HASH")
|
||||
}
|
||||
else {
|
||||
visitor.text
|
||||
}
|
||||
}.joinToString("\n\n", postfix = "\n")
|
||||
if (!filter.shouldWriteClass(cr.access, cr.className)) null else visitor.text
|
||||
}.joinToString("\n\n", postfix = "\n")
|
||||
}
|
||||
|
||||
interface Filter {
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||
val testFiles = loadMultiFiles(files, environment.project)
|
||||
val classFileFactory = GenerationUtils.compileFiles(testFiles.psiFiles, environment, TEST_LIGHT_ANALYSIS).factory
|
||||
|
||||
return BytecodeListingTextCollectingVisitor.getText(classFileFactory, ListAnalysisFilter(), replaceHash = false)
|
||||
return BytecodeListingTextCollectingVisitor.getText(classFileFactory, ListAnalysisFilter())
|
||||
}
|
||||
|
||||
protected fun compileWithFullAnalysis(
|
||||
@@ -94,7 +94,7 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||
private fun shouldFilterClass(descriptor: ClassDescriptor): Boolean {
|
||||
return descriptor.visibility == Visibilities.LOCAL || descriptor is SyntheticClassDescriptorForLambda
|
||||
}
|
||||
}, replaceHash = false)
|
||||
})
|
||||
}
|
||||
|
||||
private open class ListAnalysisFilter : BytecodeListingTextCollectingVisitor.Filter {
|
||||
|
||||
@@ -303,9 +303,6 @@ public class KotlinTestUtils {
|
||||
}
|
||||
};
|
||||
|
||||
// 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 KotlinTestUtils() {
|
||||
}
|
||||
|
||||
@@ -1275,20 +1272,6 @@ public class KotlinTestUtils {
|
||||
return new File(file.getParentFile(), FileUtil.getNameWithoutExtension(file) + (newExtension == null ? "" : "." + newExtension));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String replaceHashWithStar(@NotNull String string) {
|
||||
return replaceHash(string, "*");
|
||||
}
|
||||
|
||||
public static String replaceHash(@NotNull String string, @NotNull String replacement) {
|
||||
//TODO: hashes are still used in SamWrapperCodegen
|
||||
Matcher matcher = STRIP_PACKAGE_PART_HASH_PATTERN.matcher(string);
|
||||
if (matcher.find()) {
|
||||
return matcher.replaceAll("\\$" + replacement);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static boolean isAllFilesPresentTest(String testName) {
|
||||
//noinspection SpellCheckingInspection
|
||||
return testName.toLowerCase().startsWith("allfilespresentin");
|
||||
|
||||
@@ -300,9 +300,6 @@ public class KotlinTestUtils {
|
||||
}
|
||||
};
|
||||
|
||||
// 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 KotlinTestUtils() {
|
||||
}
|
||||
|
||||
@@ -1265,20 +1262,6 @@ public class KotlinTestUtils {
|
||||
return new File(file.getParentFile(), FileUtil.getNameWithoutExtension(file) + (newExtension == null ? "" : "." + newExtension));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String replaceHashWithStar(@NotNull String string) {
|
||||
return replaceHash(string, "*");
|
||||
}
|
||||
|
||||
public static String replaceHash(@NotNull String string, @NotNull String replacement) {
|
||||
//TODO: hashes are still used in SamWrapperCodegen
|
||||
Matcher matcher = STRIP_PACKAGE_PART_HASH_PATTERN.matcher(string);
|
||||
if (matcher.find()) {
|
||||
return matcher.replaceAll("\\$" + replacement);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static boolean isAllFilesPresentTest(String testName) {
|
||||
//noinspection SpellCheckingInspection
|
||||
return testName.toLowerCase().startsWith("allfilespresentin");
|
||||
|
||||
+1
-2
@@ -56,7 +56,6 @@ import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
|
||||
import org.jetbrains.kotlin.platform.impl.isJavaScript
|
||||
import org.jetbrains.kotlin.platform.impl.isJvm
|
||||
import org.jetbrains.kotlin.platform.orDefault
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
@@ -642,7 +641,7 @@ abstract class AbstractIncrementalJpsTest(
|
||||
}
|
||||
|
||||
override fun logLine(message: String?) {
|
||||
logBuf.append(KotlinTestUtils.replaceHashWithStar(message!!.replace("^$rootPath/".toRegex(), " "))).append('\n')
|
||||
logBuf.append(message!!.replace("^$rootPath/".toRegex(), " ")).append('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user