提交 6708f5e3 编写于 作者: 梦境迷离's avatar 梦境迷离

fix some

上级 dad7294f
......@@ -26,6 +26,7 @@ import io.github.dreamylost.logs.LogType.LogType
import scala.reflect.macros.whitebox
trait BaseLog {
val typ: LogType
def getTemplate(c: whitebox.Context)(logTransferArgument: LogTransferArgument): c.Tree
......
......@@ -54,7 +54,7 @@ object elapsedMacro {
}
private val extractArgumentsDetail: (Duration, LogLevel) = extractArgumentsTuple2 {
case q"new elapsed(limit=$limit, logLevel=$logLevel)" => (evalTree[Duration](limit.asInstanceOf[Tree]), getLogLevel(logLevel.asInstanceOf[Tree]))
case q"new elapsed(limit=$limit, logLevel=$logLevel)" => (evalTree(limit.asInstanceOf[Tree]), getLogLevel(logLevel.asInstanceOf[Tree]))
case _ => c.abort(c.enclosingPosition, ErrorMessage.UNEXPECTED_PATTERN)
}
......@@ -63,6 +63,7 @@ object elapsedMacro {
}
private def getLog(methodName: TermName, logBy: Tree): c.universe.Tree = {
// CI will fail when use lambda.
implicit val durationApply: c.universe.Liftable[Duration] = new Liftable[Duration] {
override def apply(value: Duration): c.universe.Tree = q"${value._1}"
}
......@@ -152,7 +153,7 @@ object elapsedMacro {
mapToNewMethod(defDef, defDef => {
q"""
$getStartExpr
${Try.apply(defDef.rhs, Nil, getPrintlnLog(defDef.name))}
${Try(defDef.rhs, Nil, getPrintlnLog(defDef.name))}
"""
})
}
......
......@@ -31,10 +31,10 @@ package object macros {
object ErrorMessage {
// common error msg
final lazy val ONLY_CLASS = "Annotation is only supported on class."
final lazy val ONLY_CASE_CLASS = "Annotation is only supported on case class."
final lazy val ONLY_OBJECT_CLASS = "Annotation is only supported on class or object."
final lazy val UNEXPECTED_PATTERN = "Unexpected annotation pattern!"
final lazy val ONLY_CLASS: String = "Annotation is only supported on class."
final lazy val ONLY_CASE_CLASS: String = "Annotation is only supported on case class."
final lazy val ONLY_OBJECT_CLASS: String = "Annotation is only supported on class or object."
final lazy val UNEXPECTED_PATTERN: String = "Unexpected annotation pattern!"
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册