Is it possible to manipulate kotlin classes using compiler-plugin?


#1

I want to change my Kotlin classes at compile time process. For example, adding Logger.log() in every method of my Activities or write something like All-open compiler plugin.

In Java world, we can use bytecode weaving techniques for these kinds of stuff, but I don’t know it’s possible with compiler plugin or not?


#2

I guess you have searched for existing projects on the internet, so you found eg. this: https://github.com/Takhion/sample-kotlin-compiler-plugin

Just a sidenote, the Xtend language has a very nice feature called Active Annotations: https://www.eclipse.org/xtend/documentation/204_activeannotations.html
If Kotlin would have such simple, integrated and developer-friendly compiler extension mechanism, it would be the perfect language for many-many code-generation and -modification tasks, much better than (K)APT…


#3

I already saw this sample, but I don’t know how I can manipulate .kt classes