diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-10 16:21:56 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-10 16:21:56 +0000 |
commit | 10bcc73badcbb46deb1b707e94af65f439f62b66 (patch) | |
tree | 7329556a2e34b887230a4715ad0422a50774a611 /src/compiler | |
parent | 0f5c2696c82f0027ccc815a008aac5a5226ca3e7 (diff) | |
download | scala-10bcc73badcbb46deb1b707e94af65f439f62b66.tar.gz scala-10bcc73badcbb46deb1b707e94af65f439f62b66.tar.bz2 scala-10bcc73badcbb46deb1b707e94af65f439f62b66.zip |
Some minor compiler support bits for my upcomin...
Some minor compiler support bits for my upcoming partest patch. No
review.
Diffstat (limited to 'src/compiler')
5 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/io/Directory.scala b/src/compiler/scala/tools/nsc/io/Directory.scala index 3268a0363f..3749cf6e67 100644 --- a/src/compiler/scala/tools/nsc/io/Directory.scala +++ b/src/compiler/scala/tools/nsc/io/Directory.scala @@ -12,8 +12,7 @@ package io import java.io.{ File => JFile } import collection.Traversable -object Directory -{ +object Directory { import scala.util.Properties.{ tmpDir, userHome, userDir } private def normalizePath(s: String) = Some(apply(Path(s).normalize)) @@ -21,7 +20,7 @@ object Directory def Home: Option[Directory] = if (userHome == "") None else normalizePath(userHome) def TmpDir: Option[Directory] = if (tmpDir == "") None else normalizePath(tmpDir) - def apply(path: Path) = path.toDirectory + def apply(path: Path): Directory = path.toDirectory // Like File.makeTemp but creates a directory instead def makeTemp(prefix: String = Path.randomPrefix, suffix: String = null, dir: JFile = null): Directory = { diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala index 824e74efdc..ed09aac3bb 100644 --- a/src/compiler/scala/tools/nsc/io/Path.scala +++ b/src/compiler/scala/tools/nsc/io/Path.scala @@ -61,6 +61,7 @@ object Path def roots: List[Path] = JFile.listRoots().toList map Path.apply + def apply(segments: Seq[String]): Path = apply(segments mkString JFile.separator) def apply(path: String): Path = apply(new JFile(path)) def apply(jfile: JFile): Path = if (jfile.isFile) new File(jfile) @@ -75,8 +76,7 @@ import Path._ /** The Path constructor is private so we can enforce some * semantics regarding how a Path might relate to the world. */ -class Path private[io] (val jfile: JFile) -{ +class Path private[io] (val jfile: JFile) { val separator = JFile.separatorChar val separatorStr = JFile.separator diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index 99292f2338..bdb6c6ae6f 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -31,7 +31,8 @@ abstract class Reporter { } var cancelled: Boolean = false - def hasErrors: Boolean = ERROR.count != 0 || cancelled + def hasErrors: Boolean = ERROR.count > 0 || cancelled + def hasWarnings: Boolean = WARNING.count > 0 /** Flush all output */ def flush() { } diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index cc737b9fbb..0560062bf1 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -79,8 +79,11 @@ object ClassPath { /** Split the classpath, filter according to predicate, and reassemble. */ def filter(cp: String, p: String => Boolean): String = join(split(cp) filter p: _*) - /** Split the classpath and map them into urls */ - def toURLs(cp: String): List[URL] = split(cp) map (x => Path(x).toAbsolute.toURL) + /** Split the classpath and map them into Paths */ + def toPaths(cp: String): List[Path] = split(cp) map (x => Path(x).toAbsolute) + + /** Split the classpath and map them into URLs */ + def toURLs(cp: String): List[URL] = toPaths(cp) map (_.toURL) /** Expand path and possibly expanding stars */ def expandPath(path: String, expandStar: Boolean = true): List[String] = diff --git a/src/compiler/scala/tools/nsc/util/CommandLineParser.scala b/src/compiler/scala/tools/nsc/util/CommandLineParser.scala index a640b36477..9f9eda0ef3 100644 --- a/src/compiler/scala/tools/nsc/util/CommandLineParser.scala +++ b/src/compiler/scala/tools/nsc/util/CommandLineParser.scala @@ -77,6 +77,7 @@ case class CommandLine( def isSet(arg: String) = args contains arg def get(arg: String) = argMap get arg + def getOrElse(arg: String, orElse: => String) = if (isSet(arg)) apply(arg) else orElse def apply(arg: String) = argMap(arg) override def toString() = "CommandLine(\n%s)\n" format (args map (" " + _ + "\n") mkString) |