summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/ant/Scalac.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-05 02:56:08 +0000
committerPaul Phillips <paulp@improving.org>2010-12-05 02:56:08 +0000
commit77eb8fefec3e62ead95c7d409ec5a28f30289ec3 (patch)
tree5e035714a7e6363d1ae7f712d5b1f73c1d27d79e /src/compiler/scala/tools/ant/Scalac.scala
parent626e38940b72f5e8445ecbece4d41996b5e2842e (diff)
downloadscala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.tar.gz
scala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.tar.bz2
scala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.zip
Mopping up after the deprecation of exit and er...
Mopping up after the deprecation of exit and error. It is decidedly non-trivial (at least for the IDE-impaired) to be completely sure of which error function was being called when there were about twenty with the same signature in trunk and they are being variously inherited, imported, shadowed, etc. So although I was careful, the possibility exists that something is now calling a different "error" function than before. Caveat programmer. (And let's all make it our policy not to name anything "error" or "exit" from here on out....) No review.
Diffstat (limited to 'src/compiler/scala/tools/ant/Scalac.scala')
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index 20ed9fc6d4..6c56ace9fe 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -12,7 +12,7 @@ package scala.tools.ant
import java.io.{File,PrintWriter,BufferedWriter,FileWriter}
import org.apache.tools.ant.{ BuildException, Project, AntClassLoader }
-import org.apache.tools.ant.taskdefs.{MatchingTask,Java}
+import org.apache.tools.ant.taskdefs.Java
import org.apache.tools.ant.types.{Path, Reference}
import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper,
SourceFileScanner}
@@ -68,7 +68,7 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
*
* @author Gilles Dubochet, Stephane Micheloud
*/
-class Scalac extends MatchingTask with ScalacShared {
+class Scalac extends ScalaMatchingTask with ScalacShared {
/** The unique Ant file utilities instance to use in this task. */
private val fileUtils = FileUtils.getFileUtils()
@@ -173,7 +173,7 @@ class Scalac extends MatchingTask with ScalacShared {
case None => Some(arg)
}
private def pathAsList(p: Option[Path], name: String): List[File] = p match {
- case None => error("Member '" + name + "' is empty.")
+ case None => buildError("Member '" + name + "' is empty.")
case Some(x) => x.list.toList map nameToFile
}
private def createNewPath(getter: () => Option[Path], setter: (Option[Path]) => Unit) = {
@@ -296,7 +296,7 @@ class Scalac extends MatchingTask with ScalacShared {
* @param input The value for <code>target</code>. */
def setTarget(input: String): Unit =
if (Target.isPermissible(input)) backend = Some(input)
- else error("Unknown target '" + input + "'")
+ else buildError("Unknown target '" + input + "'")
/** Sets the <code>force</code> attribute. Used by Ant.
* @param input The value for <code>force</code>. */
@@ -317,7 +317,7 @@ class Scalac extends MatchingTask with ScalacShared {
* @param input The value for <code>logging</code>. */
def setLogging(input: String) {
if (LoggingLevel.isPermissible(input)) logging = Some(input)
- else error("Logging level '" + input + "' does not exist.")
+ else buildError("Logging level '" + input + "' does not exist.")
}
/** Sets the <code>logphase</code> attribute. Used by Ant.
@@ -328,7 +328,7 @@ class Scalac extends MatchingTask with ScalacShared {
if (CompilerPhase.isPermissible(st))
(if (input != "") List(st) else Nil)
else {
- error("Phase " + st + " in log does not exist.")
+ buildError("Phase " + st + " in log does not exist.")
Nil
}
}
@@ -345,19 +345,19 @@ class Scalac extends MatchingTask with ScalacShared {
/** Set the <code>deprecation</code> info attribute.
* @param input One of the flags <code>yes/no</code> or <code>on/off</code>. */
def setDeprecation(input: String) {
- deprecation = Flag toBoolean input orElse error("Unknown deprecation flag '" + input + "'")
+ deprecation = Flag toBoolean input orElse buildError("Unknown deprecation flag '" + input + "'")
}
/** Set the <code>optimise</code> info attribute.
* @param input One of the flags <code>yes/no</code> or <code>on/off</code>. */
def setOptimise(input: String) {
- optimise = Flag toBoolean input orElse error("Unknown optimisation flag '" + input + "'")
+ optimise = Flag toBoolean input orElse buildError("Unknown optimisation flag '" + input + "'")
}
/** Set the <code>unchecked</code> info attribute.
* @param input One of the flags <code>yes/no</code> or <code>on/off</code>. */
def setUnchecked(input: String) {
- unchecked = Flag toBoolean input orElse error("Unknown unchecked flag '" + input + "'")
+ unchecked = Flag toBoolean input orElse buildError("Unknown unchecked flag '" + input + "'")
}
/** Sets the <code>force</code> attribute. Used by Ant.
@@ -391,7 +391,7 @@ class Scalac extends MatchingTask with ScalacShared {
* Scala-friendly form.
* @return The destination as a file. */
protected def getDestination: File =
- if (destination.isEmpty) error("Member 'destination' is empty.")
+ if (destination.isEmpty) buildError("Member 'destination' is empty.")
else existing(getProject().resolveFile(destination.get.toString))
/** Gets the value of the <code>sourcepath</code> attribute in a
@@ -452,14 +452,6 @@ class Scalac extends MatchingTask with ScalacShared {
protected def asString(file: File): String =
file.getAbsolutePath()
- /** Generates a build error. Error location will be the current task in the
- * ant file.
- * @param message A message describing the error.
- * @throws BuildException A build error exception thrown in every case. */
- protected def error(message: String): Nothing =
- throw new BuildException(message, getLocation())
-
-
/*============================================================================*\
** Hooks for variants of Scala **
\*============================================================================*/
@@ -480,9 +472,9 @@ class Scalac extends MatchingTask with ScalacShared {
log("Base directory is `%s`".format(scala.tools.nsc.io.Path("").normalize))
// Tests if all mandatory attributes are set and valid.
- if (origin.isEmpty) error("Attribute 'srcdir' is not set.")
+ if (origin.isEmpty) buildError("Attribute 'srcdir' is not set.")
if (!destination.isEmpty && !destination.get.isDirectory())
- error("Attribute 'destdir' does not refer to an existing directory.")
+ buildError("Attribute 'destdir' does not refer to an existing directory.")
if (destination.isEmpty) destination = Some(getOrigin.head)
val mapper = new GlobPatternMapper()
@@ -531,7 +523,7 @@ class Scalac extends MatchingTask with ScalacShared {
// Builds-up the compilation settings for Scalac with the existing Ant
// parameters.
- val settings = newSettings(error)
+ val settings = newSettings(buildError)
settings.outdir.value = asString(destination.get)
if (!classpath.isEmpty)
settings.classpath.value = asString(getClasspath)
@@ -599,7 +591,7 @@ class Scalac extends MatchingTask with ScalacShared {
if (compilerPath.isDefined) path add compilerPath.get
else getClass.getClassLoader match {
case cl: AntClassLoader => path add new Path(getProject, cl.getClasspath)
- case _ => error("Cannot determine default classpath for scalac, please specify one!")
+ case _ => buildError("Cannot determine default classpath for scalac, please specify one!")
}
path
}
@@ -626,7 +618,7 @@ class Scalac extends MatchingTask with ScalacShared {
}
val res = execWithArgFiles(java, List(writeSettings.getCanonicalPath))
if (failonerror && res != 0)
- error("Compilation failed because of an internal compiler error;"+
+ buildError("Compilation failed because of an internal compiler error;"+
" see the error output for details.")
}
@@ -640,14 +632,14 @@ class Scalac extends MatchingTask with ScalacShared {
case ex: Throwable =>
ex.printStackTrace()
val msg = if (ex.getMessage == null) "no error message provided" else ex.getMessage
- error("Compile failed because of an internal compiler error (" + msg + "); see the error output for details.")
+ buildError("Compile failed because of an internal compiler error (" + msg + "); see the error output for details.")
}
reporter.printSummary()
if (reporter.hasErrors) {
val msg = "Compile failed with %d error%s; see the compiler error output for details.".format(
reporter.ERROR.count, plural(reporter.ERROR.count))
- if (failonerror) error(msg) else log(msg)
+ if (failonerror) buildError(msg) else log(msg)
}
else if (reporter.WARNING.count > 0)
log("Compile succeeded with %d warning%s; see the compiler output for details.".format(