def scalaEnumTypeMacro[T: c.WeakTypeTag]()

in shared/src/main/scala-2/magnolify/shared/EnumTypeMacros.scala [23:40]


  def scalaEnumTypeMacro[T: c.WeakTypeTag](
    c: whitebox.Context
  )(annotations: c.Expr[AnnotationType[T]]): c.Tree = {
    import c.universe._
    val wtt = weakTypeTag[T]
    val ref = wtt.tpe.asInstanceOf[TypeRef]
    val name = ref.pre.typeSymbol.asClass.fullName // find the enum type from the value type
    val idx = name.lastIndexOf('.')
    val n = name.drop(idx + 1)
    val ns = name.take(idx)
    val list = q"${ref.pre.termSymbol}.values.iterator.map(_.toString).toList"
    val map = q"${ref.pre.termSymbol}.values.iterator.map(x => x.toString -> x).toMap"
    q"""
        _root_.magnolify.shared.EnumType.create[$wtt](
          $n, $ns, $list, $annotations.annotations, $map.apply(_)
        )
     """
  }