cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 159 forks source link

Add beforeCompilationFinished to PrinterAdapter #726

Open jgfrm opened 1 year ago

jgfrm commented 1 year ago

It is useful to have a beforeCompilationFinished hook that is called just before the targer generated file is closed, e.g. the add additional code at the end of the generated file.

lgrignon commented 1 year ago

Hello @jgfrm Thanks for your suggestion.

I guess PrinterAdapter.onTranspilationFinished() does not fit your needs?

Please feel free to send a PR and we will merge it.

Bye

renaudpawlak commented 1 year ago

To complete Louis' answer... Inserting code at the end of transpilation is not that straightforward because the end of transpiling depends on how you choose to generate the code (with or without bundling for instance). I would advise to also look at the PrinterAdapter's afterType(TypeElement type) to insert code after a transpiled class has been generated.

IMO, all the required hooks should be available but might require some big dive into the inside transpiler's components. Please, read the doc and the code (interfaces) carefully before considering any serious changes ;)