https://kotlinlang.org logo
g

gitai

06/16/2021, 10:11 AM
How can you view a composable function source code after the compiler plugin edits?
b

Big Chungus

06/16/2021, 10:13 AM
Decompile .class files in idea?
g

gitai

06/16/2021, 10:16 AM
if you mean tools->Kotlin->Show Kotlin Byte Code, then no its not supported
Caused by: java.lang.IllegalStateException: Couldn't obtain compiled function body for @androidx.compose.runtime.Composable public inline fun Column(modifier: ...
g

gildor

06/16/2021, 10:21 AM
You can get .class file from Gradle build dir and decompile it
g

gitai

06/16/2021, 10:31 AM
I wonder if there is some debug flag that can show the transformed source code during compilation before compiling to byte code...
Oddly AS decompile shows only function signatures when decompiling   ../app/build/tmp/kotlin-classes/debug/com/example/myapp4/MainActivityKt.class   And nothing for other generated files in the directory
d

Daniel

06/16/2021, 2:33 PM
The compose team has a test helper that translates to pseudocode. You can see it used in the YouTube videos by Leland Richardson where he works on the compose compiler.
g

gitai

06/16/2021, 3:09 PM
@Daniel Thanks, found them.
👍 1
3 Views