mirror of https://github.com/sbt/sbt.git
Merge pull request #4 from Duhemm/cleaning
Clean the build and the warnings
This commit is contained in:
commit
c491f57f27
36
build.sbt
36
build.sbt
|
|
@ -11,8 +11,22 @@ def commonSettings: Seq[Setting[_]] = Seq(
|
|||
// concurrentRestrictions in Global += Util.testExclusiveRestriction,
|
||||
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
|
||||
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
|
||||
incOptions := incOptions.value.withNameHashing(true),
|
||||
crossScalaVersions := Seq(scala210, scala211),
|
||||
scalacOptions ++= Seq(
|
||||
"-encoding", "utf8",
|
||||
"-deprecation",
|
||||
"-feature",
|
||||
"-unchecked",
|
||||
"-Xlint",
|
||||
"-language:higherKinds",
|
||||
"-language:implicitConversions",
|
||||
// "-Xfuture",
|
||||
"-Yinline-warnings",
|
||||
// "-Yfatal-warnings",
|
||||
"-Yno-adapted-args",
|
||||
"-Ywarn-dead-code",
|
||||
"-Ywarn-numeric-widen",
|
||||
"-Ywarn-value-discard"),
|
||||
bintrayPackage := (bintrayPackage in ThisBuild).value,
|
||||
bintrayRepository := (bintrayRepository in ThisBuild).value,
|
||||
publishArtifact in Compile := true,
|
||||
|
|
@ -62,33 +76,20 @@ lazy val utilInterface = (project in internalPath / "util-interface").
|
|||
commonSettings,
|
||||
javaOnlySettings,
|
||||
name := "Util Interface",
|
||||
// projectComponent,
|
||||
exportJars := true
|
||||
// resourceGenerators in Compile <+= (version, resourceManaged, streams, compile in Compile) map generateVersionFile,
|
||||
// apiDefinitions <<= baseDirectory map { base => (base / "definition") :: (base / "other") :: (base / "type") :: Nil },
|
||||
// sourceGenerators in Compile <+= (apiDefinitions,
|
||||
// fullClasspath in Compile in datatypeProj,
|
||||
// sourceManaged in Compile,
|
||||
// mainClass in datatypeProj in Compile,
|
||||
// runner,
|
||||
// streams) map generateAPICached
|
||||
)
|
||||
|
||||
lazy val utilControl = (project in internalPath / "util-control").
|
||||
settings(
|
||||
commonSettings,
|
||||
// Util.crossBuild,
|
||||
name := "Util Control",
|
||||
crossScalaVersions := Seq(scala210, scala211)
|
||||
name := "Util Control"
|
||||
)
|
||||
|
||||
lazy val utilCollection = (project in internalPath / "util-collection").
|
||||
settings(
|
||||
testedBaseSettings,
|
||||
Util.keywordsSettings,
|
||||
// Util.crossBuild,
|
||||
name := "Util Collection",
|
||||
crossScalaVersions := Seq(scala210, scala211)
|
||||
name := "Util Collection"
|
||||
)
|
||||
|
||||
lazy val utilApplyMacro = (project in internalPath / "util-appmacro").
|
||||
|
|
@ -104,7 +105,6 @@ lazy val utilComplete = (project in internalPath / "util-complete").
|
|||
dependsOn(utilCollection, utilControl).
|
||||
settings(
|
||||
testedBaseSettings,
|
||||
// Util.crossBuild,
|
||||
name := "Util Completion",
|
||||
libraryDependencies ++= Seq(jline, sbtIO),
|
||||
crossScalaVersions := Seq(scala210, scala211)
|
||||
|
|
@ -150,5 +150,5 @@ lazy val utilTracking = (project in internalPath / "util-tracking").
|
|||
settings(
|
||||
commonSettings,
|
||||
name := "Util Tracking",
|
||||
libraryDependencies ++= Seq(sbtIO)
|
||||
libraryDependencies += sbtIO
|
||||
)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ object ContextUtil {
|
|||
}
|
||||
|
||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
||||
private object HasCompat { val compat = ??? }; import HasCompat._
|
||||
private object HasCompat { val compat = this }; import HasCompat._
|
||||
|
||||
/**
|
||||
* Utility methods for macros. Several methods assume that the context's universe is a full compiler (`scala.tools.nsc.Global`).
|
||||
|
|
@ -134,10 +134,14 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
|||
def mkTuple(args: List[Tree]): Tree =
|
||||
global.gen.mkTuple(args.asInstanceOf[List[global.Tree]]).asInstanceOf[ctx.universe.Tree]
|
||||
|
||||
def setSymbol[Tree](t: Tree, sym: Symbol): Unit =
|
||||
def setSymbol[Tree](t: Tree, sym: Symbol): Unit = {
|
||||
t.asInstanceOf[global.Tree].setSymbol(sym.asInstanceOf[global.Symbol])
|
||||
def setInfo[Tree](sym: Symbol, tpe: Type): Unit =
|
||||
()
|
||||
}
|
||||
def setInfo[Tree](sym: Symbol, tpe: Type): Unit = {
|
||||
sym.asInstanceOf[global.Symbol].setInfo(tpe.asInstanceOf[global.Type])
|
||||
()
|
||||
}
|
||||
|
||||
/** Creates a new, synthetic type variable with the specified `owner`. */
|
||||
def newTypeVariable(owner: Symbol, prefix: String = "T0"): TypeSymbol =
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import macros._
|
|||
/** A `TupleBuilder` that uses a KList as the tuple representation.*/
|
||||
object KListBuilder extends TupleBuilder {
|
||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
||||
private object HasCompat { val compat = ??? }; import HasCompat._
|
||||
private object HasCompat { val compat = this }; import HasCompat._
|
||||
|
||||
def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
||||
val ctx: c.type = c
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ object TupleNBuilder extends TupleBuilder {
|
|||
final val TupleMethodName = "tuple"
|
||||
|
||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
||||
private object HasCompat { val compat = ??? }; import HasCompat._
|
||||
private object HasCompat { val compat = this }; import HasCompat._
|
||||
|
||||
def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
||||
val util = ContextUtil[c.type](c)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.net.{ URI, URL }
|
|||
import Types.:+:
|
||||
import DefaultProtocol.{ asProduct2, asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap }
|
||||
import scala.xml.NodeSeq
|
||||
import scala.language.existentials
|
||||
|
||||
trait Cache[I, O] {
|
||||
def apply(file: File)(i: I): Either[O, O => Unit]
|
||||
|
|
@ -200,7 +201,7 @@ trait UnionImplicits {
|
|||
def convert(in: UB) = uc.find(in)
|
||||
def read(in: Input) =
|
||||
{
|
||||
val index = ByteFormat.reads(in)
|
||||
val index = ByteFormat.reads(in).toInt
|
||||
val (cache, clazz) = uc.at(index)
|
||||
val value = cache.read(in)
|
||||
new Found[cache.Internal](cache, clazz, value, index)
|
||||
|
|
|
|||
|
|
@ -27,5 +27,6 @@ object CacheTest // extends Properties("Cache test")
|
|||
(len + 1) :+: file :+: HNil
|
||||
}
|
||||
c(create :+: fileLength :+: HNil)
|
||||
()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ object Dag {
|
|||
discovered(node) = true;
|
||||
try { visitAll(dependencies(node)); } catch { case c: Cyclic => throw node :: c }
|
||||
finished += node
|
||||
()
|
||||
} else if (!finished(node))
|
||||
throw new Cyclic(node)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ object IDSet {
|
|||
def apply(t: T) = contains(t)
|
||||
def contains(t: T) = backing.containsKey(t)
|
||||
def foreach(f: T => Unit) = all foreach f
|
||||
def +=(t: T) = backing.put(t, Dummy)
|
||||
def +=(t: T) = { backing.put(t, Dummy); () }
|
||||
def ++=(t: Iterable[T]) = t foreach +=
|
||||
def -=(t: T) = if (backing.remove(t) eq null) false else true
|
||||
def all = collection.JavaConversions.collectionAsScalaIterable(backing.keySet)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ abstract class EvaluateSettings[Scope] {
|
|||
workComplete()
|
||||
}
|
||||
|
||||
private[this] def startWork(): Unit = running.incrementAndGet()
|
||||
private[this] def startWork(): Unit = { running.incrementAndGet(); () }
|
||||
private[this] def workComplete(): Unit =
|
||||
if (running.decrementAndGet() == 0)
|
||||
complete.put(None)
|
||||
|
|
@ -154,6 +154,7 @@ abstract class EvaluateSettings[Scope] {
|
|||
case Evaluated => submitCallComplete(by, value)
|
||||
case _ => calledBy += by
|
||||
}
|
||||
()
|
||||
}
|
||||
protected def dependsOn: Seq[INode[_]]
|
||||
protected def evaluate0(): Unit
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ trait RMap[K[_], V[_]] {
|
|||
def values: Iterable[V[_]]
|
||||
def isEmpty: Boolean
|
||||
|
||||
final case class TPair[T](key: K[T], value: V[T])
|
||||
sealed case class TPair[T](key: K[T], value: V[T])
|
||||
}
|
||||
|
||||
trait IMap[K[_], V[_]] extends (K ~> V) with RMap[K, V] {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ sealed trait Settings[Scope] {
|
|||
private final class Settings0[Scope](val data: Map[Scope, AttributeMap], val delegates: Scope => Seq[Scope]) extends Settings[Scope] {
|
||||
def scopes: Set[Scope] = data.keySet
|
||||
def keys(scope: Scope) = data(scope).keys.toSet
|
||||
def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) } toSeq
|
||||
def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) }.toSeq
|
||||
|
||||
def get[T](scope: Scope, key: AttributeKey[T]): Option[T] =
|
||||
delegates(scope).toStream.flatMap(sc => getDirect(sc, key)).headOption
|
||||
|
|
@ -42,7 +42,7 @@ trait Init[Scope] {
|
|||
/** The Show instance used when a detailed String needs to be generated. It is typically used when no context is available.*/
|
||||
def showFullKey: Show[ScopedKey[_]]
|
||||
|
||||
final case class ScopedKey[T](scope: Scope, key: AttributeKey[T]) extends KeyedInitialize[T] {
|
||||
sealed case class ScopedKey[T](scope: Scope, key: AttributeKey[T]) extends KeyedInitialize[T] {
|
||||
def scopedKey = this
|
||||
}
|
||||
|
||||
|
|
@ -154,9 +154,9 @@ trait Init[Scope] {
|
|||
def compile(sMap: ScopedMap): CompiledMap =
|
||||
sMap.toTypedSeq.map {
|
||||
case sMap.TPair(k, ss) =>
|
||||
val deps = ss flatMap { _.dependencies } toSet;
|
||||
val deps = ss.flatMap(_.dependencies).toSet
|
||||
(k, new Compiled(k, deps, ss))
|
||||
} toMap;
|
||||
}.toMap
|
||||
|
||||
def grouped(init: Seq[Setting[_]]): ScopedMap =
|
||||
((IMap.empty: ScopedMap) /: init)((m, s) => add(m, s))
|
||||
|
|
@ -445,7 +445,7 @@ trait Init[Scope] {
|
|||
def join: Initialize[Seq[T]] = uniform(s)(idFun)
|
||||
}
|
||||
def join[T](inits: Seq[Initialize[T]]): Initialize[Seq[T]] = uniform(inits)(idFun)
|
||||
def joinAny[M[_]](inits: Seq[Initialize[M[T]] forSome { type T }]): Initialize[Seq[M[_]]] =
|
||||
def joinAny[M[_], T](inits: Seq[Initialize[M[T]]]): Initialize[Seq[M[_]]] =
|
||||
join(inits.asInstanceOf[Seq[Initialize[M[Any]]]]).asInstanceOf[Initialize[Seq[M[T] forSome { type T }]]]
|
||||
}
|
||||
object SettingsDefinition {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ object Signals {
|
|||
object unregisterNewHandler extends Registration {
|
||||
override def remove(): Unit = {
|
||||
Signal.handle(intSignal, oldHandler)
|
||||
()
|
||||
}
|
||||
}
|
||||
unregisterNewHandler
|
||||
|
|
@ -80,6 +81,6 @@ private final class Signals0 {
|
|||
|
||||
try Right(action())
|
||||
catch { case e: LinkageError => Left(e) }
|
||||
finally Signal.handle(intSignal, oldHandler)
|
||||
finally { Signal.handle(intSignal, oldHandler); () }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ object SettingsUsage {
|
|||
val mySettings: Seq[Setting[_]] = Seq(
|
||||
setting(a3, value(3)),
|
||||
setting(b4, map(a4)(_ * 3)),
|
||||
update(a5)(_ + 1)
|
||||
)
|
||||
update(a5)(_ + 1))
|
||||
|
||||
// "compiles" and applies the settings.
|
||||
// This can be split into multiple steps to access intermediate results if desired.
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ object SettingsTest extends Properties("settings") {
|
|||
List(scoped0, scoped1) <- chk :: scopedKeys sliding 2
|
||||
nextInit = if (scoped0 == chk) chk
|
||||
else (scoped0 zipWith chk) { (p, _) => p + 1 }
|
||||
} yield derive(setting(scoped1, nextInit))
|
||||
).toSeq
|
||||
} yield derive(setting(scoped1, nextInit))).toSeq
|
||||
|
||||
{
|
||||
// Note: This causes a cycle refernec error, quite frequently.
|
||||
|
|
@ -96,8 +95,7 @@ object SettingsTest extends Properties("settings") {
|
|||
setting(b, value(6)),
|
||||
derive(setting(b, a)),
|
||||
setting(a, value(5)),
|
||||
setting(b, value(8))
|
||||
)
|
||||
setting(b, value(8)))
|
||||
val ev = evaluate(settings)
|
||||
checkKey(a, Some(5), ev) && checkKey(b, Some(8), ev)
|
||||
}
|
||||
|
|
@ -106,8 +104,7 @@ object SettingsTest extends Properties("settings") {
|
|||
setting(a, value(3)),
|
||||
setting(b, value(6)),
|
||||
derive(setting(b, a)),
|
||||
setting(a, value(5))
|
||||
)
|
||||
setting(a, value(5)))
|
||||
val ev = evaluate(settings)
|
||||
checkKey(a, Some(5), ev) && checkKey(b, Some(5), ev)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ private object JLine {
|
|||
|
||||
// translate explicit class names to type in order to support
|
||||
// older Scala, since it shaded classes but not the system property
|
||||
private[sbt] def fixTerminalProperty() {
|
||||
private[sbt] def fixTerminalProperty(): Unit = {
|
||||
val newValue = System.getProperty(TerminalProperty) match {
|
||||
case "jline.UnixTerminal" => "unix"
|
||||
case null if System.getProperty("sbt.cygwin") != null => "unix"
|
||||
|
|
@ -75,6 +75,7 @@ private object JLine {
|
|||
case x => x
|
||||
}
|
||||
if (newValue != null) System.setProperty(TerminalProperty, newValue)
|
||||
()
|
||||
}
|
||||
|
||||
// When calling this, ensure that enableEcho has been or will be called.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ final class History private (val lines: IndexedSeq[String], val path: Option[Fil
|
|||
def all: Seq[String] = lines
|
||||
def size = lines.length
|
||||
def !! : Option[String] = !-(1)
|
||||
def apply(i: Int): Option[String] = if (0 <= i && i < size) Some(lines(i)) else { sys.error("Invalid history index: " + i); None }
|
||||
def apply(i: Int): Option[String] = if (0 <= i && i < size) Some(lines(i)) else { sys.error("Invalid history index: " + i) }
|
||||
def !(i: Int): Option[String] = apply(i)
|
||||
|
||||
def !(s: String): Option[String] =
|
||||
|
|
@ -26,14 +26,13 @@ final class History private (val lines: IndexedSeq[String], val path: Option[Fil
|
|||
def !?(s: String): Option[String] = nonEmpty(s) { reversed.drop(1).find(_.contains(s)) }
|
||||
|
||||
private def nonEmpty[T](s: String)(act: => Option[T]): Option[T] =
|
||||
if (s.isEmpty) {
|
||||
if (s.isEmpty)
|
||||
sys.error("No action specified to history command")
|
||||
None
|
||||
} else
|
||||
else
|
||||
act
|
||||
|
||||
def list(historySize: Int, show: Int): Seq[String] =
|
||||
lines.toList.drop((lines.size - historySize) max 0).zipWithIndex.map { case (line, number) => " " + number + " " + line }.takeRight(show max 1)
|
||||
lines.toList.drop(scala.math.max(0, lines.size - historySize)).zipWithIndex.map { case (line, number) => " " + number + " " + line }.takeRight(show max 1)
|
||||
}
|
||||
|
||||
object History {
|
||||
|
|
@ -42,4 +41,4 @@ object History {
|
|||
def number(s: String): Option[Int] =
|
||||
try { Some(s.toInt) }
|
||||
catch { case e: NumberFormatException => None }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ object HistoryCommands {
|
|||
|
||||
val MaxLines = 500
|
||||
lazy val num = token(NatBasic, "<integer>")
|
||||
lazy val last = Last ^^^ { execute(_ !!) }
|
||||
lazy val last = Last ^^^ { execute(_.!!) }
|
||||
lazy val list = ListCommands ~> (num ?? Int.MaxValue) map { show =>
|
||||
(h: History) => { printHistory(h, MaxLines, show); Some(Nil) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ object JLineCompletion {
|
|||
def commonPrefix(s: Seq[String]): String = if (s.isEmpty) "" else s reduceLeft commonPrefix
|
||||
def commonPrefix(a: String, b: String): String =
|
||||
{
|
||||
val len = a.length min b.length
|
||||
val len = scala.math.min(a.length, b.length)
|
||||
@tailrec def loop(i: Int): Int = if (i >= len) len else if (a(i) != b(i)) i else loop(i + 1)
|
||||
a.substring(0, loop(0))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -300,9 +300,9 @@ trait ParserMain {
|
|||
def !!!(msg: String): Parser[A] = onFailure(a, msg)
|
||||
def failOnException: Parser[A] = trapAndFail(a)
|
||||
|
||||
def unary_- = not(a)
|
||||
def unary_- = not(a, "Unexpected: " + a)
|
||||
def &(o: Parser[_]) = and(a, o)
|
||||
def -(o: Parser[_]) = sub(a, o)
|
||||
def -(o: Parser[_]) = and(a, not(o, "Unexpected: " + o))
|
||||
def examples(s: String*): Parser[A] = examples(s.toSet)
|
||||
def examples(s: Set[String], check: Boolean = false): Parser[A] = examples(new FixedSetExamples(s), s.size, check)
|
||||
def examples(s: ExampleSource, maxNumberOfExamples: Int, removeInvalidExamples: Boolean): Parser[A] = Parser.examples(a, s, maxNumberOfExamples, removeInvalidExamples)
|
||||
|
|
@ -366,7 +366,7 @@ trait ParserMain {
|
|||
def result = None
|
||||
def resultEmpty = mkFailure("Expected '" + ch + "'")
|
||||
def derive(c: Char) = if (c == ch) success(ch) else new Invalid(resultEmpty)
|
||||
def completions(level: Int) = Completions.single(Completion.suggestStrict(ch.toString))
|
||||
def completions(level: Int) = Completions.single(Completion.suggestion(ch.toString))
|
||||
override def toString = "'" + ch + "'"
|
||||
}
|
||||
/** Presents a literal String `s` as a Parser that only parses that exact text and provides it as the result.*/
|
||||
|
|
@ -812,7 +812,7 @@ private final class Repeat[T](partial: Option[Parser[T]], repeated: Parser[T], m
|
|||
case None => repeatDerive(c, accumulatedReverse)
|
||||
}
|
||||
|
||||
def repeatDerive(c: Char, accRev: List[T]): Parser[Seq[T]] = repeat(Some(repeated derive c), repeated, (min - 1) max 0, max.decrement, accRev)
|
||||
def repeatDerive(c: Char, accRev: List[T]): Parser[Seq[T]] = repeat(Some(repeated derive c), repeated, scala.math.max(0, min - 1), max.decrement, accRev)
|
||||
|
||||
def completions(level: Int) =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import java.lang.Character.{ getType, MATH_SYMBOL, OTHER_SYMBOL, DASH_PUNCTUATIO
|
|||
/** Provides standard implementations of commonly useful [[Parser]]s. */
|
||||
trait Parsers {
|
||||
/** Matches the end of input, providing no useful result on success. */
|
||||
lazy val EOF = not(any)
|
||||
lazy val EOF = not(any, "Expected EOF")
|
||||
|
||||
/** Parses any single character and provides that character as the result. */
|
||||
lazy val any: Parser[Char] = charClass(_ => true, "any character")
|
||||
|
|
@ -265,4 +265,4 @@ object DefaultParsers extends Parsers with ParserMain {
|
|||
|
||||
/** Returns `true` if `s` parses successfully according to [[ID]].*/
|
||||
def validID(s: String): Boolean = matches(ID, s)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,5 @@ object ProcessError {
|
|||
s.substring(i + 1)
|
||||
loop(s.length - 1)
|
||||
}
|
||||
def pointerSpace(s: String, i: Int): String = (s take i) map { case '\t' => '\t'; case _ => ' ' } mkString;
|
||||
}
|
||||
def pointerSpace(s: String, i: Int): String = (s take i) map { case '\t' => '\t'; case _ => ' ' } mkString ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package sbt.complete
|
||||
|
||||
import Completion.{ displayStrict, token => ctoken, tokenDisplay }
|
||||
import Completion.{ token => ctoken, tokenDisplay }
|
||||
|
||||
sealed trait TokenCompletions {
|
||||
def hideWhen(f: Int => Boolean): TokenCompletions
|
||||
|
|
@ -24,7 +24,7 @@ object TokenCompletions {
|
|||
val default: TokenCompletions = mapDelegateCompletions((seen, level, c) => ctoken(seen, c.append))
|
||||
|
||||
def displayOnly(msg: String): TokenCompletions = new Fixed {
|
||||
def completions(seen: String, level: Int) = Completions.single(displayStrict(msg))
|
||||
def completions(seen: String, level: Int) = Completions.single(Completion.displayOnly(msg))
|
||||
}
|
||||
def overrideDisplay(msg: String): TokenCompletions = mapDelegateCompletions((seen, level, c) => tokenDisplay(display = msg, append = c.append))
|
||||
|
||||
|
|
@ -34,4 +34,4 @@ object TokenCompletions {
|
|||
def mapDelegateCompletions(f: (String, Int, Completion) => Completion): TokenCompletions = new Delegating {
|
||||
def completions(seen: String, level: Int, delegate: Completions) = Completions(delegate.get.map(c => f(seen, level, c)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ final case class Finite(value: Int) extends UpperBound {
|
|||
def >=(min: Int) = value >= min
|
||||
def isOne = value == 1
|
||||
def isZero = value == 0
|
||||
def decrement = Finite((value - 1) max 0)
|
||||
def decrement = Finite(scala.math.max(0, value - 1))
|
||||
def isInfinite = false
|
||||
override def toString = value.toString
|
||||
}
|
||||
object UpperBound {
|
||||
implicit def intToFinite(i: Int): Finite = Finite(i)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,13 +109,13 @@ object ParserTest extends Properties("Completing Parser") {
|
|||
property("repeatDep accepts two tokens") = matches(repeat, colors.toSeq.take(2).mkString(" "))
|
||||
}
|
||||
object ParserExample {
|
||||
val ws = charClass(_.isWhitespace)+
|
||||
val notws = charClass(!_.isWhitespace)+
|
||||
val ws = charClass(_.isWhitespace).+
|
||||
val notws = charClass(!_.isWhitespace).+
|
||||
|
||||
val name = token("test")
|
||||
val options = (ws ~> token("quick" | "failed" | "new"))*
|
||||
val options = (ws ~> token("quick" | "failed" | "new")).*
|
||||
val exampleSet = Set("am", "is", "are", "was", "were")
|
||||
val include = (ws ~> token(examples(notws.string, new FixedSetExamples(exampleSet), exampleSet.size, false)))*
|
||||
val include = (ws ~> token(examples(notws.string, new FixedSetExamples(exampleSet), exampleSet.size, false))).*
|
||||
|
||||
val t = name ~ options ~ include
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ class ParserWithExamplesTest extends Specification {
|
|||
"use the delegate parser to remove invalid examples" in new parserWithValidExamples {
|
||||
val validCompletions = Completions(Set(
|
||||
suggestion("blue"),
|
||||
suggestion("red")
|
||||
))
|
||||
suggestion("red")))
|
||||
parserWithExamples.completions(0) shouldEqual validCompletions
|
||||
}
|
||||
}
|
||||
|
|
@ -26,8 +25,7 @@ class ParserWithExamplesTest extends Specification {
|
|||
"listing valid completions in a derived parser" should {
|
||||
"produce only valid examples that start with the character of the derivation" in new parserWithValidExamples {
|
||||
val derivedCompletions = Completions(Set(
|
||||
suggestion("lue")
|
||||
))
|
||||
suggestion("lue")))
|
||||
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
|
||||
}
|
||||
}
|
||||
|
|
@ -43,8 +41,7 @@ class ParserWithExamplesTest extends Specification {
|
|||
"produce only examples that start with the character of the derivation" in new parserWithAllExamples {
|
||||
val derivedCompletions = Completions(Set(
|
||||
suggestion("lue"),
|
||||
suggestion("lock")
|
||||
))
|
||||
suggestion("lock")))
|
||||
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
|
||||
}
|
||||
}
|
||||
|
|
@ -56,8 +53,8 @@ class ParserWithExamplesTest extends Specification {
|
|||
class parserWithAllExamples extends parser(removeInvalidExamples = false)
|
||||
|
||||
case class parser(examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"),
|
||||
maxNumberOfExamples: Int = 25,
|
||||
removeInvalidExamples: Boolean) extends Scope {
|
||||
maxNumberOfExamples: Int = 25,
|
||||
removeInvalidExamples: Boolean) extends Scope {
|
||||
|
||||
import DefaultParsers._
|
||||
|
||||
|
|
@ -66,8 +63,7 @@ class ParserWithExamplesTest extends Specification {
|
|||
colorParser,
|
||||
FixedSetExamples(examples),
|
||||
maxNumberOfExamples,
|
||||
removeInvalidExamples
|
||||
)
|
||||
removeInvalidExamples)
|
||||
}
|
||||
|
||||
case class GrowableSourceOfExamples() extends Iterable[String] {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger {
|
|||
buffer += new SetLevel(newLevel)
|
||||
else
|
||||
delegate.setLevel(newLevel)
|
||||
()
|
||||
}
|
||||
override def setSuccessEnabled(flag: Boolean): Unit = synchronized {
|
||||
super.setSuccessEnabled(flag)
|
||||
|
|
@ -59,6 +60,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger {
|
|||
buffer += new SetSuccess(flag)
|
||||
else
|
||||
delegate.setSuccessEnabled(flag)
|
||||
()
|
||||
}
|
||||
override def setTrace(level: Int): Unit = synchronized {
|
||||
super.setTrace(level)
|
||||
|
|
@ -66,6 +68,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger {
|
|||
buffer += new SetTrace(level)
|
||||
else
|
||||
delegate.setTrace(level)
|
||||
()
|
||||
}
|
||||
|
||||
def trace(t: => Throwable): Unit =
|
||||
|
|
@ -79,6 +82,7 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger {
|
|||
buffer ++= events
|
||||
else
|
||||
delegate.logAll(events)
|
||||
()
|
||||
}
|
||||
def control(event: ControlEvent.Value, message: => String): Unit =
|
||||
doBufferable(Level.Info, new ControlEvent(event, message), _.control(event, message))
|
||||
|
|
@ -91,5 +95,6 @@ class BufferedLogger(delegate: AbstractLogger) extends BasicLogger {
|
|||
else
|
||||
doUnbuffered(delegate)
|
||||
}
|
||||
()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ object ConsoleLogger {
|
|||
*
|
||||
* cf. http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes
|
||||
*/
|
||||
@deprecated("No longer public.", "0.13.8")
|
||||
def isEscapeTerminator(c: Char): Boolean =
|
||||
private[sbt] def isEscapeTerminator(c: Char): Boolean =
|
||||
c >= '@' && c <= '~'
|
||||
|
||||
/**
|
||||
|
|
@ -83,9 +82,10 @@ object ConsoleLogger {
|
|||
}
|
||||
private[this] def nextESC(s: String, start: Int, sb: java.lang.StringBuilder): Unit = {
|
||||
val escIndex = s.indexOf(ESC, start)
|
||||
if (escIndex < 0)
|
||||
if (escIndex < 0) {
|
||||
sb.append(s, start, s.length)
|
||||
else {
|
||||
()
|
||||
} else {
|
||||
sb.append(s, start, escIndex)
|
||||
val next: Int =
|
||||
// If it's a CSI we skip past it and then look for a terminator.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ object ConsoleOut {
|
|||
val lockObject = System.out
|
||||
private[this] var last: Option[String] = None
|
||||
private[this] var current = new java.lang.StringBuffer
|
||||
def print(s: String): Unit = synchronized { current.append(s) }
|
||||
def print(s: String): Unit = synchronized { current.append(s); () }
|
||||
def println(s: String): Unit = synchronized { current.append(s); println() }
|
||||
def println(): Unit = synchronized {
|
||||
val s = current.toString
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ class LoggerWriter(delegate: Logger, unbufferedLevel: Option[Level.Value], nl: S
|
|||
}
|
||||
}
|
||||
private[this] def log(s: String): Unit = unbufferedLevel match {
|
||||
case None => lines += s
|
||||
case None =>
|
||||
lines += s; ()
|
||||
case Some(level) => delegate.log(level, s)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ object StackTrace {
|
|||
b.append("\tat ")
|
||||
b.append(e)
|
||||
b.append('\n')
|
||||
()
|
||||
}
|
||||
|
||||
if (!first)
|
||||
|
|
@ -59,4 +60,4 @@ object StackTrace {
|
|||
b.toString()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ object Escape {
|
|||
{
|
||||
val builder = new StringBuilder(s.length)
|
||||
for (c <- s) {
|
||||
def escaped = pad(c.toInt.toHexString.toUpperCase, 4, '0')
|
||||
val char = c.toInt
|
||||
def escaped = pad(char.toHexString.toUpperCase, 4, '0')
|
||||
if (c < 20) builder.append("\\u").append(escaped) else builder.append(c)
|
||||
}
|
||||
builder.toString
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@ object LogicTest extends Properties("Logic") {
|
|||
case Right(res) => false
|
||||
case Left(err: Logic.CyclicNegation) => true
|
||||
case Left(err) => sys.error(s"Expected cyclic error, got: $err")
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
def expect(result: Either[LogicException, Matched], expected: Set[Atom]) = result match {
|
||||
case Left(err) => false
|
||||
case Right(res) =>
|
||||
val actual = res.provenSet
|
||||
(actual == expected) || sys.error(s"Expected to prove $expected, but actually proved $actual")
|
||||
if (actual != expected)
|
||||
sys.error(s"Expected to prove $expected, but actually proved $actual")
|
||||
else
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,4 +67,4 @@ private class CompoundChangeReport[T](a: ChangeReport[T], b: ChangeReport[T]) ex
|
|||
lazy val modified = a.modified ++ b.modified
|
||||
lazy val added = a.added ++ b.added
|
||||
lazy val removed = a.removed ++ b.removed
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ object Dependencies {
|
|||
lazy val scala210 = "2.10.5"
|
||||
lazy val scala211 = "2.11.7"
|
||||
|
||||
val bootstrapSbtVersion = "0.13.8"
|
||||
|
||||
lazy val sbtIO = "org.scala-sbt" %% "io" % "1.0.0-M1"
|
||||
lazy val jline = "jline" % "jline" % "2.11"
|
||||
lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.2"
|
||||
|
|
|
|||
Loading…
Reference in New Issue