Hey - so my team has been assigning threads to spe...
# arrow-meta
s
Hey - so my team has been assigning threads to specific classes. Currently we’ve been manually ensuring the contract that any public methods on these objects must be
suspend
, and also manually must ensure transfer to that thread - via a
withContext
method. I’d like to create a compiler plugin to do this for us by doing one of the following: 1. Change the visibility of the class, and create a wrapping class that ensure the transfer to the thread, and then defers to the delegated object / class 2. Alter the public function signature to something asynchronous, and wrap the body of the method to transfer to the proper thread. I’m new to compiler plugins. Can anyone point me in the right direction, or point me at any bumps in the road to accomplish this? Will I have to create a separate ide plugin to get syntax completion to work?
r
Meta is still in active development and you may find many hick ups but here is a few examples that may get you started https://github.com/arrow-kt/arrow-meta-examples
Check it out and if you get stuck feel free to swing by and ask any questions here 🙂
s
All I see there is the hello world example
r
same as
namedfunction
there is equivalent functions for all other elements of the kotlin tree
you can intercept any node you are interested and generate as many new declarations as you want or alter the tree declarations
That seems to be what you are after in your plugin, and hello world is the minimal example of that. It changes a function body based on its name
s
right
a
@spierce7 we're in the middle of a major refactor right now and I'm looking to add more detailed examples over time, but you're welcome to take a look at this: https://github.com/arrow-kt/arrow-meta/pull/202/files/92c7f3e99baee1b41faa148500eededc751aa226
To see what kinds of nodes are available rn