Tidy toPrettyString()

I missed this during the initial InsnNodeUtils port.
bzip2
Graham 5 years ago
parent c575ef2a9a
commit c10134c1f6
  1. 10
      asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt

@ -7,10 +7,8 @@ import org.objectweb.asm.tree.IntInsnNode
import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.LdcInsnNode
import org.objectweb.asm.util.Textifier import org.objectweb.asm.util.Textifier
import org.objectweb.asm.util.TraceMethodVisitor import org.objectweb.asm.util.TraceMethodVisitor
import java.io.IOException
import java.io.PrintWriter import java.io.PrintWriter
import java.io.StringWriter import java.io.StringWriter
import java.io.UncheckedIOException
private val PURE_OPCODES = setOf( private val PURE_OPCODES = setOf(
-1, -1,
@ -273,16 +271,14 @@ fun createIntConstant(value: Int): AbstractInsnNode = when (value) {
fun AbstractInsnNode.toPrettyString(): String { fun AbstractInsnNode.toPrettyString(): String {
val printer = Textifier() val printer = Textifier()
val visitor = TraceMethodVisitor(printer) val visitor = TraceMethodVisitor(printer)
accept(visitor) accept(visitor)
try {
StringWriter().use { stringWriter -> StringWriter().use { stringWriter ->
PrintWriter(stringWriter).use { printWriter -> PrintWriter(stringWriter).use { printWriter ->
printer.print(printWriter) printer.print(printWriter)
return stringWriter.toString().trim { it <= ' ' } return stringWriter.toString().trim()
}
} }
} catch (ex: IOException) {
throw UncheckedIOException(ex)
} }
} }

Loading…
Cancel
Save