rebugger icon indicating copy to clipboard operation
rebugger copied to clipboard

Feature Request : Custom Annotation + Compiler plugin

Open erawhctim opened this issue 2 years ago • 11 comments
trafficstars

It would be neat if Rebugger had a KSP artifact that processed annotations on compostable functions to automatically insert the necessary Rebugger function calls within the function body - is something like that even possible?

The annotation could have parameters to control what inputs are tracked by Rebugger (function arguments, state objects within the function body, or both)

erawhctim avatar Apr 02 '23 09:04 erawhctim

@erawhctim

image

This is something that I initially thought about. But thinking about the additional build time it can introduce, I prioritized developing an IDE plugin to generate the Rebugger call first. (See #1). Do you still think the annotation-processor would be better? If yes, would you explain a bit?

theapache64 avatar Apr 04 '23 12:04 theapache64

Thanks for the extra context! I do think a compiler plugin based approach is more convenient from a developer's perspective (IMO):

  • If the Rebugger calls are automatically generated by the compiler, the developer doesn't need to manually manage the trackMap parameters or remember to go back and add new ones
  • It's much faster to slap an annotation on a function than write up the Rebugger call manually (though, this sounds like the main motivation for the IDE plugin)
  • The build time impact is definitely a valid concern; I would hope that KSP would bring some performance gains over a kapt-based processor (but to be honest I would just measure the build time impact after building a PoC before deciding to ship it)

erawhctim avatar Apr 05 '23 13:04 erawhctim

I personally find that compiler plugins are more portable than IDE plugins (they still work if I'm building on the command line 🙂), but I realize that's just my own perspective.

Either way, I'd love to help/collab on this if you're looking for outside contributors! happy to take a stab at building a compiler plugin PoC

erawhctim avatar Apr 05 '23 13:04 erawhctim

@erawhctim

I personally find that compiler plugins are more portable than IDE plugins (they still work if I'm building on the command line 🙂), but I realize that's just my own perspective.

Fair request

I'd love to help/collab on this if you're looking for outside contributors! happy to take a stab at building a compiler plugin PoC

That'd be great! Let's discuss this. Sending you a DM in kotlinlang slack ✋

theapache64 avatar Apr 06 '23 03:04 theapache64

@theapache64 Hi. I already have similar compiler plugin. I can simply add a rebugger as an additional logging option. What you think about this?

EvgeniyKurinnoy avatar Apr 11 '23 07:04 EvgeniyKurinnoy

Great. Can you publish an MVP ?

theapache64 avatar May 02 '23 05:05 theapache64

@theapache64 Yes. I completed integration, I will let you know when it is merged and published.

https://user-images.githubusercontent.com/105854390/236830779-ebab6072-effb-4c84-b7ad-2d7715993092.mov

EvgeniyKurinnoy avatar May 08 '23 13:05 EvgeniyKurinnoy

Great stuff!!!

I will let you know when it is merged and published.

Sure!

theapache64 avatar May 08 '23 16:05 theapache64

@theapache64 Hi. Plugin with rebugger support has been published. The plugin adds a rebugger call to the beginning of the function and track every function argument. But it doesn't track state properties that was declared inside function. I would glad to hear any proposals or comments. I also would glad if you mention that plugin in Rebugger README :)

EvgeniyKurinnoy avatar May 10 '23 14:05 EvgeniyKurinnoy

@EvgeniyKurinnoy I tried using the plugin, but i don't see the useRebugger options or @Rebugger annotation anywhere. Am i missing something? image

theapache64 avatar May 14 '23 03:05 theapache64

@theapache64 useRebugger option available in module build.gradle Screenshot 2023-05-14 at 09 37 33

Additional annotations is not required, because plugin looks at the @Composable annotation

EvgeniyKurinnoy avatar May 14 '23 06:05 EvgeniyKurinnoy