mirror of https://github.com/sbt/sbt.git
simplify InputTask and provide InputKey factory methods
This commit is contained in:
parent
f6abc17ddf
commit
bfa3a996e9
|
|
@ -14,13 +14,11 @@ package sbt
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
sealed trait InputTask[T] {
|
sealed trait InputTask[T] {
|
||||||
type S
|
def parser: Parser[Task[T]]
|
||||||
def parser: Parser[S]
|
|
||||||
def apply(s: S): Task[T]
|
|
||||||
}
|
}
|
||||||
object InputTask {
|
object InputTask {
|
||||||
def apply[I,T](p: Parser[I], c: I => Task[T]): InputTask[T] { type S = I } =
|
def apply[T](p: Parser[Task[T]]): InputTask[T] = new InputTask[T] { def parser = p }
|
||||||
new InputTask[T] { type S = I; def parser = p; def apply(s: I) = c(s) }
|
def apply[I,T](p: Parser[I], c: I => Task[T]): InputTask[T] = apply(p map c)
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed trait Scoped { def scope: Scope }
|
sealed trait Scoped { def scope: Scope }
|
||||||
|
|
@ -209,6 +207,14 @@ object Scoped
|
||||||
|
|
||||||
// private[this] val hcHead = new ( ({type l[t] = t :+: _})#l ~> Id ) { def apply[T](hc: t :+: _): t = hc.head }
|
// private[this] val hcHead = new ( ({type l[t] = t :+: _})#l ~> Id ) { def apply[T](hc: t :+: _): t = hc.head }
|
||||||
}
|
}
|
||||||
|
object InputKey
|
||||||
|
{
|
||||||
|
def apply[T](label: String): InputKey[T] =
|
||||||
|
apply( AttributeKey[InputTask[T]](label) )
|
||||||
|
|
||||||
|
def apply[T](akey: AttributeKey[InputTask[T]]): InputKey[T] =
|
||||||
|
new InputKey[T](akey)
|
||||||
|
}
|
||||||
object TaskKey
|
object TaskKey
|
||||||
{
|
{
|
||||||
def apply[T](label: String): TaskKey[T] =
|
def apply[T](label: String): TaskKey[T] =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue