scalameta / scalagen

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

Replace[A, B] based generator methods #35

Open DavidDudson opened 6 years ago

DavidDudson commented 6 years ago

This is one that I believe will be useful for a lot of situations.

This is similar to the scalameta/paradise, by being fairly generic, however, instead of having to pattern match we target owners of specific data in tree subclasses.

object ProfileAll extends ManipulationGenerator("ProfileAll") {
  def extend(a: A: StatReplacer): A = 
    a.withStats(a.extract[Stat].map(somefunction))
}

This could be used in the situation below (useless example, but you get the idea)

Before

@ProfileAll
object Foo {
 def bar = 2
 def baz = 4
 val ban = "foo"
}
@ProfileAll
object Foo {
 def bar = time(2)
 def baz = time(4)
 val ban = time("foo")
}
DavidDudson commented 6 years ago

Blocked by #44