https://kotlinlang.org logo
Title
r

reactormonk

07/12/2022, 12:24 PM
Is there a library that implements the Debug / inspect functionality similar to the Rust
inspect
? Where you get a full dump of a class, not just the
toString
k

Klitos Kyriacou

07/12/2022, 1:02 PM
You could use
Json.serializeToString
from the kotlinx.serialization library. If you don't want to use that, there's
ToStringBuilder
+
RecursiveToStringStyle
from Apache commons.
m

MR3Y

07/12/2022, 1:42 PM
You can implement a simple compiler plugin that calls
IrModuleFragment.dump()
on any class/file which should give you the full dump of the file, see: https://blog.bnorm.dev/writing-your-second-compiler-plugin-part-2 for a reference
r

reactormonk

07/12/2022, 1:45 PM
That's a neat way to go about it ^^, is that compiler plugin available as library?
Probably requires some additional smithing to be cool to use.
d

dmitriy.novozhilov

07/12/2022, 5:27 PM
There is no IR in runtime, so plugin approach won't work. Some kind of serialisation is a good solution
👍 1
m

MR3Y

07/12/2022, 5:42 PM
Thanks for clarifying, I missed that.