mirror of https://github.com/sbt/sbt.git
Drop the remaining TupleSyntax usage
This commit is contained in:
parent
707972e190
commit
e86a63ca1b
|
|
@ -99,10 +99,7 @@ sealed abstract class SettingKey[T]
|
|||
|
||||
protected[this] def make[S](other: Initialize[S], source: SourcePosition)(
|
||||
f: (T, S) => T
|
||||
): Setting[T] = {
|
||||
import TupleSyntax._
|
||||
set((this, other)(f), source)
|
||||
}
|
||||
): Setting[T] = set(this.zipWith(other)(f), source)
|
||||
|
||||
final def withRank(rank: Int): SettingKey[T] =
|
||||
SettingKey(AttributeKey.copyWithRank(key, rank))
|
||||
|
|
@ -169,10 +166,7 @@ sealed abstract class TaskKey[T]
|
|||
|
||||
private[this] def make[S](other: Initialize[Task[S]], source: SourcePosition)(
|
||||
f: (T, S) => T
|
||||
): Setting[Task[T]] = {
|
||||
import TupleSyntax._
|
||||
set((this, other)((a, b) => (a, b) map f.tupled), source)
|
||||
}
|
||||
): Setting[Task[T]] = set(this.zipWith(other)((a, b) => (a, b) map f.tupled), source)
|
||||
|
||||
final def withRank(rank: Int): TaskKey[T] =
|
||||
TaskKey(AttributeKey.copyWithRank(key, rank))
|
||||
|
|
@ -297,10 +291,7 @@ object Scoped {
|
|||
* @param i value to return if this setting doesn't have a value.
|
||||
* @return currently bound setting value, or `i` if unbound.
|
||||
*/
|
||||
final def or[T >: S](i: Initialize[T]): Initialize[T] = {
|
||||
import TupleSyntax._
|
||||
(this.?, i)(_ getOrElse _)
|
||||
}
|
||||
final def or[T >: S](i: Initialize[T]): Initialize[T] = ?.zipWith(i)(_.getOrElse(_))
|
||||
|
||||
/**
|
||||
* Like [[?]], but with a call-by-name parameter rather than an existing [[Def.Initialize]].
|
||||
|
|
@ -366,8 +357,7 @@ object Scoped {
|
|||
protected def onTask[T](f: Task[S] => Task[T]): Initialize[Task[T]] = i apply f
|
||||
|
||||
def dependsOn(tasks: AnyInitTask*): Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(i, Initialize.joinAny[Task](tasks))((thisTask, deps) => thisTask.dependsOn(deps: _*))
|
||||
i.zipWith(Initialize.joinAny[Task](tasks))((thisTask, deps) => thisTask.dependsOn(deps: _*))
|
||||
}
|
||||
|
||||
def failure: Initialize[Task[Incomplete]] = i(_.failure)
|
||||
|
|
@ -385,10 +375,8 @@ object Scoped {
|
|||
private[this] def nonLocal(
|
||||
tasks: Seq[AnyInitTask],
|
||||
key: AttributeKey[Seq[Task[_]]]
|
||||
): Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(Initialize.joinAny[Task](tasks), i)((ts, i) => i.copy(info = i.info.set(key, ts)))
|
||||
}
|
||||
): Initialize[Task[S]] =
|
||||
Initialize.joinAny[Task](tasks).zipWith(i)((ts, i) => i.copy(info = i.info.set(key, ts)))
|
||||
}
|
||||
|
||||
/** Enriches `Initialize[InputTask[S]]` types.
|
||||
|
|
@ -402,8 +390,7 @@ object Scoped {
|
|||
protected def onTask[T](f: Task[S] => Task[T]): Initialize[InputTask[T]] = i(_ mapTask f)
|
||||
|
||||
def dependsOn(tasks: AnyInitTask*): Initialize[InputTask[S]] = {
|
||||
import TupleSyntax._
|
||||
(i, Initialize.joinAny[Task](tasks))(
|
||||
i.zipWith(Initialize.joinAny[Task](tasks))(
|
||||
(thisTask, deps) => thisTask.mapTask(_.dependsOn(deps: _*))
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import sbt.internal.util.appmacro.{
|
|||
}
|
||||
import Instance.Transform
|
||||
import sbt.internal.util.complete.{ DefaultParsers, Parser }
|
||||
import sbt.internal.util.{ AList, LinePosition, NoPosition, SourcePosition }
|
||||
import sbt.internal.util.{ AList, LinePosition, NoPosition, SourcePosition, ~> }
|
||||
|
||||
import language.experimental.macros
|
||||
import scala.annotation.tailrec
|
||||
|
|
@ -63,21 +63,23 @@ object FullInstance
|
|||
)
|
||||
|
||||
def flatten[T](in: Initialize[Task[Initialize[Task[T]]]]): Initialize[Task[T]] = {
|
||||
import TupleSyntax._
|
||||
(in, settingsData, Def.capturedTransformations) {
|
||||
(a: Task[Initialize[Task[T]]], data: Task[SS], f) =>
|
||||
type K[L[x]] = AList.T3K[Task[Initialize[Task[T]]], Task[SS], Initialize ~> Initialize]#l[L]
|
||||
Def.app[K, Task[T]]((in, settingsData, Def.capturedTransformations)) {
|
||||
case (a: Task[Initialize[Task[T]]], data: Task[SS], f) =>
|
||||
import TaskExtra.multT2Task
|
||||
(a, data) flatMap { case (a, d) => f(a) evaluate d }
|
||||
}
|
||||
}(AList.tuple3)
|
||||
}
|
||||
|
||||
def flattenFun[S, T](in: Initialize[Task[S => Initialize[Task[T]]]]): Initialize[S => Task[T]] = {
|
||||
import TupleSyntax._
|
||||
(in, settingsData, Def.capturedTransformations) {
|
||||
(a: Task[S => Initialize[Task[T]]], data: Task[SS], f) => (s: S) =>
|
||||
type K[L[x]] =
|
||||
AList.T3K[Task[S => Initialize[Task[T]]], Task[SS], Initialize ~> Initialize]#l[L]
|
||||
Def.app[K, S => Task[T]]((in, settingsData, Def.capturedTransformations)) {
|
||||
case (a: Task[S => Initialize[Task[T]]], data: Task[SS], f) => { (s: S) =>
|
||||
import TaskExtra.multT2Task
|
||||
(a, data) flatMap { case (af, d) => f(af(s)) evaluate d }
|
||||
}
|
||||
}
|
||||
}(AList.tuple3)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -849,23 +849,18 @@ object Project extends ProjectExtra {
|
|||
def updateState(f: (State, S) => State): Def.Initialize[Task[S]] = i(t => tx(t, f))
|
||||
|
||||
def storeAs(key: TaskKey[S])(implicit f: JsonFormat[S]): Def.Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(Keys.resolvedScoped, i)(
|
||||
(scoped, task) =>
|
||||
tx(
|
||||
task,
|
||||
(state, value) =>
|
||||
persistAndSet(resolveContext(key, scoped.scope, state), state, value)(f)
|
||||
)
|
||||
)
|
||||
Keys.resolvedScoped.zipWith(i) { (scoped, task) =>
|
||||
tx(
|
||||
task,
|
||||
(state, value) => persistAndSet(resolveContext(key, scoped.scope, state), state, value)(f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def keepAs(key: TaskKey[S]): Def.Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(i, Keys.resolvedScoped)(
|
||||
(t, scoped) =>
|
||||
tx(t, (state, value) => set(resolveContext(key, scoped.scope, state), state, value))
|
||||
)
|
||||
i.zipWith(Keys.resolvedScoped) { (t, scoped) =>
|
||||
tx(t, (state, value) => set(resolveContext(key, scoped.scope, state), state, value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue