// File B
@DoWorkBasedOnParent
class Foo extends SomeTrait
// File C
case class DoWorkBasedOnParent extends ExtensionGenerator {
def extend(c: Defn.Class): List[Stat] = {
// Would have the structure of the given object
val parents: List[Defn] = c.semanticParents
// Resolve a Type.Name to a literal type
val tpe: Option[Tree] = c.type.resolve
}
}
This idea originally sprung from gitter, but this sort of solution could allow generation of data based on potentially uncontrollable sources. For example auto generating typeclass instances for all classes in the entire scalameta Trees.scala file, without touching the file itself.
This would allow cross file resolution.
This would work at the source level only.
The idea here is to allow
This idea originally sprung from gitter, but this sort of solution could allow generation of data based on potentially uncontrollable sources. For example auto generating typeclass instances for all classes in the entire scalameta Trees.scala file, without touching the file itself.