I am trying to create a macro annotation but I need to pass it parameters.
class ToPojo(param1: String, param2: String) extends StaticAnnotation {
inline def apply(defn: Any): Any = meta {
...
}
}
which is used as
@ToPojo("p1", "p2")
case class Entity(a: Int, m: Map[Long, Boolean])
The problem with above code is that the Entity
gets to the apply
as defn
already with the annotation stripped - hence I can not get the parameters from there. Also the param1
and param2
fields are not accessible from the apply
method since it gets inlined.
Could you please point me to the easiest way to overcome this using scala meta? I thought about using two annotations
@ToPojo
@ToPojoParams("p1", "p2")
case class Entity(a: Int, m: Map[Long, Boolean])
But thats hacky and ugly.
Thanks a lot