https://kotlinlang.org logo
#feed
Title
d

Damien O'Hara

06/05/2023, 1:28 PM
I've just released version 0.1.2 of Kapshot, a compiler plugin that allows Kotlin code to access fragments of its own source text at runtime. 0.1.2 adds support for capturing the source of property declarations. This complements the existing support for class, method and block capture. Write self-testing sample code!
Copy code
val captured = CapturedBlock {
    println("Hello!")
}

@CaptureSource
val myVal = 10

/* ... */

captured.source.text // == "println(\"Hello!\")"

sourceOf(::myVal).text // == "val myVal = 10"
https://github.com/mfwgenerics/kapshot
👏 8
😮 3
👍 7
🤔 1
a

altavir

06/05/2023, 4:28 PM
Wow. Looks interesting!
p

Pavel

06/07/2023, 7:53 AM
Wow. That's brilliant!
c

Chenbing Android

06/08/2023, 7:12 AM
Interesting idea🤩