https://kotlinlang.org logo
#arrow
Title
# arrow
r

rcd27

07/21/2022, 10:51 AM
I have a goal to inject some code invocations in my functions calls. Something like http://github.com/jakewharton/hugo (compiler plugin + AspectJ bytecode weaving + Android Gradle Transform API). And I remember
Arrow
team was working on better-compiler-plugin-environment-writing for Kotlin. Should I check it out?
a

Alejandro Serrano Mena

07/21/2022, 12:29 PM
Arrow Meta may offer you a simpler way to do that, indeed
👍 1
j

Javier

07/21/2022, 7:17 PM
In Arrow Inject we want to add “interceptors” which can help with this too
r

rcd27

07/21/2022, 7:44 PM
@Javier is there a ticket for that task?
j

Javier

07/21/2022, 7:44 PM
No, we have a PR open for moving arrow inject to arrow proofs repo, but we haven't explored the interceptors feature yet
Well indeed the PR was merged
you can check the current state in the main branch
I recommend checking those tests to understand how it will work, but that is the basic DI part, nothing about interceptors https://github.com/arrow-kt/arrow-proofs/tree/main/arrow-inject-compiler-plugin/src/testData/box/context-receivers
❤️ 1
r

rcd27

07/22/2022, 5:20 AM
@Javier I've checked it out, looks good for injections like DI(at quick look). But I need a resulting code modification. Like adding analytics calls in generated code.
Copy code
@LogEvent(eventName="user_pressed_button)
fun onButtonPressed(){
    ...
}
And the generated code would be:
Copy code
fun onButtonPressed(){
...
sendAnalytics("user_pressed_button")
}
So it seems like
Meta
is my choice, what do you think @Javier
j

Javier

07/22/2022, 7:27 AM
At this moment yes, that kind of injection will be available in arrow inject too
5 Views