Thanks for the reply, I was able to create a function macro as it maps Each field name can be used for the map of a square, such as
... attribute model case class user (name: string, age: IT, post: list [string]) extension of the model {Val num.posts: int = posts.length ... def foo = "bar" ...} then this command
Val myUser = User ("Foo", 25, list ("Laramum", "Epsom") myUser.asMap Ritter Map - " , "Number Post" -> 2)
This is where Tupal s is prepared for the map (Travis See brown):
... val pairs = weakTypeOf [T] Declarations.collect {case m: MethodSymbol if m.isAccessor = & gt; Val name = c.literal (m.name.decoded) val value = c.Expr (select (model, m.name)) (name.splice -> value.splice) .tree} ... Now I want to ignore areas that have @transient annotations. How do I check that there is a method @transient annotation?
I am thinking of modifying the snippet above
val pairs = weak typing [t] .declarations.collect {Case I: Method Symbol, M. Assessor & amp; ! M.annotations.exists (???) = & gt; Val name = c.literal (m.name.decoded) val value = c.Expr (select (model, m.name)) (name.splice -> value.splice) .tree} But I can not find that I need to write in the existing section @transient in a annotation How will I get it, so can I pass it there?
Thanks in advance!
On annotation val , not on the accelerator. The easiest way to access val is to accessed method on MethodSymbol
def isTransient ( M: MethodSymbol) = m.accessed.annotations.exists (_.tpe =: = typeOf [scala.transient]) Now you can write the following in your archive < / Code>:
Case I: Method Symbol, if M. Associate & amp; amp; ! Haitian (M) = & gt; Note that the version of the isTransient that you provided must be defined in your macro, as it needs to be imported from c.universe < / Code>, but if you are talking about this type in several macros, you can factor it by adding universe logic
No comments:
Post a Comment