mirror of https://github.com/sbt/sbt.git
Migrate to blackbox.Context
This commit is contained in:
parent
e177ba75d6
commit
2f84e05282
|
|
@ -8,7 +8,7 @@ import sbt.internal.util.complete.Parser
|
||||||
import sbt.internal.util.appmacro.{ Convert, Converted }
|
import sbt.internal.util.appmacro.{ Convert, Converted }
|
||||||
|
|
||||||
object InputInitConvert extends Convert {
|
object InputInitConvert extends Convert {
|
||||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type] =
|
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
|
||||||
nme match {
|
nme match {
|
||||||
case InputWrapper.WrapInitName => Converted.Success(in)
|
case InputWrapper.WrapInitName => Converted.Success(in)
|
||||||
case InputWrapper.WrapInitTaskName => Converted.Failure(in.pos, initTaskErrorMessage)
|
case InputWrapper.WrapInitTaskName => Converted.Failure(in.pos, initTaskErrorMessage)
|
||||||
|
|
@ -20,7 +20,7 @@ object InputInitConvert extends Convert {
|
||||||
|
|
||||||
/** Converts an input `Tree` of type `Parser[T]` or `State => Parser[T]` into a `Tree` of type `State => Parser[T]`.*/
|
/** Converts an input `Tree` of type `Parser[T]` or `State => Parser[T]` into a `Tree` of type `State => Parser[T]`.*/
|
||||||
object ParserConvert extends Convert {
|
object ParserConvert extends Convert {
|
||||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type] =
|
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
|
||||||
nme match {
|
nme match {
|
||||||
case ParserInput.WrapName => Converted.Success(in)
|
case ParserInput.WrapName => Converted.Success(in)
|
||||||
case ParserInput.WrapInitName => Converted.Failure(in.pos, initParserErrorMessage)
|
case ParserInput.WrapInitName => Converted.Failure(in.pos, initParserErrorMessage)
|
||||||
|
|
@ -32,14 +32,14 @@ object ParserConvert extends Convert {
|
||||||
|
|
||||||
/** Convert instance for plain `Task`s not within the settings system. */
|
/** Convert instance for plain `Task`s not within the settings system. */
|
||||||
object TaskConvert extends Convert {
|
object TaskConvert extends Convert {
|
||||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type] =
|
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
|
||||||
if (nme == InputWrapper.WrapTaskName) Converted.Success(in) else Converted.NotApplicable
|
if (nme == InputWrapper.WrapTaskName) Converted.Success(in) else Converted.NotApplicable
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts an input `Tree` of type `Initialize[T]`, `Initialize[Task[T]]`, or `Task[T]` into a `Tree` of type `Initialize[Task[T]]`.*/
|
/** Converts an input `Tree` of type `Initialize[T]`, `Initialize[Task[T]]`, or `Task[T]` into a `Tree` of type `Initialize[Task[T]]`.*/
|
||||||
object FullConvert extends Convert {
|
object FullConvert extends Convert {
|
||||||
import InputWrapper._
|
import InputWrapper._
|
||||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type] =
|
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
|
||||||
nme match {
|
nme match {
|
||||||
case WrapInitTaskName => Converted.Success(in)
|
case WrapInitTaskName => Converted.Success(in)
|
||||||
case WrapPreviousName => Converted.Success(in)
|
case WrapPreviousName => Converted.Success(in)
|
||||||
|
|
@ -48,13 +48,13 @@ object FullConvert extends Convert {
|
||||||
case _ => Converted.NotApplicable
|
case _ => Converted.NotApplicable
|
||||||
}
|
}
|
||||||
|
|
||||||
private def wrapInit[T](c: Context)(tree: c.Tree): Converted[c.type] = {
|
private def wrapInit[T](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||||
val i = c.Expr[Initialize[T]](tree)
|
val i = c.Expr[Initialize[T]](tree)
|
||||||
val t = c.universe.reify(Def.toITask(i.splice)).tree
|
val t = c.universe.reify(Def.toITask(i.splice)).tree
|
||||||
Converted.Success(t)
|
Converted.Success(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def wrapTask[T](c: Context)(tree: c.Tree): Converted[c.type] = {
|
private def wrapTask[T](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||||
val i = c.Expr[Task[T]](tree)
|
val i = c.Expr[Task[T]](tree)
|
||||||
val t = c.universe.reify(Def.valueStrict[Task[T]](i.splice)).tree
|
val t = c.universe.reify(Def.valueStrict[Task[T]](i.splice)).tree
|
||||||
Converted.Success(t)
|
Converted.Success(t)
|
||||||
|
|
@ -66,14 +66,14 @@ object FullConvert extends Convert {
|
||||||
* into a `Tree` of type `Initialize[State => Parser[T]]`.
|
* into a `Tree` of type `Initialize[State => Parser[T]]`.
|
||||||
*/
|
*/
|
||||||
object InitParserConvert extends Convert {
|
object InitParserConvert extends Convert {
|
||||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type] =
|
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
|
||||||
nme match {
|
nme match {
|
||||||
case ParserInput.WrapName => wrap[T](c)(in)
|
case ParserInput.WrapName => wrap[T](c)(in)
|
||||||
case ParserInput.WrapInitName => Converted.Success(in)
|
case ParserInput.WrapInitName => Converted.Success(in)
|
||||||
case _ => Converted.NotApplicable
|
case _ => Converted.NotApplicable
|
||||||
}
|
}
|
||||||
|
|
||||||
private def wrap[T](c: Context)(tree: c.Tree): Converted[c.type] = {
|
private def wrap[T](c: blackbox.Context)(tree: c.Tree): Converted[c.type] = {
|
||||||
val e = c.Expr[State => Parser[T]](tree)
|
val e = c.Expr[State => Parser[T]](tree)
|
||||||
val t = c.universe.reify { Def.valueStrict[State => Parser[T]](e.splice) }
|
val t = c.universe.reify { Def.valueStrict[State => Parser[T]](e.splice) }
|
||||||
Converted.Success(t.tree)
|
Converted.Success(t.tree)
|
||||||
|
|
|
||||||
|
|
@ -42,19 +42,19 @@ object InputWrapper {
|
||||||
|
|
||||||
private[this] def implDetailError = sys.error("This method is an implementation detail and should not be referenced.")
|
private[this] def implDetailError = sys.error("This method is an implementation detail and should not be referenced.")
|
||||||
|
|
||||||
private[std] def wrapTask[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
private[std] def wrapTask[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
||||||
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapTaskName)(ts, pos)
|
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapTaskName)(ts, pos)
|
||||||
private[std] def wrapInit[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
private[std] def wrapInit[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
||||||
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitName)(ts, pos)
|
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitName)(ts, pos)
|
||||||
private[std] def wrapInitTask[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
private[std] def wrapInitTask[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
||||||
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitTaskName)(ts, pos)
|
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitTaskName)(ts, pos)
|
||||||
|
|
||||||
private[std] def wrapInitInputTask[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
private[std] def wrapInitInputTask[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
||||||
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitInputName)(ts, pos)
|
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitInputName)(ts, pos)
|
||||||
private[std] def wrapInputTask[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
private[std] def wrapInputTask[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
||||||
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInputName)(ts, pos)
|
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInputName)(ts, pos)
|
||||||
|
|
||||||
private[std] def wrapPrevious[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[Option[T]] =
|
private[std] def wrapPrevious[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[Option[T]] =
|
||||||
wrapImpl[Option[T], InputWrapper.type](c, InputWrapper, WrapPreviousName)(ts, pos)
|
wrapImpl[Option[T], InputWrapper.type](c, InputWrapper, WrapPreviousName)(ts, pos)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,7 +63,7 @@ object InputWrapper {
|
||||||
*
|
*
|
||||||
* `c.universe.reify { <s>.<wrapName>[T](ts.splice) }`
|
* `c.universe.reify { <s>.<wrapName>[T](ts.splice) }`
|
||||||
*/
|
*/
|
||||||
def wrapImpl[T: c.WeakTypeTag, S <: AnyRef with Singleton](c: Context, s: S, wrapName: String)(ts: c.Expr[Any], pos: c.Position)(implicit it: c.TypeTag[s.type]): c.Expr[T] =
|
def wrapImpl[T: c.WeakTypeTag, S <: AnyRef with Singleton](c: blackbox.Context, s: S, wrapName: String)(ts: c.Expr[Any], pos: c.Position)(implicit it: c.TypeTag[s.type]): c.Expr[T] =
|
||||||
{
|
{
|
||||||
import c.universe.{ Apply => ApplyTree, _ }
|
import c.universe.{ Apply => ApplyTree, _ }
|
||||||
import internal.decorators._
|
import internal.decorators._
|
||||||
|
|
@ -87,7 +87,7 @@ object InputWrapper {
|
||||||
c.Expr[T](typedTree)
|
c.Expr[T](typedTree)
|
||||||
}
|
}
|
||||||
|
|
||||||
def valueMacroImpl[T: c.WeakTypeTag](c: Context): c.Expr[T] =
|
def valueMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[T] =
|
||||||
ContextUtil.selectMacroImpl[T](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[T](c) { (ts, pos) =>
|
||||||
ts.tree.tpe match {
|
ts.tree.tpe match {
|
||||||
case tpe if tpe <:< c.weakTypeOf[Initialize[T]] =>
|
case tpe if tpe <:< c.weakTypeOf[Initialize[T]] =>
|
||||||
|
|
@ -103,11 +103,11 @@ object InputWrapper {
|
||||||
case tpe => unexpectedType(c)(pos, tpe)
|
case tpe => unexpectedType(c)(pos, tpe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def inputTaskValueMacroImpl[T: c.WeakTypeTag](c: Context): c.Expr[InputTask[T]] =
|
def inputTaskValueMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[InputTask[T]] =
|
||||||
ContextUtil.selectMacroImpl[InputTask[T]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[InputTask[T]](c) { (ts, pos) =>
|
||||||
InputWrapper.wrapInit[InputTask[T]](c)(ts, pos)
|
InputWrapper.wrapInit[InputTask[T]](c)(ts, pos)
|
||||||
}
|
}
|
||||||
def taskValueMacroImpl[T: c.WeakTypeTag](c: Context): c.Expr[Task[T]] =
|
def taskValueMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[Task[T]] =
|
||||||
ContextUtil.selectMacroImpl[Task[T]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[Task[T]](c) { (ts, pos) =>
|
||||||
val tpe = ts.tree.tpe
|
val tpe = ts.tree.tpe
|
||||||
if (tpe <:< c.weakTypeOf[Initialize[Task[T]]])
|
if (tpe <:< c.weakTypeOf[Initialize[Task[T]]])
|
||||||
|
|
@ -116,7 +116,7 @@ object InputWrapper {
|
||||||
unexpectedType(c)(pos, tpe)
|
unexpectedType(c)(pos, tpe)
|
||||||
}
|
}
|
||||||
/** Translates <task: TaskKey[T]>.previous(format) to Previous.runtime(<task>)(format).value*/
|
/** Translates <task: TaskKey[T]>.previous(format) to Previous.runtime(<task>)(format).value*/
|
||||||
def previousMacroImpl[T: c.WeakTypeTag](c: Context)(format: c.Expr[sbinary.Format[T]]): c.Expr[Option[T]] =
|
def previousMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(format: c.Expr[sbinary.Format[T]]): c.Expr[Option[T]] =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
c.macroApplication match {
|
c.macroApplication match {
|
||||||
|
|
@ -131,7 +131,7 @@ object InputWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def unexpectedType(c: Context)(pos: c.Position, tpe: c.Type) =
|
private def unexpectedType(c: blackbox.Context)(pos: c.Position, tpe: c.Type) =
|
||||||
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.widen}")
|
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.widen}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,14 +176,14 @@ object ParserInput {
|
||||||
@compileTimeOnly("`parsed` can only be used within an input task macro, such as := or Def.inputTask.")
|
@compileTimeOnly("`parsed` can only be used within an input task macro, such as := or Def.inputTask.")
|
||||||
def initParser_\u2603\u2603[T](i: Any): T = sys.error("This method is an implementation detail and should not be referenced.")
|
def initParser_\u2603\u2603[T](i: Any): T = sys.error("This method is an implementation detail and should not be referenced.")
|
||||||
|
|
||||||
private[std] def wrap[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
private[std] def wrap[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
||||||
InputWrapper.wrapImpl[T, ParserInput.type](c, ParserInput, WrapName)(ts, pos)
|
InputWrapper.wrapImpl[T, ParserInput.type](c, ParserInput, WrapName)(ts, pos)
|
||||||
private[std] def wrapInit[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
private[std] def wrapInit[T: c.WeakTypeTag](c: blackbox.Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
|
||||||
InputWrapper.wrapImpl[T, ParserInput.type](c, ParserInput, WrapInitName)(ts, pos)
|
InputWrapper.wrapImpl[T, ParserInput.type](c, ParserInput, WrapInitName)(ts, pos)
|
||||||
|
|
||||||
private[std] def inputParser[T: c.WeakTypeTag](c: Context)(t: c.Expr[InputTask[T]]): c.Expr[State => Parser[Task[T]]] = c.universe.reify(t.splice.parser)
|
private[std] def inputParser[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[InputTask[T]]): c.Expr[State => Parser[Task[T]]] = c.universe.reify(t.splice.parser)
|
||||||
|
|
||||||
def parsedInputMacroImpl[T: c.WeakTypeTag](c: Context): c.Expr[Task[T]] =
|
def parsedInputMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[Task[T]] =
|
||||||
ContextUtil.selectMacroImpl[Task[T]](c) { (p, pos) =>
|
ContextUtil.selectMacroImpl[Task[T]](c) { (p, pos) =>
|
||||||
p.tree.tpe match {
|
p.tree.tpe match {
|
||||||
case tpe if tpe <:< c.weakTypeOf[InputTask[T]] => wrapInputTask[T](c)(p.tree, pos)
|
case tpe if tpe <:< c.weakTypeOf[InputTask[T]] => wrapInputTask[T](c)(p.tree, pos)
|
||||||
|
|
@ -192,18 +192,18 @@ object ParserInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def wrapInputTask[T: c.WeakTypeTag](c: Context)(tree: c.Tree, pos: c.Position) = {
|
private def wrapInputTask[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
|
||||||
val e = c.Expr[InputTask[T]](tree)
|
val e = c.Expr[InputTask[T]](tree)
|
||||||
wrap[Task[T]](c)(inputParser(c)(e), pos)
|
wrap[Task[T]](c)(inputParser(c)(e), pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def wrapInitInputTask[T: c.WeakTypeTag](c: Context)(tree: c.Tree, pos: c.Position) = {
|
private def wrapInitInputTask[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
|
||||||
val e = c.Expr[Initialize[InputTask[T]]](tree)
|
val e = c.Expr[Initialize[InputTask[T]]](tree)
|
||||||
wrapInit[Task[T]](c)(c.universe.reify {Def.toIParser(e.splice)}, pos)
|
wrapInit[Task[T]](c)(c.universe.reify {Def.toIParser(e.splice)}, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Implements `Parser[T].parsed` by wrapping the Parser with the ParserInput wrapper.*/
|
/** Implements `Parser[T].parsed` by wrapping the Parser with the ParserInput wrapper.*/
|
||||||
def parsedMacroImpl[T: c.WeakTypeTag](c: Context): c.Expr[T] =
|
def parsedMacroImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[T] =
|
||||||
ContextUtil.selectMacroImpl[T](c) { (p, pos) =>
|
ContextUtil.selectMacroImpl[T](c) { (p, pos) =>
|
||||||
p.tree.tpe match {
|
p.tree.tpe match {
|
||||||
case tpe if tpe <:< c.weakTypeOf[Parser[T]] => wrapParser[T](c)(p.tree, pos)
|
case tpe if tpe <:< c.weakTypeOf[Parser[T]] => wrapParser[T](c)(p.tree, pos)
|
||||||
|
|
@ -214,17 +214,17 @@ object ParserInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def wrapParser[T: c.WeakTypeTag](c: Context)(tree: c.Tree, pos: c.Position) = {
|
private def wrapParser[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
|
||||||
val e = c.Expr[Parser[T]](tree)
|
val e = c.Expr[Parser[T]](tree)
|
||||||
wrap[T](c)(c.universe.reify {Def.toSParser(e.splice)}, pos)
|
wrap[T](c)(c.universe.reify {Def.toSParser(e.splice)}, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def wrapInitParser[T: c.WeakTypeTag](c: Context)(tree: c.Tree, pos: c.Position) = {
|
private def wrapInitParser[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
|
||||||
val e = c.Expr[Initialize[Parser[T]]](tree)
|
val e = c.Expr[Initialize[Parser[T]]](tree)
|
||||||
val es = c.universe.reify {Def.toISParser(e.splice)}
|
val es = c.universe.reify {Def.toISParser(e.splice)}
|
||||||
wrapInit[T](c)(es, pos)
|
wrapInit[T](c)(es, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def unexpectedType(c: Context)(pos: c.Position, tpe: c.Type, label: String) =
|
private def unexpectedType(c: blackbox.Context)(pos: c.Position, tpe: c.Type, label: String) =
|
||||||
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.dealias} in $label.")
|
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.dealias} in $label.")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,20 @@ package std
|
||||||
import reflect.macros._
|
import reflect.macros._
|
||||||
|
|
||||||
private[sbt] object KeyMacro {
|
private[sbt] object KeyMacro {
|
||||||
def settingKeyImpl[T: c.WeakTypeTag](c: Context)(description: c.Expr[String]): c.Expr[SettingKey[T]] =
|
def settingKeyImpl[T: c.WeakTypeTag](c: blackbox.Context)(description: c.Expr[String]): c.Expr[SettingKey[T]] =
|
||||||
keyImpl[T, SettingKey[T]](c) { (name, mf) =>
|
keyImpl[T, SettingKey[T]](c) { (name, mf) =>
|
||||||
c.universe.reify { SettingKey[T](name.splice, description.splice)(mf.splice) }
|
c.universe.reify { SettingKey[T](name.splice, description.splice)(mf.splice) }
|
||||||
}
|
}
|
||||||
def taskKeyImpl[T: c.WeakTypeTag](c: Context)(description: c.Expr[String]): c.Expr[TaskKey[T]] =
|
def taskKeyImpl[T: c.WeakTypeTag](c: blackbox.Context)(description: c.Expr[String]): c.Expr[TaskKey[T]] =
|
||||||
keyImpl[T, TaskKey[T]](c) { (name, mf) =>
|
keyImpl[T, TaskKey[T]](c) { (name, mf) =>
|
||||||
c.universe.reify { TaskKey[T](name.splice, description.splice)(mf.splice) }
|
c.universe.reify { TaskKey[T](name.splice, description.splice)(mf.splice) }
|
||||||
}
|
}
|
||||||
def inputKeyImpl[T: c.WeakTypeTag](c: Context)(description: c.Expr[String]): c.Expr[InputKey[T]] =
|
def inputKeyImpl[T: c.WeakTypeTag](c: blackbox.Context)(description: c.Expr[String]): c.Expr[InputKey[T]] =
|
||||||
keyImpl[T, InputKey[T]](c) { (name, mf) =>
|
keyImpl[T, InputKey[T]](c) { (name, mf) =>
|
||||||
c.universe.reify { InputKey[T](name.splice, description.splice)(mf.splice) }
|
c.universe.reify { InputKey[T](name.splice, description.splice)(mf.splice) }
|
||||||
}
|
}
|
||||||
|
|
||||||
def keyImpl[T: c.WeakTypeTag, S: c.WeakTypeTag](c: Context)(f: (c.Expr[String], c.Expr[Manifest[T]]) => c.Expr[S]): c.Expr[S] =
|
def keyImpl[T: c.WeakTypeTag, S: c.WeakTypeTag](c: blackbox.Context)(f: (c.Expr[String], c.Expr[Manifest[T]]) => c.Expr[S]): c.Expr[S] =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
val enclosingValName = definingValName(c, methodName => s"""$methodName must be directly assigned to a val, such as `val x = $methodName[Int]("description")`.""")
|
val enclosingValName = definingValName(c, methodName => s"""$methodName must be directly assigned to a val, such as `val x = $methodName[Int]("description")`.""")
|
||||||
|
|
@ -25,7 +25,7 @@ private[sbt] object KeyMacro {
|
||||||
val mf = c.Expr[Manifest[T]](c.inferImplicitValue(weakTypeOf[Manifest[T]]))
|
val mf = c.Expr[Manifest[T]](c.inferImplicitValue(weakTypeOf[Manifest[T]]))
|
||||||
f(name, mf)
|
f(name, mf)
|
||||||
}
|
}
|
||||||
def definingValName(c: Context, invalidEnclosingTree: String => String): String =
|
def definingValName(c: blackbox.Context, invalidEnclosingTree: String => String): String =
|
||||||
{
|
{
|
||||||
import c.universe.{ Apply => ApplyTree, _ }
|
import c.universe.{ Apply => ApplyTree, _ }
|
||||||
val methodName = c.macroApplication.symbol.name
|
val methodName = c.macroApplication.symbol.name
|
||||||
|
|
@ -44,6 +44,6 @@ private[sbt] object KeyMacro {
|
||||||
}
|
}
|
||||||
enclosingVal(enclosingTrees(c).toList)
|
enclosingVal(enclosingTrees(c).toList)
|
||||||
}
|
}
|
||||||
def enclosingTrees(c: Context): Seq[c.Tree] =
|
def enclosingTrees(c: blackbox.Context): Seq[c.Tree] =
|
||||||
c.asInstanceOf[reflect.macros.runtime.Context].callsiteTyper.context.enclosingContextChain.map(_.tree.asInstanceOf[c.Tree])
|
c.asInstanceOf[reflect.macros.runtime.Context].callsiteTyper.context.enclosingContextChain.map(_.tree.asInstanceOf[c.Tree])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ object InitializeInstance extends MonadInstance {
|
||||||
import reflect.macros._
|
import reflect.macros._
|
||||||
|
|
||||||
object InitializeConvert extends Convert {
|
object InitializeConvert extends Convert {
|
||||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type] =
|
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type] =
|
||||||
nme match {
|
nme match {
|
||||||
case InputWrapper.WrapInitName => convert[T](c)(in)
|
case InputWrapper.WrapInitName => convert[T](c)(in)
|
||||||
case InputWrapper.WrapTaskName | InputWrapper.WrapInitTaskName => failTask[c.type](c)(in.pos)
|
case InputWrapper.WrapTaskName | InputWrapper.WrapInitTaskName => failTask[c.type](c)(in.pos)
|
||||||
|
|
@ -25,23 +25,23 @@ object InitializeConvert extends Convert {
|
||||||
case _ => Converted.NotApplicable
|
case _ => Converted.NotApplicable
|
||||||
}
|
}
|
||||||
|
|
||||||
private def convert[T](c: Context)(in: c.Tree): Converted[c.type] =
|
private def convert[T](c: blackbox.Context)(in: c.Tree): Converted[c.type] =
|
||||||
{
|
{
|
||||||
val i = c.Expr[Initialize[T]](in)
|
val i = c.Expr[Initialize[T]](in)
|
||||||
val t = c.universe.reify(i.splice).tree
|
val t = c.universe.reify(i.splice).tree
|
||||||
Converted.Success(t)
|
Converted.Success(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def failTask[C <: Context with Singleton](c: C)(pos: c.Position): Converted[c.type] =
|
private def failTask[C <: blackbox.Context with Singleton](c: C)(pos: c.Position): Converted[c.type] =
|
||||||
Converted.Failure(pos, "A setting cannot depend on a task")
|
Converted.Failure(pos, "A setting cannot depend on a task")
|
||||||
private def failPrevious[C <: Context with Singleton](c: C)(pos: c.Position): Converted[c.type] =
|
private def failPrevious[C <: blackbox.Context with Singleton](c: C)(pos: c.Position): Converted[c.type] =
|
||||||
Converted.Failure(pos, "A setting cannot depend on a task's previous value.")
|
Converted.Failure(pos, "A setting cannot depend on a task's previous value.")
|
||||||
}
|
}
|
||||||
|
|
||||||
object SettingMacro {
|
object SettingMacro {
|
||||||
def settingMacroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[Initialize[T]] =
|
def settingMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[T]): c.Expr[Initialize[T]] =
|
||||||
Instance.contImpl[T, Id](c, InitializeInstance, InitializeConvert, MixedBuilder)(Left(t), Instance.idTransform[c.type])
|
Instance.contImpl[T, Id](c, InitializeInstance, InitializeConvert, MixedBuilder)(Left(t), Instance.idTransform[c.type])
|
||||||
|
|
||||||
def settingDynMacroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[Initialize[T]]): c.Expr[Initialize[T]] =
|
def settingDynMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[Initialize[T]]): c.Expr[Initialize[T]] =
|
||||||
Instance.contImpl[T, Id](c, InitializeInstance, InitializeConvert, MixedBuilder)(Right(t), Instance.idTransform[c.type])
|
Instance.contImpl[T, Id](c, InitializeInstance, InitializeConvert, MixedBuilder)(Right(t), Instance.idTransform[c.type])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,21 +80,21 @@ object TaskMacro {
|
||||||
|by wrapping the expression in parenthesis, and calling `.value` at the end.
|
|by wrapping the expression in parenthesis, and calling `.value` at the end.
|
||||||
|For example, `key := (key.dependsOn(compile in Test)).value`.""".stripMargin
|
|For example, `key := (key.dependsOn(compile in Test)).value`.""".stripMargin
|
||||||
|
|
||||||
def taskMacroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[Initialize[Task[T]]] =
|
def taskMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[T]): c.Expr[Initialize[Task[T]]] =
|
||||||
Instance.contImpl[T, Id](c, FullInstance, FullConvert, MixedBuilder)(Left(t), Instance.idTransform[c.type])
|
Instance.contImpl[T, Id](c, FullInstance, FullConvert, MixedBuilder)(Left(t), Instance.idTransform[c.type])
|
||||||
|
|
||||||
def taskDynMacroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[Initialize[Task[T]]]): c.Expr[Initialize[Task[T]]] =
|
def taskDynMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[Initialize[Task[T]]]): c.Expr[Initialize[Task[T]]] =
|
||||||
Instance.contImpl[T, Id](c, FullInstance, FullConvert, MixedBuilder)(Right(t), Instance.idTransform[c.type])
|
Instance.contImpl[T, Id](c, FullInstance, FullConvert, MixedBuilder)(Right(t), Instance.idTransform[c.type])
|
||||||
|
|
||||||
/** Implementation of := macro for settings. */
|
/** Implementation of := macro for settings. */
|
||||||
def settingAssignMacroImpl[T: c.WeakTypeTag](c: Context)(v: c.Expr[T]): c.Expr[Setting[T]] =
|
def settingAssignMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[T]): c.Expr[Setting[T]] =
|
||||||
{
|
{
|
||||||
val init = SettingMacro.settingMacroImpl[T](c)(v)
|
val init = SettingMacro.settingMacroImpl[T](c)(v)
|
||||||
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
||||||
c.Expr[Setting[T]](assign)
|
c.Expr[Setting[T]](assign)
|
||||||
}
|
}
|
||||||
/** Implementation of := macro for tasks. */
|
/** Implementation of := macro for tasks. */
|
||||||
def taskAssignMacroImpl[T: c.WeakTypeTag](c: Context)(v: c.Expr[T]): c.Expr[Setting[Task[T]]] =
|
def taskAssignMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[T]): c.Expr[Setting[Task[T]]] =
|
||||||
{
|
{
|
||||||
val init = taskMacroImpl[T](c)(v)
|
val init = taskMacroImpl[T](c)(v)
|
||||||
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
||||||
|
|
@ -104,80 +104,80 @@ object TaskMacro {
|
||||||
// Error macros (Restligeist)
|
// Error macros (Restligeist)
|
||||||
// These macros are there just so we can fail old operators like `<<=` and provide useful migration information.
|
// These macros are there just so we can fail old operators like `<<=` and provide useful migration information.
|
||||||
|
|
||||||
def fakeSettingAssignPosition[T: c.WeakTypeTag](c: Context)(app: c.Expr[Initialize[T]]): c.Expr[Setting[T]] =
|
def fakeSettingAssignPosition[T: c.WeakTypeTag](c: blackbox.Context)(app: c.Expr[Initialize[T]]): c.Expr[Setting[T]] =
|
||||||
ContextUtil.selectMacroImpl[Setting[T]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[Setting[T]](c) { (ts, pos) =>
|
||||||
c.abort(pos, assignMigration)
|
c.abort(pos, assignMigration)
|
||||||
}
|
}
|
||||||
def fakeSettingAppend1Position[S: c.WeakTypeTag, V: c.WeakTypeTag](c: Context)(v: c.Expr[Initialize[V]])(a: c.Expr[Append.Value[S, V]]): c.Expr[Setting[S]] =
|
def fakeSettingAppend1Position[S: c.WeakTypeTag, V: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[Initialize[V]])(a: c.Expr[Append.Value[S, V]]): c.Expr[Setting[S]] =
|
||||||
ContextUtil.selectMacroImpl[Setting[S]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[Setting[S]](c) { (ts, pos) =>
|
||||||
c.abort(pos, append1Migration)
|
c.abort(pos, append1Migration)
|
||||||
}
|
}
|
||||||
def fakeSettingAppendNPosition[S: c.WeakTypeTag, V: c.WeakTypeTag](c: Context)(vs: c.Expr[Initialize[V]])(a: c.Expr[Append.Values[S, V]]): c.Expr[Setting[S]] =
|
def fakeSettingAppendNPosition[S: c.WeakTypeTag, V: c.WeakTypeTag](c: blackbox.Context)(vs: c.Expr[Initialize[V]])(a: c.Expr[Append.Values[S, V]]): c.Expr[Setting[S]] =
|
||||||
ContextUtil.selectMacroImpl[Setting[S]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[Setting[S]](c) { (ts, pos) =>
|
||||||
c.abort(pos, appendNMigration)
|
c.abort(pos, appendNMigration)
|
||||||
}
|
}
|
||||||
def fakeItaskAssignPosition[T: c.WeakTypeTag](c: Context)(app: c.Expr[Initialize[Task[T]]]): c.Expr[Setting[Task[T]]] =
|
def fakeItaskAssignPosition[T: c.WeakTypeTag](c: blackbox.Context)(app: c.Expr[Initialize[Task[T]]]): c.Expr[Setting[Task[T]]] =
|
||||||
ContextUtil.selectMacroImpl[Setting[Task[T]]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[Setting[Task[T]]](c) { (ts, pos) =>
|
||||||
c.abort(pos, assignMigration)
|
c.abort(pos, assignMigration)
|
||||||
}
|
}
|
||||||
def fakeTaskAppend1Position[S: c.WeakTypeTag, V: c.WeakTypeTag](c: Context)(v: c.Expr[Initialize[Task[V]]])(a: c.Expr[Append.Value[S, V]]): c.Expr[Setting[Task[S]]] =
|
def fakeTaskAppend1Position[S: c.WeakTypeTag, V: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[Initialize[Task[V]]])(a: c.Expr[Append.Value[S, V]]): c.Expr[Setting[Task[S]]] =
|
||||||
ContextUtil.selectMacroImpl[Setting[Task[S]]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[Setting[Task[S]]](c) { (ts, pos) =>
|
||||||
c.abort(pos, append1Migration)
|
c.abort(pos, append1Migration)
|
||||||
}
|
}
|
||||||
def fakeTaskAppendNPosition[S: c.WeakTypeTag, V: c.WeakTypeTag](c: Context)(vs: c.Expr[Initialize[Task[V]]])(a: c.Expr[Append.Values[S, V]]): c.Expr[Setting[Task[S]]] =
|
def fakeTaskAppendNPosition[S: c.WeakTypeTag, V: c.WeakTypeTag](c: blackbox.Context)(vs: c.Expr[Initialize[Task[V]]])(a: c.Expr[Append.Values[S, V]]): c.Expr[Setting[Task[S]]] =
|
||||||
ContextUtil.selectMacroImpl[Setting[Task[S]]](c) { (ts, pos) =>
|
ContextUtil.selectMacroImpl[Setting[Task[S]]](c) { (ts, pos) =>
|
||||||
c.abort(pos, appendNMigration)
|
c.abort(pos, appendNMigration)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementations of <<= macro variations for tasks and settings. These just get the source position of the call site.*/
|
/* Implementations of <<= macro variations for tasks and settings. These just get the source position of the call site.*/
|
||||||
|
|
||||||
def itaskAssignPosition[T: c.WeakTypeTag](c: Context)(app: c.Expr[Initialize[Task[T]]]): c.Expr[Setting[Task[T]]] =
|
def itaskAssignPosition[T: c.WeakTypeTag](c: blackbox.Context)(app: c.Expr[Initialize[Task[T]]]): c.Expr[Setting[Task[T]]] =
|
||||||
settingAssignPosition(c)(app)
|
settingAssignPosition(c)(app)
|
||||||
def taskAssignPositionT[T: c.WeakTypeTag](c: Context)(app: c.Expr[Task[T]]): c.Expr[Setting[Task[T]]] =
|
def taskAssignPositionT[T: c.WeakTypeTag](c: blackbox.Context)(app: c.Expr[Task[T]]): c.Expr[Setting[Task[T]]] =
|
||||||
itaskAssignPosition(c)(c.universe.reify { Def.valueStrict(app.splice) })
|
itaskAssignPosition(c)(c.universe.reify { Def.valueStrict(app.splice) })
|
||||||
def taskAssignPositionPure[T: c.WeakTypeTag](c: Context)(app: c.Expr[T]): c.Expr[Setting[Task[T]]] =
|
def taskAssignPositionPure[T: c.WeakTypeTag](c: blackbox.Context)(app: c.Expr[T]): c.Expr[Setting[Task[T]]] =
|
||||||
taskAssignPositionT(c)(c.universe.reify { TaskExtra.constant(app.splice) })
|
taskAssignPositionT(c)(c.universe.reify { TaskExtra.constant(app.splice) })
|
||||||
def taskTransformPosition[S: c.WeakTypeTag](c: Context)(f: c.Expr[S => S]): c.Expr[Setting[Task[S]]] =
|
def taskTransformPosition[S: c.WeakTypeTag](c: blackbox.Context)(f: c.Expr[S => S]): c.Expr[Setting[Task[S]]] =
|
||||||
c.Expr[Setting[Task[S]]](transformMacroImpl(c)(f.tree)(TransformInitName))
|
c.Expr[Setting[Task[S]]](transformMacroImpl(c)(f.tree)(TransformInitName))
|
||||||
def settingTransformPosition[S: c.WeakTypeTag](c: Context)(f: c.Expr[S => S]): c.Expr[Setting[S]] =
|
def settingTransformPosition[S: c.WeakTypeTag](c: blackbox.Context)(f: c.Expr[S => S]): c.Expr[Setting[S]] =
|
||||||
c.Expr[Setting[S]](transformMacroImpl(c)(f.tree)(TransformInitName))
|
c.Expr[Setting[S]](transformMacroImpl(c)(f.tree)(TransformInitName))
|
||||||
def itaskTransformPosition[S: c.WeakTypeTag](c: Context)(f: c.Expr[S => S]): c.Expr[Setting[S]] =
|
def itaskTransformPosition[S: c.WeakTypeTag](c: blackbox.Context)(f: c.Expr[S => S]): c.Expr[Setting[S]] =
|
||||||
c.Expr[Setting[S]](transformMacroImpl(c)(f.tree)(TransformInitName))
|
c.Expr[Setting[S]](transformMacroImpl(c)(f.tree)(TransformInitName))
|
||||||
def settingAssignPure[T: c.WeakTypeTag](c: Context)(app: c.Expr[T]): c.Expr[Setting[T]] =
|
def settingAssignPure[T: c.WeakTypeTag](c: blackbox.Context)(app: c.Expr[T]): c.Expr[Setting[T]] =
|
||||||
settingAssignPosition(c)(c.universe.reify { Def.valueStrict(app.splice) })
|
settingAssignPosition(c)(c.universe.reify { Def.valueStrict(app.splice) })
|
||||||
def settingAssignPosition[T: c.WeakTypeTag](c: Context)(app: c.Expr[Initialize[T]]): c.Expr[Setting[T]] =
|
def settingAssignPosition[T: c.WeakTypeTag](c: blackbox.Context)(app: c.Expr[Initialize[T]]): c.Expr[Setting[T]] =
|
||||||
c.Expr[Setting[T]](transformMacroImpl(c)(app.tree)(AssignInitName))
|
c.Expr[Setting[T]](transformMacroImpl(c)(app.tree)(AssignInitName))
|
||||||
|
|
||||||
/** Implementation of := macro for tasks. */
|
/** Implementation of := macro for tasks. */
|
||||||
def inputTaskAssignMacroImpl[T: c.WeakTypeTag](c: Context)(v: c.Expr[T]): c.Expr[Setting[InputTask[T]]] =
|
def inputTaskAssignMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[T]): c.Expr[Setting[InputTask[T]]] =
|
||||||
{
|
{
|
||||||
val init = inputTaskMacroImpl[T](c)(v)
|
val init = inputTaskMacroImpl[T](c)(v)
|
||||||
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
||||||
c.Expr[Setting[InputTask[T]]](assign)
|
c.Expr[Setting[InputTask[T]]](assign)
|
||||||
}
|
}
|
||||||
/** Implementation of += macro for tasks. */
|
/** Implementation of += macro for tasks. */
|
||||||
def taskAppend1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(v: c.Expr[U])(a: c.Expr[Append.Value[T, U]]): c.Expr[Setting[Task[T]]] =
|
def taskAppend1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[U])(a: c.Expr[Append.Value[T, U]]): c.Expr[Setting[Task[T]]] =
|
||||||
{
|
{
|
||||||
val init = taskMacroImpl[U](c)(v)
|
val init = taskMacroImpl[U](c)(v)
|
||||||
val append = appendMacroImpl(c)(init.tree, a.tree)(Append1InitName)
|
val append = appendMacroImpl(c)(init.tree, a.tree)(Append1InitName)
|
||||||
c.Expr[Setting[Task[T]]](append)
|
c.Expr[Setting[Task[T]]](append)
|
||||||
}
|
}
|
||||||
/** Implementation of += macro for settings. */
|
/** Implementation of += macro for settings. */
|
||||||
def settingAppend1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(v: c.Expr[U])(a: c.Expr[Append.Value[T, U]]): c.Expr[Setting[T]] =
|
def settingAppend1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[U])(a: c.Expr[Append.Value[T, U]]): c.Expr[Setting[T]] =
|
||||||
{
|
{
|
||||||
val init = SettingMacro.settingMacroImpl[U](c)(v)
|
val init = SettingMacro.settingMacroImpl[U](c)(v)
|
||||||
val append = appendMacroImpl(c)(init.tree, a.tree)(Append1InitName)
|
val append = appendMacroImpl(c)(init.tree, a.tree)(Append1InitName)
|
||||||
c.Expr[Setting[T]](append)
|
c.Expr[Setting[T]](append)
|
||||||
}
|
}
|
||||||
/** Implementation of ++= macro for tasks. */
|
/** Implementation of ++= macro for tasks. */
|
||||||
def taskAppendNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(vs: c.Expr[U])(a: c.Expr[Append.Values[T, U]]): c.Expr[Setting[Task[T]]] =
|
def taskAppendNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(vs: c.Expr[U])(a: c.Expr[Append.Values[T, U]]): c.Expr[Setting[Task[T]]] =
|
||||||
{
|
{
|
||||||
val init = taskMacroImpl[U](c)(vs)
|
val init = taskMacroImpl[U](c)(vs)
|
||||||
val append = appendMacroImpl(c)(init.tree, a.tree)(AppendNInitName)
|
val append = appendMacroImpl(c)(init.tree, a.tree)(AppendNInitName)
|
||||||
c.Expr[Setting[Task[T]]](append)
|
c.Expr[Setting[Task[T]]](append)
|
||||||
}
|
}
|
||||||
/** Implementation of ++= macro for settings. */
|
/** Implementation of ++= macro for settings. */
|
||||||
def settingAppendNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(vs: c.Expr[U])(a: c.Expr[Append.Values[T, U]]): c.Expr[Setting[T]] =
|
def settingAppendNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(vs: c.Expr[U])(a: c.Expr[Append.Values[T, U]]): c.Expr[Setting[T]] =
|
||||||
{
|
{
|
||||||
val init = SettingMacro.settingMacroImpl[U](c)(vs)
|
val init = SettingMacro.settingMacroImpl[U](c)(vs)
|
||||||
val append = appendMacroImpl(c)(init.tree, a.tree)(AppendNInitName)
|
val append = appendMacroImpl(c)(init.tree, a.tree)(AppendNInitName)
|
||||||
|
|
@ -185,35 +185,35 @@ object TaskMacro {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of -= macro for tasks. */
|
/** Implementation of -= macro for tasks. */
|
||||||
def taskRemove1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(v: c.Expr[U])(r: c.Expr[Remove.Value[T, U]]): c.Expr[Setting[Task[T]]] =
|
def taskRemove1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[U])(r: c.Expr[Remove.Value[T, U]]): c.Expr[Setting[Task[T]]] =
|
||||||
{
|
{
|
||||||
val init = taskMacroImpl[U](c)(v)
|
val init = taskMacroImpl[U](c)(v)
|
||||||
val remove = removeMacroImpl(c)(init.tree, r.tree)(Remove1InitName)
|
val remove = removeMacroImpl(c)(init.tree, r.tree)(Remove1InitName)
|
||||||
c.Expr[Setting[Task[T]]](remove)
|
c.Expr[Setting[Task[T]]](remove)
|
||||||
}
|
}
|
||||||
/** Implementation of -= macro for settings. */
|
/** Implementation of -= macro for settings. */
|
||||||
def settingRemove1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(v: c.Expr[U])(r: c.Expr[Remove.Value[T, U]]): c.Expr[Setting[T]] =
|
def settingRemove1Impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(v: c.Expr[U])(r: c.Expr[Remove.Value[T, U]]): c.Expr[Setting[T]] =
|
||||||
{
|
{
|
||||||
val init = SettingMacro.settingMacroImpl[U](c)(v)
|
val init = SettingMacro.settingMacroImpl[U](c)(v)
|
||||||
val remove = removeMacroImpl(c)(init.tree, r.tree)(Remove1InitName)
|
val remove = removeMacroImpl(c)(init.tree, r.tree)(Remove1InitName)
|
||||||
c.Expr[Setting[T]](remove)
|
c.Expr[Setting[T]](remove)
|
||||||
}
|
}
|
||||||
/** Implementation of --= macro for tasks. */
|
/** Implementation of --= macro for tasks. */
|
||||||
def taskRemoveNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(vs: c.Expr[U])(r: c.Expr[Remove.Values[T, U]]): c.Expr[Setting[Task[T]]] =
|
def taskRemoveNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(vs: c.Expr[U])(r: c.Expr[Remove.Values[T, U]]): c.Expr[Setting[Task[T]]] =
|
||||||
{
|
{
|
||||||
val init = taskMacroImpl[U](c)(vs)
|
val init = taskMacroImpl[U](c)(vs)
|
||||||
val remove = removeMacroImpl(c)(init.tree, r.tree)(RemoveNInitName)
|
val remove = removeMacroImpl(c)(init.tree, r.tree)(RemoveNInitName)
|
||||||
c.Expr[Setting[Task[T]]](remove)
|
c.Expr[Setting[Task[T]]](remove)
|
||||||
}
|
}
|
||||||
/** Implementation of --= macro for settings. */
|
/** Implementation of --= macro for settings. */
|
||||||
def settingRemoveNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(vs: c.Expr[U])(r: c.Expr[Remove.Values[T, U]]): c.Expr[Setting[T]] =
|
def settingRemoveNImpl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: blackbox.Context)(vs: c.Expr[U])(r: c.Expr[Remove.Values[T, U]]): c.Expr[Setting[T]] =
|
||||||
{
|
{
|
||||||
val init = SettingMacro.settingMacroImpl[U](c)(vs)
|
val init = SettingMacro.settingMacroImpl[U](c)(vs)
|
||||||
val remove = removeMacroImpl(c)(init.tree, r.tree)(RemoveNInitName)
|
val remove = removeMacroImpl(c)(init.tree, r.tree)(RemoveNInitName)
|
||||||
c.Expr[Setting[T]](remove)
|
c.Expr[Setting[T]](remove)
|
||||||
}
|
}
|
||||||
|
|
||||||
private[this] def appendMacroImpl(c: Context)(init: c.Tree, append: c.Tree)(newName: String): c.Tree =
|
private[this] def appendMacroImpl(c: blackbox.Context)(init: c.Tree, append: c.Tree)(newName: String): c.Tree =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
c.macroApplication match {
|
c.macroApplication match {
|
||||||
|
|
@ -222,7 +222,7 @@ object TaskMacro {
|
||||||
case x => ContextUtil.unexpectedTree(x)
|
case x => ContextUtil.unexpectedTree(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private[this] def removeMacroImpl(c: Context)(init: c.Tree, remove: c.Tree)(newName: String): c.Tree =
|
private[this] def removeMacroImpl(c: blackbox.Context)(init: c.Tree, remove: c.Tree)(newName: String): c.Tree =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
c.macroApplication match {
|
c.macroApplication match {
|
||||||
|
|
@ -231,7 +231,7 @@ object TaskMacro {
|
||||||
case x => ContextUtil.unexpectedTree(x)
|
case x => ContextUtil.unexpectedTree(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private[this] def transformMacroImpl(c: Context)(init: c.Tree)(newName: String): c.Tree =
|
private[this] def transformMacroImpl(c: blackbox.Context)(init: c.Tree)(newName: String): c.Tree =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
val target =
|
val target =
|
||||||
|
|
@ -241,7 +241,7 @@ object TaskMacro {
|
||||||
}
|
}
|
||||||
Apply.apply(Select(target, TermName(newName).encodedName), init :: sourcePosition(c).tree :: Nil)
|
Apply.apply(Select(target, TermName(newName).encodedName), init :: sourcePosition(c).tree :: Nil)
|
||||||
}
|
}
|
||||||
private[this] def sourcePosition(c: Context): c.Expr[SourcePosition] =
|
private[this] def sourcePosition(c: blackbox.Context): c.Expr[SourcePosition] =
|
||||||
{
|
{
|
||||||
import c.universe.reify
|
import c.universe.reify
|
||||||
val pos = c.enclosingPosition
|
val pos = c.enclosingPosition
|
||||||
|
|
@ -253,7 +253,7 @@ object TaskMacro {
|
||||||
} else
|
} else
|
||||||
reify { NoPosition }
|
reify { NoPosition }
|
||||||
}
|
}
|
||||||
private[this] def settingSource(c: Context, path: String, name: String): String =
|
private[this] def settingSource(c: blackbox.Context, path: String, name: String): String =
|
||||||
{
|
{
|
||||||
@tailrec def inEmptyPackage(s: c.Symbol): Boolean = s != c.universe.NoSymbol && (
|
@tailrec def inEmptyPackage(s: c.Symbol): Boolean = s != c.universe.NoSymbol && (
|
||||||
s.owner == c.mirror.EmptyPackage || s.owner == c.mirror.EmptyPackageClass || inEmptyPackage(s.owner)
|
s.owner == c.mirror.EmptyPackage || s.owner == c.mirror.EmptyPackageClass || inEmptyPackage(s.owner)
|
||||||
|
|
@ -265,17 +265,17 @@ object TaskMacro {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private[this] def constant[T: c.TypeTag](c: Context, t: T): c.Expr[T] = {
|
private[this] def constant[T: c.TypeTag](c: blackbox.Context, t: T): c.Expr[T] = {
|
||||||
import c.universe._
|
import c.universe._
|
||||||
c.Expr[T](Literal(Constant(t)))
|
c.Expr[T](Literal(Constant(t)))
|
||||||
}
|
}
|
||||||
|
|
||||||
def inputTaskMacroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[Initialize[InputTask[T]]] =
|
def inputTaskMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[T]): c.Expr[Initialize[InputTask[T]]] =
|
||||||
inputTaskMacro0[T](c)(t)
|
inputTaskMacro0[T](c)(t)
|
||||||
def inputTaskDynMacroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[Initialize[Task[T]]]): c.Expr[Initialize[InputTask[T]]] =
|
def inputTaskDynMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[Initialize[Task[T]]]): c.Expr[Initialize[InputTask[T]]] =
|
||||||
inputTaskDynMacro0[T](c)(t)
|
inputTaskDynMacro0[T](c)(t)
|
||||||
|
|
||||||
private[this] def inputTaskMacro0[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[Initialize[InputTask[T]]] =
|
private[this] def inputTaskMacro0[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[T]): c.Expr[Initialize[InputTask[T]]] =
|
||||||
iInitializeMacro(c)(t) { et =>
|
iInitializeMacro(c)(t) { et =>
|
||||||
val pt = iParserMacro(c)(et) { pt =>
|
val pt = iParserMacro(c)(et) { pt =>
|
||||||
iTaskMacro(c)(pt)
|
iTaskMacro(c)(pt)
|
||||||
|
|
@ -283,13 +283,13 @@ object TaskMacro {
|
||||||
c.universe.reify { InputTask.make(pt.splice) }
|
c.universe.reify { InputTask.make(pt.splice) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private[this] def iInitializeMacro[M[_], T](c: Context)(t: c.Expr[T])(f: c.Expr[T] => c.Expr[M[T]])(implicit tt: c.WeakTypeTag[T], mt: c.WeakTypeTag[M[T]]): c.Expr[Initialize[M[T]]] =
|
private[this] def iInitializeMacro[M[_], T](c: blackbox.Context)(t: c.Expr[T])(f: c.Expr[T] => c.Expr[M[T]])(implicit tt: c.WeakTypeTag[T], mt: c.WeakTypeTag[M[T]]): c.Expr[Initialize[M[T]]] =
|
||||||
{
|
{
|
||||||
val inner: Transform[c.type, M] = new Transform[c.type, M] { def apply(in: c.Tree): c.Tree = f(c.Expr[T](in)).tree }
|
val inner: Transform[c.type, M] = new Transform[c.type, M] { def apply(in: c.Tree): c.Tree = f(c.Expr[T](in)).tree }
|
||||||
val cond = c.Expr[T](conditionInputTaskTree(c)(t.tree))
|
val cond = c.Expr[T](conditionInputTaskTree(c)(t.tree))
|
||||||
Instance.contImpl[T, M](c, InitializeInstance, InputInitConvert, MixedBuilder)(Left(cond), inner)
|
Instance.contImpl[T, M](c, InitializeInstance, InputInitConvert, MixedBuilder)(Left(cond), inner)
|
||||||
}
|
}
|
||||||
private[this] def conditionInputTaskTree(c: Context)(t: c.Tree): c.Tree =
|
private[this] def conditionInputTaskTree(c: blackbox.Context)(t: c.Tree): c.Tree =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
import InputWrapper._
|
import InputWrapper._
|
||||||
|
|
@ -326,16 +326,16 @@ object TaskMacro {
|
||||||
util.transformWrappers(t, (nme, tpe, tree, original) => expand(nme, tpe, tree))
|
util.transformWrappers(t, (nme, tpe, tree, original) => expand(nme, tpe, tree))
|
||||||
}
|
}
|
||||||
|
|
||||||
private[this] def iParserMacro[M[_], T](c: Context)(t: c.Expr[T])(f: c.Expr[T] => c.Expr[M[T]])(implicit tt: c.WeakTypeTag[T], mt: c.WeakTypeTag[M[T]]): c.Expr[State => Parser[M[T]]] =
|
private[this] def iParserMacro[M[_], T](c: blackbox.Context)(t: c.Expr[T])(f: c.Expr[T] => c.Expr[M[T]])(implicit tt: c.WeakTypeTag[T], mt: c.WeakTypeTag[M[T]]): c.Expr[State => Parser[M[T]]] =
|
||||||
{
|
{
|
||||||
val inner: Transform[c.type, M] = new Transform[c.type, M] { def apply(in: c.Tree): c.Tree = f(c.Expr[T](in)).tree }
|
val inner: Transform[c.type, M] = new Transform[c.type, M] { def apply(in: c.Tree): c.Tree = f(c.Expr[T](in)).tree }
|
||||||
Instance.contImpl[T, M](c, ParserInstance, ParserConvert, MixedBuilder)(Left(t), inner)
|
Instance.contImpl[T, M](c, ParserInstance, ParserConvert, MixedBuilder)(Left(t), inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
private[this] def iTaskMacro[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[Task[T]] =
|
private[this] def iTaskMacro[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[T]): c.Expr[Task[T]] =
|
||||||
Instance.contImpl[T, Id](c, TaskInstance, TaskConvert, MixedBuilder)(Left(t), Instance.idTransform)
|
Instance.contImpl[T, Id](c, TaskInstance, TaskConvert, MixedBuilder)(Left(t), Instance.idTransform)
|
||||||
|
|
||||||
private[this] def inputTaskDynMacro0[T: c.WeakTypeTag](c: Context)(t: c.Expr[Initialize[Task[T]]]): c.Expr[Initialize[InputTask[T]]] =
|
private[this] def inputTaskDynMacro0[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[Initialize[Task[T]]]): c.Expr[Initialize[InputTask[T]]] =
|
||||||
{
|
{
|
||||||
import c.universe.{ Apply => ApplyTree, _ }
|
import c.universe.{ Apply => ApplyTree, _ }
|
||||||
import internal.decorators._
|
import internal.decorators._
|
||||||
|
|
@ -417,10 +417,10 @@ object TaskMacro {
|
||||||
|
|
||||||
object PlainTaskMacro {
|
object PlainTaskMacro {
|
||||||
def task[T](t: T): Task[T] = macro taskImpl[T]
|
def task[T](t: T): Task[T] = macro taskImpl[T]
|
||||||
def taskImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[Task[T]] =
|
def taskImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[T]): c.Expr[Task[T]] =
|
||||||
Instance.contImpl[T, Id](c, TaskInstance, TaskConvert, MixedBuilder)(Left(t), Instance.idTransform[c.type])
|
Instance.contImpl[T, Id](c, TaskInstance, TaskConvert, MixedBuilder)(Left(t), Instance.idTransform[c.type])
|
||||||
|
|
||||||
def taskDyn[T](t: Task[T]): Task[T] = macro taskDynImpl[T]
|
def taskDyn[T](t: Task[T]): Task[T] = macro taskDynImpl[T]
|
||||||
def taskDynImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[Task[T]]): c.Expr[Task[T]] =
|
def taskDynImpl[T: c.WeakTypeTag](c: blackbox.Context)(t: c.Expr[Task[T]]): c.Expr[Task[T]] =
|
||||||
Instance.contImpl[T, Id](c, TaskInstance, TaskConvert, MixedBuilder)(Right(t), Instance.idTransform[c.type])
|
Instance.contImpl[T, Id](c, TaskInstance, TaskConvert, MixedBuilder)(Right(t), Instance.idTransform[c.type])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -636,7 +636,7 @@ object Project extends ProjectExtra {
|
||||||
|
|
||||||
import reflect.macros._
|
import reflect.macros._
|
||||||
|
|
||||||
def projectMacroImpl(c: Context): c.Expr[Project] =
|
def projectMacroImpl(c: blackbox.Context): c.Expr[Project] =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
val enclosingValName = std.KeyMacro.definingValName(c, methodName => s"""$methodName must be directly assigned to a val, such as `val x = $methodName`. Alternatively, you can use `sbt.Project.apply`""")
|
val enclosingValName = std.KeyMacro.definingValName(c, methodName => s"""$methodName must be directly assigned to a val, such as `val x = $methodName`. Alternatively, you can use `sbt.Project.apply`""")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue