Change default parameter rendering in decompiled text

So the code does not contain syntax errors
This commit is contained in:
Pavel V. Talanov
2014-12-02 14:38:59 +03:00
parent d0479aa61b
commit 72aba2b758
4 changed files with 8 additions and 7 deletions
@@ -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 */"
public val descriptorRendererForDecompiler: DescriptorRenderer = DescriptorRendererBuilder()
@@ -118,7 +119,7 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
val header = if (isEnumEntry(descriptor))
descriptor.getName().asString()
else
descriptorRendererForDecompiler.render(descriptor).replace("= ...", "= " + DECOMPILED_COMMENT)
descriptorRendererForDecompiler.render(descriptor).replace("= ...", DECOMPILED_COMMENT_FOR_PARAMETER)
builder.append(header)
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 as MemberDescriptor).getModality() != Modality.ABSTRACT) {
if (descriptor is FunctionDescriptor) {
builder.append(" { ").append(DECOMPILED_COMMENT).append(" }")
builder.append(" { ").append(DECOMPILED_CODE_COMMENT).append(" }")
}
else {
// descriptor instanceof PropertyDescriptor
builder.append(" ").append(DECOMPILED_COMMENT)
builder.append(" ").append(DECOMPILED_CODE_COMMENT)
}
endOffset = builder.length()
}
@@ -9,5 +9,5 @@ internal val p: kotlin.Int /* 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
private var i = 2
fun Int.plus(i: Int) = this + i
fun Int.plus(i: Int = 1) = this + i
class ShouldNotBeVisible1
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.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 */ }]