Generate class annotation in AbstractAsmLikeInstructionListingTest
This commit is contained in:
committed by
TeamCityServer
parent
40eeee48b6
commit
f574f89f78
+35
-1
@@ -25,6 +25,14 @@ abstract class AbstractAsmLikeInstructionListingTest : CodegenTestCase() {
|
|||||||
const val CURIOUS_ABOUT_DIRECTIVE = "// CURIOUS_ABOUT "
|
const val CURIOUS_ABOUT_DIRECTIVE = "// CURIOUS_ABOUT "
|
||||||
const val LOCAL_VARIABLE_TABLE_DIRECTIVE = "// LOCAL_VARIABLE_TABLE"
|
const val LOCAL_VARIABLE_TABLE_DIRECTIVE = "// LOCAL_VARIABLE_TABLE"
|
||||||
const val RENDER_ANNOTATIONS_DIRECTIVE = "// RENDER_ANNOTATIONS"
|
const val RENDER_ANNOTATIONS_DIRECTIVE = "// RENDER_ANNOTATIONS"
|
||||||
|
|
||||||
|
val IGNORED_CLASS_VISIBLE_ANNOTATIONS = setOf(
|
||||||
|
"Lkotlin/Metadata;",
|
||||||
|
"Lkotlin/annotation/Target;",
|
||||||
|
"Lkotlin/annotation/Retention;",
|
||||||
|
"Ljava/lang/annotation/Retention;",
|
||||||
|
"Ljava/lang/annotation/Target;"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
||||||
@@ -81,6 +89,32 @@ abstract class AbstractAsmLikeInstructionListingTest : CodegenTestCase() {
|
|||||||
|
|
||||||
appendLine(" {")
|
appendLine(" {")
|
||||||
|
|
||||||
|
if (renderAnnotations) {
|
||||||
|
val textifier = Textifier()
|
||||||
|
val visitor = TraceMethodVisitor(textifier)
|
||||||
|
|
||||||
|
clazz.visibleAnnotations?.forEach {
|
||||||
|
if (it.desc !in IGNORED_CLASS_VISIBLE_ANNOTATIONS) {
|
||||||
|
it.accept(visitor.visitAnnotation(it.desc, true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clazz.invisibleAnnotations?.forEach {
|
||||||
|
it.accept(visitor.visitAnnotation(it.desc, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
clazz.visibleTypeAnnotations?.forEach {
|
||||||
|
it.accept(visitor.visitTypeAnnotation(it.typeRef, it.typePath, it.desc, true))
|
||||||
|
}
|
||||||
|
clazz.invisibleTypeAnnotations?.forEach {
|
||||||
|
it.accept(visitor.visitTypeAnnotation(it.typeRef, it.typePath, it.desc, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
textifier.getText().takeIf { it.isNotEmpty() }?.let {
|
||||||
|
appendLine(textifier.getText().joinToString("").trimEnd())
|
||||||
|
appendLine("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fields.joinTo(this, LINE_SEPARATOR.repeat(2)) { renderField(it, renderAnnotations).withMargin() }
|
fields.joinTo(this, LINE_SEPARATOR.repeat(2)) { renderField(it, renderAnnotations).withMargin() }
|
||||||
|
|
||||||
if (fields.isNotEmpty()) {
|
if (fields.isNotEmpty()) {
|
||||||
@@ -226,7 +260,7 @@ abstract class AbstractAsmLikeInstructionListingTest : CodegenTestCase() {
|
|||||||
|
|
||||||
private fun getParameterName(index: Int, method: MethodNode): String {
|
private fun getParameterName(index: Int, method: MethodNode): String {
|
||||||
val localVariableIndexOffset = when {
|
val localVariableIndexOffset = when {
|
||||||
(method.access and Opcodes.ACC_STATIC) != 0 -> 0
|
(method.access and ACC_STATIC) != 0 -> 0
|
||||||
method.isJvmOverloadsGenerated() -> 0
|
method.isJvmOverloadsGenerated() -> 0
|
||||||
else -> 1
|
else -> 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user