https://kotlinlang.org logo
#arrow-meta
Title
# arrow-meta
d

dalexander

10/17/2020, 10:50 AM
I've been working on a compiler plugin using Arrow Meta and it's been smooth sailing so far, but I have a few additional questions: 1) Is it possible to tell what phase of compilation the plugin is hooking in to (mostly out of curiosity)? Information that might help is it's using quote syntax and hooking into class declarations, generating files. It looks like file generation is associated with analysis, is that correct? 2) How can I do some processing after all the classes that the plugin will activate on have been processed? I want to produce a couple of what would effectively be "summary" files based on the processed data classes. It seems like this might involve something like a "post-current-phase" hook but I can't find something like that in the documentation. 3) Are new generated files operated on by the compiler plugins / annotation processors? Would I need to do anything special to make that happen?
r

raulraja

10/17/2020, 8:27 PM
Hi Derek, 1. Yes that happens in the analysis phase. 2. You can do processing on análisis completed or if you are using IR in IrGeneration which will give you a module fragment with it's file info typecheched and ready for codegen. 3. If you are using Transform.newSources then other processors should pick it up at the same time you do on the rewind but there is no way to control order. Please report if you find anything odd so we can report it to the compiler team as use case.
d

dalexander

10/18/2020, 11:14 PM
Thanks for the answer-- So it sounds like I can accumulate a list of changes during the analysis phase, and write them out in a later phase? I think there's another way I can approach the issue too that's a bit simpler that I thought of after I asked the question. I'll probably try the simple one first to see if it works. I want to mention again that working on the plugin has been delightfully easy!
r

raulraja

10/19/2020, 8:00 AM
Thanks for the kind words Derek 😊. Regarding producing reports about analyzed code IR is the best place since the entire Module Fragment is type checked and analysed there and the IR tree contains all the programm properly tagged. Not sure what you are reporting or accumulating but I would do it in IR. Doing in analysisCompleted takes fiddling with the binding trace and context which is a bunch of descriptor like maps.