Hi, I’m trying to create a compiler plugin that would generate some additional classes for types with configured annotation. I’m not sure if there is any ProjectExtensionDescriptor that supports this - I’ve looked at ClassBuilderInterceptorExtension and ExpressionCodegenExtension. In ExpressionCodegenExtension there is generateClassSyntheticParts() method where I can access an instance of ImplementationBodyCodegen and invoke method genSyntheticClassOrObject(). Still I’m not sure how to construct SyntheticClassOrObjectDescriptor to use that method or if I will be able to inject my bytecode to that synthetic class and create regular methods. I will be grateful for any advices
If you only want to generate extra classes and not modify existing once and you only target kotlin jvm I suggest you take a look at annotation processing using kapt. It is far better documented (since it’s basically the kotlin equivalent to java’s annotation processor).
Another advantage of kapt is that you don’t have to generate bytecode, but you instead generate kotlin or java code that is then compiled. This allows you to use libraries like kotlinpoet which make generating complex classes much easier.
Otherwise I can’t really help. Compiler plugins don’t have any stable api and I don’t think there is documentation for it. AFAIK the best place to look for examples on how to use them are the places where they are used in official kotlin projects. I think the serialization library uses them to generate all the serializers.