mirror of https://github.com/sbt/sbt.git
Replace procedure syntax by explicit Unit annotation
This commit is contained in:
parent
d1e719b07c
commit
404c5e8fc6
|
|
@ -40,7 +40,7 @@ object Cache extends CacheImplicits {
|
|||
println(label + ".read: " + v)
|
||||
v
|
||||
}
|
||||
def write(to: Out, v: Internal) {
|
||||
def write(to: Out, v: Internal): Unit = {
|
||||
println(label + ".write: " + v)
|
||||
c.write(to, v)
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ trait BasicCacheImplicits {
|
|||
if (left <= 0) acc.reverse else next(left - 1, t.read(from) :: acc)
|
||||
next(size, Nil)
|
||||
}
|
||||
def write(to: Out, vs: Internal) {
|
||||
def write(to: Out, vs: Internal): Unit = {
|
||||
val size = vs.length
|
||||
IntFormat.writes(to, size)
|
||||
for (v <- vs) t.write(to, v)
|
||||
|
|
@ -165,7 +165,7 @@ trait HListCacheImplicits {
|
|||
val t = tail.read(from)
|
||||
(h, t)
|
||||
}
|
||||
def write(to: Out, j: Internal) {
|
||||
def write(to: Out, j: Internal): Unit = {
|
||||
head.write(to, j._1)
|
||||
tail.write(to, j._2)
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ trait HListCacheImplicits {
|
|||
val t = tail.reads(from)
|
||||
HCons(h, t)
|
||||
}
|
||||
def writes(to: Out, hc: H :+: T) {
|
||||
def writes(to: Out, hc: H :+: T): Unit = {
|
||||
head.writes(to, hc.head)
|
||||
tail.writes(to, hc.tail)
|
||||
}
|
||||
|
|
@ -205,8 +205,8 @@ trait UnionImplicits {
|
|||
val value = cache.read(in)
|
||||
new Found[cache.Internal](cache, clazz, value, index)
|
||||
}
|
||||
def write(to: Out, i: Internal) {
|
||||
def write0[I](f: Found[I]) {
|
||||
def write(to: Out, i: Internal): Unit = {
|
||||
def write0[I](f: Found[I]): Unit = {
|
||||
ByteFormat.writes(to, f.index.toByte)
|
||||
f.cache.write(to, f.value)
|
||||
}
|
||||
|
|
@ -245,4 +245,4 @@ trait UnionImplicits {
|
|||
def at(i: Int): (InputCache[_ <: UB], Class[_])
|
||||
def find(forValue: UB): Found[_]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,22 +13,22 @@ class TestCallback(override val nameHashing: Boolean = false) extends AnalysisCa
|
|||
val usedNames = scala.collection.mutable.Map.empty[File, Set[String]].withDefaultValue(Set.empty)
|
||||
val apis: scala.collection.mutable.Map[File, SourceAPI] = scala.collection.mutable.Map.empty
|
||||
|
||||
def sourceDependency(dependsOn: File, source: File, inherited: Boolean) {
|
||||
def sourceDependency(dependsOn: File, source: File, inherited: Boolean): Unit = {
|
||||
val context = if(inherited) DependencyByInheritance else DependencyByMemberRef
|
||||
sourceDependency(dependsOn, source, context)
|
||||
}
|
||||
def sourceDependency(dependsOn: File, source: File, context: DependencyContext) { sourceDependencies += ((dependsOn, source, context)) }
|
||||
def binaryDependency(binary: File, name: String, source: File, inherited: Boolean) {
|
||||
def sourceDependency(dependsOn: File, source: File, context: DependencyContext): Unit = { sourceDependencies += ((dependsOn, source, context)) }
|
||||
def binaryDependency(binary: File, name: String, source: File, inherited: Boolean): Unit = {
|
||||
val context = if(inherited) DependencyByInheritance else DependencyByMemberRef
|
||||
binaryDependency(binary, name, source, context)
|
||||
}
|
||||
def binaryDependency(binary: File, name: String, source: File, context: DependencyContext) { binaryDependencies += ((binary, name, source, context)) }
|
||||
def generatedClass(source: File, module: File, name: String) { products += ((source, module, name)) }
|
||||
def binaryDependency(binary: File, name: String, source: File, context: DependencyContext): Unit = { binaryDependencies += ((binary, name, source, context)) }
|
||||
def generatedClass(source: File, module: File, name: String): Unit = { products += ((source, module, name)) }
|
||||
|
||||
def usedName(source: File, name: String) { usedNames(source) += name }
|
||||
def usedName(source: File, name: String): Unit = { usedNames(source) += name }
|
||||
def api(source: File, sourceAPI: SourceAPI): Unit = {
|
||||
assert(!apis.contains(source), s"The `api` method should be called once per source file: $source")
|
||||
apis(source) = sourceAPI
|
||||
}
|
||||
def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean) {}
|
||||
def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean): Unit = ()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
|||
|
||||
// Workaround copied from scala/async:can be removed once https://github.com/scala/scala/pull/3179 is merged.
|
||||
private[this] class ChangeOwnerAndModuleClassTraverser(oldowner: global.Symbol, newowner: global.Symbol) extends global.ChangeOwnerTraverser(oldowner, newowner) {
|
||||
override def traverse(tree: global.Tree) {
|
||||
override def traverse(tree: global.Tree): Unit = {
|
||||
tree match {
|
||||
case _: global.DefTree => change(tree.symbol.moduleClass)
|
||||
case _ =>
|
||||
|
|
|
|||
|
|
@ -21,18 +21,18 @@ object Dag {
|
|||
val finished = (new java.util.LinkedHashSet[T]).asScala
|
||||
|
||||
def visitAll(nodes: Iterable[T]) = nodes foreach visit
|
||||
def visit(node: T) {
|
||||
def visit(node: T): Unit = {
|
||||
if (!discovered(node)) {
|
||||
discovered(node) = true;
|
||||
try { visitAll(dependencies(node)); } catch { case c: Cyclic => throw node :: c }
|
||||
finished += node;
|
||||
finished += node
|
||||
} else if (!finished(node))
|
||||
throw new Cyclic(node)
|
||||
}
|
||||
|
||||
visitAll(nodes);
|
||||
visitAll(nodes)
|
||||
|
||||
finished.toList;
|
||||
finished.toList
|
||||
}
|
||||
// doesn't check for cycles
|
||||
def topologicalSortUnchecked[T](node: T)(dependencies: T => Iterable[T]): List[T] = topologicalSortUnchecked(node :: Nil)(dependencies)
|
||||
|
|
@ -43,11 +43,11 @@ object Dag {
|
|||
var finished: List[T] = Nil
|
||||
|
||||
def visitAll(nodes: Iterable[T]) = nodes foreach visit
|
||||
def visit(node: T) {
|
||||
def visit(node: T): Unit = {
|
||||
if (!discovered(node)) {
|
||||
discovered(node) = true;
|
||||
discovered(node) = true
|
||||
visitAll(dependencies(node))
|
||||
finished ::= node;
|
||||
finished ::= node
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ abstract class EvaluateSettings[Scope] {
|
|||
final def isNew: Boolean = synchronized { state == New }
|
||||
final def isCalling: Boolean = synchronized { state == Calling }
|
||||
final def registerIfNew(): Unit = synchronized { if (state == New) register() }
|
||||
private[this] def register() {
|
||||
private[this] def register(): Unit = {
|
||||
assert(state == New, "Already registered and: " + toString)
|
||||
val deps = dependsOn
|
||||
blockedOn = deps.size - deps.count(_.doneOrBlock(this))
|
||||
|
|
@ -133,12 +133,12 @@ abstract class EvaluateSettings[Scope] {
|
|||
if (blockedOn == 0) schedule()
|
||||
}
|
||||
final def evaluate(): Unit = synchronized { evaluate0() }
|
||||
protected final def makeCall(source: BindNode[_, T], target: INode[T]) {
|
||||
protected final def makeCall(source: BindNode[_, T], target: INode[T]): Unit = {
|
||||
assert(state == Ready, "Invalid state for call to makeCall: " + toString)
|
||||
state = Calling
|
||||
target.call(source)
|
||||
}
|
||||
protected final def setValue(v: T) {
|
||||
protected final def setValue(v: T): Unit = {
|
||||
assert(state != Evaluated, "Already evaluated (trying to set value to " + v + "): " + toString)
|
||||
if (v == null) sys.error("Setting value cannot be null: " + keyString)
|
||||
value = v
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ object Param {
|
|||
type T = s
|
||||
def in = a
|
||||
private var r: B[T] = _
|
||||
def ret(b: B[T]) { r = b }
|
||||
def ret(b: B[T]): Unit = { r = b }
|
||||
def ret: B[T] = r
|
||||
}
|
||||
p(v)
|
||||
v.ret
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ trait Init[Scope] {
|
|||
|
||||
// set of defined scoped keys, used to ensure a derived setting is only added if all dependencies are present
|
||||
val defined = new mutable.HashSet[ScopedKey[_]]
|
||||
def addDefs(ss: Seq[Setting[_]]) { for (s <- ss) defined += s.key }
|
||||
def addDefs(ss: Seq[Setting[_]]): Unit = { for (s <- ss) defined += s.key }
|
||||
addDefs(defs)
|
||||
|
||||
// true iff the scoped key is in `defined`, taking delegation into account
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ object JLineCompletion {
|
|||
!(common.isEmpty && display.isEmpty)
|
||||
}
|
||||
|
||||
def appendCompletion(common: String, reader: ConsoleReader) {
|
||||
def appendCompletion(common: String, reader: ConsoleReader): Unit = {
|
||||
reader.getCursorBuffer.write(common)
|
||||
reader.redrawLine()
|
||||
}
|
||||
|
|
@ -113,16 +113,16 @@ object JLineCompletion {
|
|||
* `display` is assumed to be the exact strings requested to be displayed.
|
||||
* In particular, duplicates should have been removed already.
|
||||
*/
|
||||
def showCompletions(display: Seq[String], reader: ConsoleReader) {
|
||||
def showCompletions(display: Seq[String], reader: ConsoleReader): Unit = {
|
||||
printCompletions(display, reader)
|
||||
reader.drawLine()
|
||||
}
|
||||
def printCompletions(cs: Seq[String], reader: ConsoleReader) {
|
||||
def printCompletions(cs: Seq[String], reader: ConsoleReader): Unit = {
|
||||
val print = shouldPrint(cs, reader)
|
||||
reader.println()
|
||||
if (print) printLinesAndColumns(cs, reader)
|
||||
}
|
||||
def printLinesAndColumns(cs: Seq[String], reader: ConsoleReader) {
|
||||
def printLinesAndColumns(cs: Seq[String], reader: ConsoleReader): Unit = {
|
||||
val (lines, columns) = cs partition hasNewline
|
||||
for (line <- lines) {
|
||||
reader.print(line)
|
||||
|
|
@ -153,4 +153,4 @@ object JLineCompletion {
|
|||
@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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ object Parser extends ParserMain {
|
|||
def mkFailure(error: => String, definitive: Boolean = false): Failure = new Failure(error :: Nil, definitive)
|
||||
|
||||
@deprecated("This method is deprecated and will be removed in the next major version. Use the parser directly to check for invalid completions.", since = "0.13.2")
|
||||
def checkMatches(a: Parser[_], completions: Seq[String]) {
|
||||
def checkMatches(a: Parser[_], completions: Seq[String]): Unit = {
|
||||
val bad = completions.filter(apply(a)(_).resultEmpty.isFailure)
|
||||
if (bad.nonEmpty) sys.error("Invalid example completions: " + bad.mkString("'", "', '", "'"))
|
||||
}
|
||||
|
|
@ -845,4 +845,4 @@ private final class Repeat[T](partial: Option[Parser[T]], repeated: Parser[T], m
|
|||
for (value <- repeated.resultEmpty) yield makeList(min, value)
|
||||
}
|
||||
override def toString = "repeat(" + min + "," + max + "," + partial + "," + repeated + ")"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ object JLineTest {
|
|||
}
|
||||
|
||||
val parsers = Map("1" -> one, "2" -> two, "3" -> three, "4" -> four, "5" -> five)
|
||||
def main(args: Array[String]) {
|
||||
def main(args: Array[String]): Unit = {
|
||||
import jline.TerminalFactory
|
||||
import jline.console.ConsoleReader
|
||||
val reader = new ConsoleReader()
|
||||
|
|
@ -23,7 +23,7 @@ object JLineTest {
|
|||
|
||||
val parser = parsers(args(0))
|
||||
JLineCompletion.installCustomCompletor(reader, parser)
|
||||
def loop() {
|
||||
def loop(): Unit = {
|
||||
val line = reader.readLine("> ")
|
||||
if (line ne null) {
|
||||
println("Result: " + apply(parser)(line).resultEmpty)
|
||||
|
|
@ -130,7 +130,7 @@ object ParserExample {
|
|||
println(apply(t)("test w").resultEmpty)
|
||||
println(apply(t)("test was were").resultEmpty)
|
||||
|
||||
def run(n: Int) {
|
||||
def run(n: Int): Unit = {
|
||||
val a = 'a'.id
|
||||
val aq = a.?
|
||||
val aqn = repeat(aq, min = n, max = n)
|
||||
|
|
@ -140,9 +140,9 @@ object ParserExample {
|
|||
def r = apply(ann)("a" * (n * 2)).resultEmpty
|
||||
println(r.isValid)
|
||||
}
|
||||
def run2(n: Int) {
|
||||
def run2(n: Int): Unit = {
|
||||
val ab = "ab".?.*
|
||||
val r = apply(ab)("a" * n).resultEmpty
|
||||
println(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ object ConsoleLogger {
|
|||
nextESC(s, 0, sb)
|
||||
sb.toString
|
||||
}
|
||||
private[this] def nextESC(s: String, start: Int, sb: java.lang.StringBuilder) {
|
||||
private[this] def nextESC(s: String, start: Int, sb: java.lang.StringBuilder): Unit = {
|
||||
val escIndex = s.indexOf(ESC, start)
|
||||
if (escIndex < 0)
|
||||
sb.append(s, start, s.length)
|
||||
|
|
@ -167,7 +167,7 @@ class ConsoleLogger private[ConsoleLogger] (val out: ConsoleOut, override val an
|
|||
}
|
||||
def successLabelColor = GREEN
|
||||
def successMessageColor = RESET
|
||||
override def success(message: => String) {
|
||||
override def success(message: => String): Unit = {
|
||||
if (successEnabled)
|
||||
log(successLabelColor, Level.SuccessLabel, successMessageColor, message)
|
||||
}
|
||||
|
|
@ -180,13 +180,13 @@ class ConsoleLogger private[ConsoleLogger] (val out: ConsoleOut, override val an
|
|||
for (msg <- suppressedMessage(new SuppressedTraceContext(traceLevel, ansiCodesSupported && useColor)))
|
||||
printLabeledLine(labelColor(Level.Error), "trace", messageColor(Level.Error), msg)
|
||||
}
|
||||
def log(level: Level.Value, message: => String) {
|
||||
def log(level: Level.Value, message: => String): Unit = {
|
||||
if (atLevel(level))
|
||||
log(labelColor(level), level.toString, messageColor(level), message)
|
||||
}
|
||||
private def reset(): Unit = setColor(RESET)
|
||||
|
||||
private def setColor(color: String) {
|
||||
private def setColor(color: String): Unit = {
|
||||
if (ansiCodesSupported && useColor)
|
||||
out.lockObject.synchronized { out.print(color) }
|
||||
}
|
||||
|
|
@ -210,6 +210,6 @@ class ConsoleLogger private[ConsoleLogger] (val out: ConsoleOut, override val an
|
|||
}
|
||||
|
||||
def logAll(events: Seq[LogEvent]) = out.lockObject.synchronized { events.foreach(log) }
|
||||
def control(event: ControlEvent.Value, message: => String) { log(labelColor(Level.Info), Level.Info.toString, BLUE, message) }
|
||||
def control(event: ControlEvent.Value, message: => String): Unit = log(labelColor(Level.Info), Level.Info.toString, BLUE, message)
|
||||
}
|
||||
final class SuppressedTraceContext(val traceLevel: Int, val useColor: Boolean)
|
||||
|
|
|
|||
|
|
@ -9,23 +9,23 @@ package sbt
|
|||
*/
|
||||
class FilterLogger(delegate: AbstractLogger) extends BasicLogger {
|
||||
override lazy val ansiCodesSupported = delegate.ansiCodesSupported
|
||||
def trace(t: => Throwable) {
|
||||
def trace(t: => Throwable): Unit = {
|
||||
if (traceEnabled)
|
||||
delegate.trace(t)
|
||||
}
|
||||
override def setSuccessEnabled(flag: Boolean) { delegate.setSuccessEnabled(flag) }
|
||||
override def setSuccessEnabled(flag: Boolean): Unit = delegate.setSuccessEnabled(flag)
|
||||
override def successEnabled = delegate.successEnabled
|
||||
override def setTrace(level: Int) { delegate.setTrace(level) }
|
||||
override def setTrace(level: Int): Unit = delegate.setTrace(level)
|
||||
override def getTrace = delegate.getTrace
|
||||
def log(level: Level.Value, message: => String) {
|
||||
def log(level: Level.Value, message: => String): Unit = {
|
||||
if (atLevel(level))
|
||||
delegate.log(level, message)
|
||||
}
|
||||
def success(message: => String) {
|
||||
def success(message: => String): Unit = {
|
||||
if (successEnabled)
|
||||
delegate.success(message)
|
||||
}
|
||||
def control(event: ControlEvent.Value, message: => String) {
|
||||
def control(event: ControlEvent.Value, message: => String): Unit = {
|
||||
if (atLevel(Level.Info))
|
||||
delegate.control(event, message)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ package sbt
|
|||
/** Promotes the simple Logger interface to the full AbstractLogger interface. */
|
||||
class FullLogger(delegate: Logger) extends BasicLogger {
|
||||
override val ansiCodesSupported: Boolean = delegate.ansiCodesSupported
|
||||
def trace(t: => Throwable) {
|
||||
def trace(t: => Throwable): Unit = {
|
||||
if (traceEnabled)
|
||||
delegate.trace(t)
|
||||
}
|
||||
def log(level: Level.Value, message: => String) {
|
||||
def log(level: Level.Value, message: => String): Unit = {
|
||||
if (atLevel(level))
|
||||
delegate.log(level, message)
|
||||
}
|
||||
|
|
@ -27,4 +27,4 @@ object FullLogger {
|
|||
case d: AbstractLogger => d
|
||||
case _ => new FullLogger(delegate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class LoggerWriter(delegate: Logger, unbufferedLevel: Option[Level.Value], nl: S
|
|||
process()
|
||||
}
|
||||
|
||||
private[this] def process() {
|
||||
private[this] def process(): Unit = {
|
||||
val i = buffer.indexOf(nl)
|
||||
if (i >= 0) {
|
||||
log(buffer.substring(0, i))
|
||||
|
|
@ -46,4 +46,4 @@ class LoggerWriter(delegate: Logger, unbufferedLevel: Option[Level.Value], nl: S
|
|||
case None => lines += s
|
||||
case Some(level) => delegate.log(level, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,24 +11,24 @@ class MultiLogger(delegates: List[AbstractLogger]) extends BasicLogger {
|
|||
private[this] lazy val allSupportCodes = delegates forall supported
|
||||
private[this] def supported = (_: AbstractLogger).ansiCodesSupported
|
||||
|
||||
override def setLevel(newLevel: Level.Value) {
|
||||
override def setLevel(newLevel: Level.Value): Unit = {
|
||||
super.setLevel(newLevel)
|
||||
dispatch(new SetLevel(newLevel))
|
||||
}
|
||||
override def setTrace(level: Int) {
|
||||
override def setTrace(level: Int): Unit = {
|
||||
super.setTrace(level)
|
||||
dispatch(new SetTrace(level))
|
||||
}
|
||||
override def setSuccessEnabled(flag: Boolean) {
|
||||
override def setSuccessEnabled(flag: Boolean): Unit = {
|
||||
super.setSuccessEnabled(flag)
|
||||
dispatch(new SetSuccess(flag))
|
||||
}
|
||||
def trace(t: => Throwable) { dispatch(new Trace(t)) }
|
||||
def log(level: Level.Value, message: => String) { dispatch(new Log(level, message)) }
|
||||
def success(message: => String) { dispatch(new Success(message)) }
|
||||
def logAll(events: Seq[LogEvent]) { delegates.foreach(_.logAll(events)) }
|
||||
def control(event: ControlEvent.Value, message: => String) { delegates.foreach(_.control(event, message)) }
|
||||
private[this] def dispatch(event: LogEvent) {
|
||||
def trace(t: => Throwable): Unit = dispatch(new Trace(t))
|
||||
def log(level: Level.Value, message: => String): Unit = dispatch(new Log(level, message))
|
||||
def success(message: => String): Unit = dispatch(new Success(message))
|
||||
def logAll(events: Seq[LogEvent]): Unit = delegates.foreach(_.logAll(events))
|
||||
def control(event: ControlEvent.Value, message: => String): Unit = delegates.foreach(_.control(event, message))
|
||||
private[this] def dispatch(event: LogEvent): Unit = {
|
||||
val plainEvent = if (allSupportCodes) event else removeEscapes(event)
|
||||
for (d <- delegates)
|
||||
if (d.ansiCodesSupported)
|
||||
|
|
@ -47,4 +47,4 @@ class MultiLogger(delegates: List[AbstractLogger]) extends BasicLogger {
|
|||
case _: Trace | _: SetLevel | _: SetTrace | _: SetSuccess => event
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ object LogWriterTest extends Properties("Log Writer") {
|
|||
* represented as separately written segments (ToLog instances). ToLog.`byCharacter`
|
||||
* indicates whether to write the segment by character (true) or all at once (false)
|
||||
*/
|
||||
def logLines(writer: Writer, lines: List[List[ToLog]], newLine: String) {
|
||||
def logLines(writer: Writer, lines: List[List[ToLog]], newLine: String): Unit = {
|
||||
for (line <- lines; section <- line) {
|
||||
val content = section.content
|
||||
val normalized = Escape.newline(content, newLine)
|
||||
|
|
@ -141,10 +141,10 @@ final class RecordingLogger extends BasicLogger {
|
|||
def getEvents = events.reverse
|
||||
|
||||
override def ansiCodesSupported = true
|
||||
def trace(t: => Throwable) { events ::= new Trace(t) }
|
||||
def log(level: Level.Value, message: => String) { events ::= new Log(level, message) }
|
||||
def success(message: => String) { events ::= new Success(message) }
|
||||
def logAll(es: Seq[LogEvent]) { events :::= es.toList }
|
||||
def control(event: ControlEvent.Value, message: => String) { events ::= new ControlEvent(event, message) }
|
||||
def trace(t: => Throwable): Unit = { events ::= new Trace(t) }
|
||||
def log(level: Level.Value, message: => String): Unit = { events ::= new Log(level, message) }
|
||||
def success(message: => String): Unit = { events ::= new Success(message) }
|
||||
def logAll(es: Seq[LogEvent]): Unit = { events :::= es.toList }
|
||||
def control(event: ControlEvent.Value, message: => String): Unit = { events ::= new ControlEvent(event, message) }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ object BasicIO {
|
|||
processLinesFully(processLine)(reader.readLine)
|
||||
reader.close()
|
||||
}
|
||||
def processLinesFully(processLine: String => Unit)(readLine: () => String) {
|
||||
def readFully() {
|
||||
def processLinesFully(processLine: String => Unit)(readLine: () => String): Unit = {
|
||||
def readFully(): Unit = {
|
||||
val line = readLine()
|
||||
if (line != null) {
|
||||
processLine(line)
|
||||
|
|
@ -68,7 +68,7 @@ object BasicIO {
|
|||
}
|
||||
readFully()
|
||||
}
|
||||
def connectToIn(o: OutputStream) { transferFully(Uncloseable protect System.in, o) }
|
||||
def connectToIn(o: OutputStream): Unit = transferFully(Uncloseable protect System.in, o)
|
||||
def input(connect: Boolean): OutputStream => Unit = if (connect) connectToIn else closeOut
|
||||
def standard(connectInput: Boolean): ProcessIO = standard(input(connectInput), inheritInput(connectInput))
|
||||
def standard(in: OutputStream => Unit, inheritIn: JProcessBuilder => Boolean): ProcessIO = new ProcessIO(in, toStdOut, toStdErr, inheritIn)
|
||||
|
|
@ -87,10 +87,10 @@ object BasicIO {
|
|||
buffer.append(Newline)
|
||||
}
|
||||
|
||||
private[this] def transferFullyImpl(in: InputStream, out: OutputStream) {
|
||||
private[this] def transferFullyImpl(in: InputStream, out: OutputStream): Unit = {
|
||||
val continueCount = 1 //if(in.isInstanceOf[PipedInputStream]) 1 else 0
|
||||
val buffer = new Array[Byte](BufferSize)
|
||||
def read() {
|
||||
def read(): Unit = {
|
||||
val byteCount = in.read(buffer)
|
||||
if (byteCount >= continueCount) {
|
||||
out.write(buffer, 0, byteCount)
|
||||
|
|
@ -189,7 +189,7 @@ private abstract class BasicProcess extends Process {
|
|||
}
|
||||
|
||||
private abstract class CompoundProcess extends BasicProcess {
|
||||
def destroy() { destroyer() }
|
||||
def destroy(): Unit = destroyer()
|
||||
def exitValue() = getExitValue().getOrElse(sys.error("No exit code: process destroyed."))
|
||||
|
||||
def start() = getExitValue
|
||||
|
|
@ -294,7 +294,7 @@ private class PipedProcesses(a: ProcessBuilder, b: ProcessBuilder, defaultIO: Pr
|
|||
}
|
||||
}
|
||||
private class PipeSource(currentSource: SyncVar[Option[InputStream]], pipe: PipedOutputStream, label: => String) extends Thread {
|
||||
final override def run() {
|
||||
final override def run(): Unit = {
|
||||
currentSource.get match {
|
||||
case Some(source) =>
|
||||
try { BasicIO.transferFully(source, pipe) }
|
||||
|
|
@ -311,7 +311,7 @@ private class PipeSource(currentSource: SyncVar[Option[InputStream]], pipe: Pipe
|
|||
}
|
||||
}
|
||||
private class PipeSink(pipe: PipedInputStream, currentSink: SyncVar[Option[OutputStream]], label: => String) extends Thread {
|
||||
final override def run() {
|
||||
final override def run(): Unit = {
|
||||
currentSink.get match {
|
||||
case Some(sink) =>
|
||||
try { BasicIO.transferFully(pipe, sink) }
|
||||
|
|
@ -338,7 +338,7 @@ private[sbt] class DummyProcessBuilder(override val toString: String, exitValue:
|
|||
private class DummyProcess(action: => Int) extends Process {
|
||||
private[this] val exitCode = Future(action)
|
||||
override def exitValue() = exitCode()
|
||||
override def destroy() {}
|
||||
override def destroy(): Unit = ()
|
||||
}
|
||||
/** Represents a simple command without any redirection or combination. */
|
||||
private[sbt] class SimpleProcessBuilder(p: JProcessBuilder) extends AbstractProcessBuilder {
|
||||
|
|
@ -410,12 +410,12 @@ private final class ThreadProcess(thread: Thread, success: SyncVar[Boolean]) ext
|
|||
thread.join()
|
||||
if (success.get) 0 else 1
|
||||
}
|
||||
override def destroy() { thread.interrupt() }
|
||||
override def destroy(): Unit = thread.interrupt()
|
||||
}
|
||||
|
||||
object Uncloseable {
|
||||
def apply(in: InputStream): InputStream = new FilterInputStream(in) { override def close() {} }
|
||||
def apply(out: OutputStream): OutputStream = new FilterOutputStream(out) { override def close() {} }
|
||||
def apply(in: InputStream): InputStream = new FilterInputStream(in) { override def close(): Unit = () }
|
||||
def apply(out: OutputStream): OutputStream = new FilterOutputStream(out) { override def close(): Unit = () }
|
||||
def protect(in: InputStream): InputStream = if (in eq System.in) Uncloseable(in) else in
|
||||
def protect(out: OutputStream): OutputStream = if ((out eq System.out) || (out eq System.err)) Uncloseable(out) else out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ package sbt
|
|||
import java.io.{ File, FileNotFoundException, IOException }
|
||||
|
||||
object exit {
|
||||
def main(args: Array[String]) {
|
||||
def main(args: Array[String]): Unit = {
|
||||
System.exit(java.lang.Integer.parseInt(args(0)))
|
||||
}
|
||||
}
|
||||
object cat {
|
||||
def main(args: Array[String]) {
|
||||
def main(args: Array[String]): Unit = {
|
||||
try {
|
||||
if (args.length == 0)
|
||||
IO.transfer(System.in, System.out)
|
||||
|
|
@ -41,7 +41,6 @@ object cat {
|
|||
}
|
||||
}
|
||||
object echo {
|
||||
def main(args: Array[String]) {
|
||||
def main(args: Array[String]): Unit =
|
||||
System.out.println(args.mkString(" "))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue