mirror of https://github.com/sbt/sbt.git
Add recommended compiler flags, fix most of the warnings
This commit is contained in:
parent
c0f55127db
commit
6c7e69497f
|
|
@ -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); () }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ object LogicTest extends Properties("Logic") {
|
|||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue