mirror of https://github.com/sbt/sbt.git
Append macros
This commit is contained in:
parent
9c1e8abb91
commit
a1e50f8a2e
|
|
@ -148,23 +148,23 @@ sealed abstract class TaskKey[A1]
|
||||||
def in(scope: Scope): TaskKey[A1] =
|
def in(scope: Scope): TaskKey[A1] =
|
||||||
Scoped.scopedTask(Scope.replaceThis(this.scope)(scope), this.key)
|
Scoped.scopedTask(Scope.replaceThis(this.scope)(scope), this.key)
|
||||||
|
|
||||||
// def +=[U](v: U)(implicit a: Append.Value[T, U]): Setting[Task[T]] =
|
inline def +=[A2](inline v: A2)(using Append.Value[A1, A2]): Setting[Task[A1]] =
|
||||||
// macro std.TaskMacro.taskAppend1Impl[T, U]
|
${ TaskMacro.taskAppend1Impl[A1, A2]('this, 'v) }
|
||||||
|
|
||||||
// def ++=[U](vs: U)(implicit a: Append.Values[T, U]): Setting[Task[T]] =
|
inline def ++=[A2](inline vs: A2)(using Append.Values[A1, A2]): Setting[Task[A1]] =
|
||||||
// macro std.TaskMacro.taskAppendNImpl[T, U]
|
${ TaskMacro.taskAppendNImpl[A1, A2]('this, 'vs) }
|
||||||
|
|
||||||
// def <+=[V](v: Initialize[Task[V]])(implicit a: Append.Value[T, V]): Setting[Task[T]] =
|
inline def <+=[A2](inline v: Initialize[Task[A2]]): Setting[Task[A1]] =
|
||||||
// macro std.TaskMacro.fakeTaskAppend1Position[T, V]
|
${ TaskMacro.fakeTaskAppend1Position[A1, A2]('v) }
|
||||||
|
|
||||||
// def <++=[V](vs: Initialize[Task[V]])(implicit a: Append.Values[T, V]): Setting[Task[T]] =
|
inline def <++=[A2](inline vs: Initialize[Task[A2]]): Setting[Task[A1]] =
|
||||||
// macro std.TaskMacro.fakeTaskAppendNPosition[T, V]
|
${ TaskMacro.fakeTaskAppendNPosition[A1, A2]('vs) }
|
||||||
|
|
||||||
// final def -=[U](v: U)(implicit r: Remove.Value[T, U]): Setting[Task[T]] =
|
final inline def -=[A2](v: A2)(using r: Remove.Value[A1, A2]): Setting[Task[A1]] =
|
||||||
// macro std.TaskMacro.taskRemove1Impl[T, U]
|
${ TaskMacro.taskRemove1Impl[A1, A2]('this, 'v) }
|
||||||
|
|
||||||
// final def --=[U](vs: U)(implicit r: Remove.Values[T, U]): Setting[Task[T]] =
|
final inline def --=[A2](vs: A2)(using r: Remove.Values[A1, A2]): Setting[Task[A1]] =
|
||||||
// macro std.TaskMacro.taskRemoveNImpl[T, U]
|
${ TaskMacro.taskRemoveNImpl[A1, A2]('this, 'vs) }
|
||||||
|
|
||||||
def append1[V](v: Initialize[Task[V]], source: SourcePosition)(implicit
|
def append1[V](v: Initialize[Task[V]], source: SourcePosition)(implicit
|
||||||
a: Append.Value[A1, V]
|
a: Append.Value[A1, V]
|
||||||
|
|
@ -372,8 +372,8 @@ object Scoped:
|
||||||
inline def :=(inline v: A1): Setting[Task[A1]] =
|
inline def :=(inline v: A1): Setting[Task[A1]] =
|
||||||
${ TaskMacro.taskAssignMacroImpl[A1]('self, 'v) }
|
${ TaskMacro.taskAssignMacroImpl[A1]('self, 'v) }
|
||||||
|
|
||||||
// def <<=(app: Initialize[Task[S]]): Setting[Task[S]] =
|
inline def <<=(inline app: Initialize[Task[A1]]): Setting[Task[A1]] =
|
||||||
// macro std.TaskMacro.fakeItaskAssignPosition[S]
|
${ TaskMacro.fakeItaskAssignPosition[A1]('app) }
|
||||||
|
|
||||||
/** In addition to creating Def.setting(...), this captures the source position. */
|
/** In addition to creating Def.setting(...), this captures the source position. */
|
||||||
inline def set(inline app: Initialize[Task[A1]]): Setting[Task[A1]] =
|
inline def set(inline app: Initialize[Task[A1]]): Setting[Task[A1]] =
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ object TaskMacro:
|
||||||
@deprecated("unused", "") v: Expr[Initialize[Task[A2]]]
|
@deprecated("unused", "") v: Expr[Initialize[Task[A2]]]
|
||||||
)(using
|
)(using
|
||||||
qctx: Quotes
|
qctx: Quotes
|
||||||
): Expr[Setting[Task[A2]]] =
|
): Expr[Setting[Task[A1]]] =
|
||||||
import qctx.reflect.*
|
import qctx.reflect.*
|
||||||
report.errorAndAbort(TaskMacro.append1Migration)
|
report.errorAndAbort(TaskMacro.append1Migration)
|
||||||
|
|
||||||
|
|
@ -241,16 +241,21 @@ object TaskMacro:
|
||||||
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
val assign = transformMacroImpl(c)(init.tree)(AssignInitName)
|
||||||
c.Expr[Setting[InputTask[A1]]](assign)
|
c.Expr[Setting[InputTask[A1]]](assign)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** Implementation of += macro for tasks. */
|
/** Implementation of += macro for tasks. */
|
||||||
def taskAppend1Impl[A1: Type, U: Type](using
|
def taskAppend1Impl[A1: Type, A2: Type](rec: Expr[TaskKey[A1]], v: Expr[A2])(using
|
||||||
qctx: Quotes
|
qctx: Quotes
|
||||||
)(v: c.Expr[U])(a: c.Expr[Append.Value[A1, U]]): c.Expr[Setting[Task[A1]]] = {
|
): Expr[Setting[Task[A1]]] =
|
||||||
val init = taskMacroImpl[U](c)(v)
|
import qctx.reflect.*
|
||||||
val append = appendMacroImpl(c)(init.tree, a.tree)(Append1InitName)
|
Expr.summon[Append.Value[A1, A2]] match
|
||||||
c.Expr[Setting[Task[A1]]](append)
|
case Some(ev) =>
|
||||||
}
|
val init = taskMacroImpl[A2](v)
|
||||||
*/
|
'{
|
||||||
|
$rec.append1[A2]($init, $sourcePosition)(using $ev)
|
||||||
|
}
|
||||||
|
case _ =>
|
||||||
|
report.errorAndAbort(s"Append.Value[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
||||||
|
|
||||||
/** Implementation of += macro for settings. */
|
/** Implementation of += macro for settings. */
|
||||||
def settingAppend1Impl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], v: Expr[A2])(using
|
def settingAppend1Impl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], v: Expr[A2])(using
|
||||||
|
|
@ -278,16 +283,18 @@ object TaskMacro:
|
||||||
}
|
}
|
||||||
case _ => report.errorAndAbort(s"Append.Value[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
case _ => report.errorAndAbort(s"Append.Value[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
||||||
|
|
||||||
/*
|
|
||||||
/** Implementation of ++= macro for tasks. */
|
/** Implementation of ++= macro for tasks. */
|
||||||
def taskAppendNImpl[A1: Type, U: Type](
|
def taskAppendNImpl[A1: Type, A2: Type](rec: Expr[TaskKey[A1]], vs: Expr[A2])(using
|
||||||
c: blackbox.Context
|
qctx: Quotes
|
||||||
)(vs: c.Expr[U])(a: c.Expr[Append.Values[A1, U]]): c.Expr[Setting[Task[A1]]] = {
|
): Expr[Setting[Task[A1]]] =
|
||||||
val init = taskMacroImpl[U](c)(vs)
|
import qctx.reflect.*
|
||||||
val append = appendMacroImpl(c)(init.tree, a.tree)(AppendNInitName)
|
Expr.summon[Append.Values[A1, A2]] match
|
||||||
c.Expr[Setting[Task[A1]]](append)
|
case Some(ev) =>
|
||||||
}
|
val init = taskMacroImpl[A2](vs)
|
||||||
*/
|
'{
|
||||||
|
$rec.appendN($init, $sourcePosition)(using $ev)
|
||||||
|
}
|
||||||
|
case _ => report.errorAndAbort(s"Append.Values[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
||||||
|
|
||||||
/** Implementation of ++= macro for settings. */
|
/** Implementation of ++= macro for settings. */
|
||||||
def settingAppendNImpl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], vs: Expr[A2])(using
|
def settingAppendNImpl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], vs: Expr[A2])(using
|
||||||
|
|
@ -302,16 +309,18 @@ object TaskMacro:
|
||||||
}
|
}
|
||||||
case _ => report.errorAndAbort(s"Append.Values[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
case _ => report.errorAndAbort(s"Append.Values[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
||||||
|
|
||||||
/*
|
|
||||||
/** Implementation of -= macro for tasks. */
|
/** Implementation of -= macro for tasks. */
|
||||||
def taskRemove1Impl[A1: Type, U: Type](using
|
def taskRemove1Impl[A1: Type, A2: Type](rec: Expr[TaskKey[A1]], v: Expr[A2])(using
|
||||||
qctx: Quotes
|
qctx: Quotes
|
||||||
)(v: c.Expr[U])(r: c.Expr[Remove.Value[A1, U]]): c.Expr[Setting[Task[A1]]] = {
|
): Expr[Setting[Task[A1]]] =
|
||||||
val init = taskMacroImpl[U](c)(v)
|
import qctx.reflect.*
|
||||||
val remove = removeMacroImpl(c)(init.tree, r.tree)(Remove1InitName)
|
Expr.summon[Remove.Value[A1, A2]] match
|
||||||
c.Expr[Setting[Task[A1]]](remove)
|
case Some(ev) =>
|
||||||
}
|
val init = taskMacroImpl[A2](v)
|
||||||
*/
|
'{
|
||||||
|
$rec.remove1[A2]($init, $sourcePosition)(using $ev)
|
||||||
|
}
|
||||||
|
case _ => report.errorAndAbort(s"Remove.Value[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
||||||
|
|
||||||
/** Implementation of -= macro for settings. */
|
/** Implementation of -= macro for settings. */
|
||||||
def settingRemove1Impl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], v: Expr[A2])(using
|
def settingRemove1Impl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], v: Expr[A2])(using
|
||||||
|
|
@ -326,16 +335,18 @@ object TaskMacro:
|
||||||
}
|
}
|
||||||
case _ => report.errorAndAbort(s"Remove.Value[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
case _ => report.errorAndAbort(s"Remove.Value[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
||||||
|
|
||||||
/*
|
|
||||||
/** Implementation of --= macro for tasks. */
|
/** Implementation of --= macro for tasks. */
|
||||||
def taskRemoveNImpl[A1: Type, U: Type](using
|
def taskRemoveNImpl[A1: Type, A2: Type](rec: Expr[TaskKey[A1]], vs: Expr[A2])(using
|
||||||
qctx: Quotes
|
qctx: Quotes
|
||||||
)(vs: c.Expr[U])(r: c.Expr[Remove.Values[A1, U]]): c.Expr[Setting[Task[A1]]] = {
|
): Expr[Setting[Task[A1]]] =
|
||||||
val init = taskMacroImpl[U](c)(vs)
|
import qctx.reflect.*
|
||||||
val remove = removeMacroImpl(c)(init.tree, r.tree)(RemoveNInitName)
|
Expr.summon[Remove.Values[A1, A2]] match
|
||||||
c.Expr[Setting[Task[A1]]](remove)
|
case Some(ev) =>
|
||||||
}
|
val init = taskMacroImpl[A2](vs)
|
||||||
*/
|
'{
|
||||||
|
$rec.removeN[A2]($init, $sourcePosition)(using $ev)
|
||||||
|
}
|
||||||
|
case _ => report.errorAndAbort(s"Remove.Values[${Type.of[A1]}, ${Type.of[A2]}] missing")
|
||||||
|
|
||||||
/** Implementation of --= macro for settings. */
|
/** Implementation of --= macro for settings. */
|
||||||
def settingRemoveNImpl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], vs: Expr[A2])(using
|
def settingRemoveNImpl[A1: Type, A2: Type](rec: Expr[SettingKey[A1]], vs: Expr[A2])(using
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ object Assign {
|
||||||
val seqSetting = settingKey[Seq[String]]("seqSetting")
|
val seqSetting = settingKey[Seq[String]]("seqSetting")
|
||||||
val listSetting = settingKey[List[String]]("listSetting")
|
val listSetting = settingKey[List[String]]("listSetting")
|
||||||
|
|
||||||
|
val listTask = taskKey[List[String]]("listTask")
|
||||||
|
|
||||||
/* def azy = sk.value
|
/* def azy = sk.value
|
||||||
|
|
||||||
def azy2 = appmacro.Debug.checkWild(Def.task{ sk.value.size })
|
def azy2 = appmacro.Debug.checkWild(Def.task{ sk.value.size })
|
||||||
|
|
@ -134,4 +136,7 @@ object Assign {
|
||||||
listSetting += "test4"
|
listSetting += "test4"
|
||||||
|
|
||||||
listSetting ~= { (xs) => xs }
|
listSetting ~= { (xs) => xs }
|
||||||
|
|
||||||
|
listTask := List("test1")
|
||||||
|
listTask += "test2"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue