mirror of https://github.com/sbt/sbt.git
cleanup and fixes
This commit is contained in:
parent
2687836ca5
commit
837bb80d40
|
|
@ -23,8 +23,8 @@ final class Eval(options: Seq[String], mkReporter: Settings => Reporter, parent:
|
|||
import global._
|
||||
import definitions._
|
||||
|
||||
def eval[T](expression: String)(implicit mf: Manifest[T]): T = eval(expression, Some(mf.toString)).asInstanceOf[T]
|
||||
def eval(expression: String, tpeName: Option[String]): Any =
|
||||
def eval[T](expression: String)(implicit mf: Manifest[T]): T = eval(expression, Some(mf.toString))._2.asInstanceOf[T]
|
||||
def eval(expression: String, tpeName: Option[String]): (String,Any) =
|
||||
{
|
||||
reporter.reset
|
||||
val unit = mkUnit(expression)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ object EvaluateConfigurations
|
|||
// handle multiple expressions at once (for efficiency and better error handling)
|
||||
// accept the source name for error display
|
||||
// accept imports to use
|
||||
eval.eval[Setting[_]](expression)
|
||||
// persist the results (critical for start up time)
|
||||
eval.eval(expression, Some("sbt.Project.Setting[_]"))._2.asInstanceOf[Setting[_]]
|
||||
}
|
||||
def splitExpressions(name: String, lines: Seq[String]): (Seq[String], Seq[String]) =
|
||||
{
|
||||
|
|
@ -81,11 +82,13 @@ object EvaluateConfigurations
|
|||
def groupedLines(lines: Seq[String], delimiter: String => Boolean): Seq[String] =
|
||||
{
|
||||
@tailrec def group0(lines: Seq[String], delimiter: String => Boolean, accum: Seq[String]): Seq[String] =
|
||||
{
|
||||
val start = lines dropWhile delimiter
|
||||
val (next, tail) = start.span (s => !delimiter(s))
|
||||
group0(tail, delimiter, next.mkString("\n") +: accum)
|
||||
}
|
||||
if(lines.isEmpty) accum.reverse
|
||||
else
|
||||
{
|
||||
val start = lines dropWhile delimiter
|
||||
val (next, tail) = start.span (s => !delimiter(s))
|
||||
group0(tail, delimiter, next.mkString("\n") +: accum)
|
||||
}
|
||||
group0(lines, delimiter, Nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ object Command
|
|||
def single(name: String, briefHelp: (String, String), detail: String)(f: (State, String) => State): Command =
|
||||
single(name, Help(name, briefHelp, detail) )(f)
|
||||
def single(name: String, help: Help*)(f: (State, String) => State): Command =
|
||||
apply(name, help : _*)( state => token(any.+.string map apply1(f, state)) )
|
||||
apply(name, help : _*)( state => token(trimmed(any.+.string) map apply1(f, state)) )
|
||||
|
||||
def custom(parser: State => Parser[() => State], help: Seq[Help]): Command = new ArbitraryCommand(parser, help, AttributeMap.empty)
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ object Scoped
|
|||
final def :==(value: S): Setting[S] = :=(value)
|
||||
final def := (value: => S): Setting[S] = Project.value(scoped)(value)
|
||||
final def :~ (f: S => S): Setting[S] = Project.update(scoped)(f)
|
||||
final def :- [HL <: HList](app: Apply[S]): Setting[S] = app toSetting scoped
|
||||
final def :- (app: Apply[S]): Setting[S] = app toSetting scoped
|
||||
|
||||
def apply[T](f: S => T): Apply[T] = Apply.mk(scopedList)(hl => f(hl.head))
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ object Scoped
|
|||
def :== (v: TaskKey[S]): ScS = Project.app(scoped, ScopedKey(scope, v.key) :^: KNil)(_.head)
|
||||
def :~ (f: S => S): ScS = Project.update(scoped)( _ map f )
|
||||
|
||||
def :- [HL <: HList](app: App[S]): ScS = app toSetting scoped
|
||||
def :- (app: App[S]): ScS = app toSetting scoped
|
||||
|
||||
def get(settings: Settings[Scope]): Option[Task[S]] = settings.get(scope, key)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ trait Parsers
|
|||
def mapOrFail[S,T](p: Parser[S])(f: S => T): Parser[T] =
|
||||
p flatMap { s => try { success(f(s)) } catch { case e: Exception => failure(e.toString) } }
|
||||
|
||||
def spaceDelimited(display: String): Parser[Seq[String]] = (token(Space) ~> token(NotSpace, display)).*
|
||||
def spaceDelimited(display: String): Parser[Seq[String]] = (token(Space) ~> token(NotSpace, display)).* <~ SpaceClass.*
|
||||
|
||||
def trimmed(p: Parser[String]) = p map { _.trim }
|
||||
def Uri(ex: Set[URI]) = NotSpace map { uri => new URI(uri) } examples(ex.map(_.toString))
|
||||
}
|
||||
object Parsers extends Parsers
|
||||
|
|
|
|||
Loading…
Reference in New Issue