scalameta / scalagen

WIP - Scalameta powered code generation
Apache License 2.0
40 stars 5 forks source link

Manipulation, Runner unification and Test Suite overhaul #14

Closed DavidDudson closed 6 years ago

DavidDudson commented 6 years ago

DO NOT MERGE.

I broke some things....

Stopping for the day, updates tomorrow

DavidDudson commented 6 years ago

Ready for merge now

DavidDudson commented 6 years ago

Added companion behavior.

Instead of having a method

  def manipulate(clazz: Defn.Class, companion: Defn.Obj) 

to have the companion avaliable... Instead we just can call

clazz.companionObject

To find the companion for a given class/trait/type.

This is useful for both generator authors, and our backend.

DavidDudson commented 6 years ago

Just added Companion and transmutation generators.

All that's left is input parameters on the annotations and we have more functionality than scalameta/paradise.

It's a little fragile for my liking due to restrictions of scalameta at present.

Next up I will need to create the SBT plugin

DavidDudson commented 6 years ago

@xeno-by You might want to have a look. Any suggestions welcome.

Considering the pain that we went through with desugaring etc. This has been relatively tiny and painless soo far.

DavidDudson commented 6 years ago

It would be helpful to add // Optimization: ... comments where applicable. I would be careful about too eager optimizations, since the performance bottleneck is likely to origin from an unexpected place.

There's only 2 optimizations.

  1. Disabling recursion by default
  2. Caching generator strings.
    • This is to prevent repeated traversal of the Generator list searching for an appropriate annotation.

I want to split this class into a few subfiles. So I will do that before merge. I also want to change the namespace to scala.meta.gen if possible while I am at it.

DavidDudson commented 6 years ago

I'm going to push this, even though it is not production ready. It's going to get increasingly hard to review and this patchset is already large enough. I'm going to change Runner again soon and change the tree traversal slightly. We should be able to get rid of mutability.