JakeWharton/diffuse

Add support for R8 retrace mapping format.

nevack opened this issue · 1 comments

Right now, diffuse fails with:

Unable to parse line 11 as member mapping:       # {"id":"com.android.tools.r8.synthesized"}

New mapping format reference https://r8.googlesource.com/r8/+/refs/heads/main/doc/retrace.md

The most simple fix:

--- a/formats/src/main/kotlin/com/jakewharton/diffuse/format/ApiMapping.kt
+++ b/formats/src/main/kotlin/com/jakewharton/diffuse/format/ApiMapping.kt
@@ -82,7 +82,7 @@ class ApiMapping private constructor(private val typeMappings: Map<TypeDescripto
       var fields: MutableMap<String, String>? = null
       var methods: MutableMap<MethodSignature, String>? = null
       toUtf8().split('\n').forEachIndexed { index, line ->
-        if (line.startsWith('#') || line.isBlank()) {
+        if (line.trimStart().startsWith('#') || line.isBlank()) {
           return@forEachIndexed
         }
         if (line.startsWith(' ')) {

Want to send a PR? In time I suspect it will make sense to parse this format a bit more efficiently, but this is an easy way to unblock things.