@@ -40,30 +40,33 @@ object RWMacros {
4040 case m : MethodSymbol if m.isPrimaryConstructor => m.paramLists.head
4141 } match {
4242 case Some (fields) =>
43- val transientNames = fields.filter(_.annotations.exists(_.tree.tpe =:= typeOf[notSerialized])).map(_.asTerm.name.decodedName.toString).toSet
44- val fieldDefs = fields.zipWithIndex.filterNot { case (field, _) =>
45- transientNames.contains(field.asTerm.name.decodedName.toString)
46- }.map { case (field, index) =>
47- val name = field.asTerm.name
48- val key = name.decodedName.toString
49- val returnType = tpe.decl(name).typeSignature.asSeenFrom(tpe, tpe.typeSymbol.asClass)
50- val descAnn = field.annotations.find(_.tree.tpe =:= typeOf[description])
51- val baseDef =
52- if (defaults.contains(index)) {
53- q " implicitly[RW[ $returnType]].definition.opt "
54- } else {
55- q " implicitly[RW[ $returnType]].definition "
56- }
57- descAnn match {
58- case Some (ann) => ann.tree.children.tail.head match {
59- case l : LiteralApi =>
60- val text = l.value.value.toString
61- q " $key -> $baseDef.describe( $text) "
62- case _ => q " $key -> $baseDef"
43+ val transientNames = fields
44+ .filter(_.annotations.exists(_.tree.tpe =:= typeOf[notSerialized]))
45+ .map(_.asTerm.name.decodedName.toString)
46+ .toSet
47+ val fieldDefs = fields.zipWithIndex
48+ .filterNot { case (field, _) => transientNames.contains(field.asTerm.name.decodedName.toString) }
49+ .map { case (field, index) =>
50+ val name = field.asTerm.name
51+ val key = name.decodedName.toString
52+ val returnType = tpe.decl(name).typeSignature.asSeenFrom(tpe, tpe.typeSymbol.asClass)
53+ val descAnn = field.annotations.find(_.tree.tpe =:= typeOf[description])
54+ val baseDef =
55+ if (defaults.contains(index)) {
56+ q " implicitly[RW[ $returnType]].definition.opt "
57+ } else {
58+ q " implicitly[RW[ $returnType]].definition "
6359 }
64- case None => q " $key -> $baseDef"
60+ descAnn match {
61+ case Some (ann) => ann.tree.children.tail.head match {
62+ case l : LiteralApi =>
63+ val text = l.value.value.toString
64+ q " $key -> $baseDef.describe( $text) "
65+ case _ => q " $key -> $baseDef"
66+ }
67+ case None => q " $key -> $baseDef"
68+ }
6569 }
66- }
6770 val serializedDefs = serializedMembers(context)(tpe).map { info =>
6871 val key = info.jsonKey
6972 val returnType = info.returnType.asInstanceOf [Type ]
@@ -107,14 +110,19 @@ object RWMacros {
107110 case m : MethodSymbol if m.isPrimaryConstructor => m.paramLists.head
108111 } match {
109112 case Some (fields) =>
110- val transientNames = fields.filter(_.annotations.exists(_.tree.tpe =:= typeOf[notSerialized])).map(_.asTerm.name.decodedName.toString).toSet
111- val toMap : List [context.universe.Tree ] = fields.filterNot { field =>
112- transientNames.contains(field.asTerm.name.decodedName.toString)
113- }.map { field =>
114- val name = field.asTerm.name
115- val key = name.decodedName.toString
116- q " $key -> t. $name.json "
117- }
113+ val transientNames = fields
114+ .filter(_.annotations.exists(_.tree.tpe =:= typeOf[notSerialized]))
115+ .map(_.asTerm.name.decodedName.toString)
116+ .toSet
117+ val toMap : List [context.universe.Tree ] = fields
118+ .filterNot { field =>
119+ transientNames.contains(field.asTerm.name.decodedName.toString)
120+ }
121+ .map { field =>
122+ val name = field.asTerm.name
123+ val key = name.decodedName.toString
124+ q " $key -> t. $name.json "
125+ }
118126 val extraMap : List [context.universe.Tree ] = serializedMembers(context)(tpe).map { info =>
119127 val key = info.jsonKey
120128 val memberName = TermName (info.memberName)
0 commit comments