Change default parameter rendering in decompiled text
So the code does not contain syntax errors
This commit is contained in:
+5
-4
@@ -71,7 +71,8 @@ public fun buildDecompiledText(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val DECOMPILED_COMMENT = "/* compiled code */"
|
private val DECOMPILED_CODE_COMMENT = "/* compiled code */"
|
||||||
|
private val DECOMPILED_COMMENT_FOR_PARAMETER = "/* = compiled code */"
|
||||||
private val FLEXIBLE_TYPE_COMMENT = "/* platform type */"
|
private val FLEXIBLE_TYPE_COMMENT = "/* platform type */"
|
||||||
|
|
||||||
public val descriptorRendererForDecompiler: DescriptorRenderer = DescriptorRendererBuilder()
|
public val descriptorRendererForDecompiler: DescriptorRenderer = DescriptorRendererBuilder()
|
||||||
@@ -118,7 +119,7 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
|||||||
val header = if (isEnumEntry(descriptor))
|
val header = if (isEnumEntry(descriptor))
|
||||||
descriptor.getName().asString()
|
descriptor.getName().asString()
|
||||||
else
|
else
|
||||||
descriptorRendererForDecompiler.render(descriptor).replace("= ...", "= " + DECOMPILED_COMMENT)
|
descriptorRendererForDecompiler.render(descriptor).replace("= ...", DECOMPILED_COMMENT_FOR_PARAMETER)
|
||||||
builder.append(header)
|
builder.append(header)
|
||||||
var endOffset = builder.length()
|
var endOffset = builder.length()
|
||||||
|
|
||||||
@@ -132,11 +133,11 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
|||||||
if (descriptor is FunctionDescriptor || descriptor is PropertyDescriptor) {
|
if (descriptor is FunctionDescriptor || descriptor is PropertyDescriptor) {
|
||||||
if ((descriptor as MemberDescriptor).getModality() != Modality.ABSTRACT) {
|
if ((descriptor as MemberDescriptor).getModality() != Modality.ABSTRACT) {
|
||||||
if (descriptor is FunctionDescriptor) {
|
if (descriptor is FunctionDescriptor) {
|
||||||
builder.append(" { ").append(DECOMPILED_COMMENT).append(" }")
|
builder.append(" { ").append(DECOMPILED_CODE_COMMENT).append(" }")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// descriptor instanceof PropertyDescriptor
|
// descriptor instanceof PropertyDescriptor
|
||||||
builder.append(" ").append(DECOMPILED_COMMENT)
|
builder.append(" ").append(DECOMPILED_CODE_COMMENT)
|
||||||
}
|
}
|
||||||
endOffset = builder.length()
|
endOffset = builder.length()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ internal val p: kotlin.Int /* compiled code */
|
|||||||
|
|
||||||
internal fun f(): kotlin.Unit { /* compiled code */ }
|
internal fun f(): kotlin.Unit { /* compiled code */ }
|
||||||
|
|
||||||
internal fun kotlin.Int.plus(i: kotlin.Int): kotlin.Int { /* compiled code */ }
|
internal fun kotlin.Int.plus(i: kotlin.Int /* = compiled code */): kotlin.Int { /* compiled code */ }
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ fun f() {}
|
|||||||
val p = 3
|
val p = 3
|
||||||
private var i = 2
|
private var i = 2
|
||||||
|
|
||||||
fun Int.plus(i: Int) = this + i
|
fun Int.plus(i: Int = 1) = this + i
|
||||||
|
|
||||||
class ShouldNotBeVisible1
|
class ShouldNotBeVisible1
|
||||||
trait ShouldNotBeVisible2
|
trait ShouldNotBeVisible2
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ package testData.libraries
|
|||||||
|
|
||||||
[public fun func(a: kotlin.Int, b: kotlin.Int): kotlin.Unit { /* compiled code */ }]
|
[public fun func(a: kotlin.Int, b: kotlin.Int): kotlin.Unit { /* compiled code */ }]
|
||||||
|
|
||||||
[public fun func(a: kotlin.Int, b: kotlin.String = /* compiled code */): kotlin.Unit { /* compiled code */ }]
|
[public fun func(a: kotlin.Int, b: kotlin.String /* = compiled code */): kotlin.Unit { /* compiled code */ }]
|
||||||
|
|
||||||
[public fun func(str: kotlin.String): kotlin.Unit { /* compiled code */ }]
|
[public fun func(str: kotlin.String): kotlin.Unit { /* compiled code */ }]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user