From 35f61f4fa2c277d7c459b148ab0cf633b2800386 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 22 Sep 2009 15:27:34 +0000 Subject: fixed doArgs (Settings.scala) and loadFrom (Plu... fixed doArgs (Settings.scala) and loadFrom (Plugin.scala) --- src/compiler/scala/tools/nsc/Settings.scala | 58 +++++++++++----------- .../scala/tools/nsc/backend/icode/Repository.scala | 2 +- src/compiler/scala/tools/nsc/plugins/Plugin.scala | 37 +++++++------- src/library/scala/Equals.scala | 12 +++-- src/library/scala/LowPriorityImplicits.scala | 12 +++-- src/library/scala/Numeric.scala | 2 +- src/library/scala/UninitializedFieldError.scala | 2 +- src/library/scala/throws.scala | 2 +- src/library/scala/util/Hashable.scala | 2 +- src/library/scala/util/NameTransformer.scala | 16 ++++-- src/library/scala/util/grammar/HedgeRHS.scala | 2 +- src/library/scala/util/grammar/TreeRHS.scala | 2 +- 12 files changed, 84 insertions(+), 65 deletions(-) diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index f9c12ce10a..027c25cd0c 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -136,37 +136,39 @@ class Settings(errorFn: String => Unit) extends ScalacSettings { def doArgs(args: List[String]): List[String] = { if (args.isEmpty) return Nil - val p = args.head - if (p == "") return args.tail // it looks like ant passes "" sometimes - - if (!p.startsWith("-")) { - errorFn("Parameter '" + p + "' does not start with '-'.") - return args - } - else if (p == "-") { - errorFn("'-' is not a valid argument.") - return args + val arg :: rest = args + if (arg == "") { + // it looks like Ant passes "" sometimes + doArgs(rest) } - - // we dispatch differently based on the appearance of p: - // 1) If it has a : it is presumed to be -Xfoo:bar,baz - // 2) If the first two chars are the name of a command, -Dfoo=bar - // 3) Otherwise, the whole string should be a command name - // - // Internally we use Option[List[String]] to discover error, - // but the outside expects our arguments back unchanged on failure - if (p contains ":") parseColonArg(p) match { - case Some(_) => args.tail - case None => args - } - else if (isPropertyArg(p)) parsePropertyArg(p) match { - case Some(_) => args.tail - case None => args + else if (!arg.startsWith("-")) { + errorFn("Argument '" + arg + "' does not start with '-'.") + args } - else parseNormalArg(p, args.tail) match { - case Some(xs) => xs - case None => args + else if (arg == "-") { + errorFn("'-' is not a valid argument.") + args } + else + // we dispatch differently based on the appearance of p: + // 1) If it has a : it is presumed to be -Xfoo:bar,baz + // 2) If the first two chars are the name of a command, -Dfoo=bar + // 3) Otherwise, the whole string should be a command name + // + // Internally we use Option[List[String]] to discover error, + // but the outside expects our arguments back unchanged on failure + if (arg contains ":") parseColonArg(arg) match { + case Some(_) => doArgs(rest) + case None => args + } + else if (isPropertyArg(arg)) parsePropertyArg(arg) match { + case Some(_) => doArgs(rest) + case None => args + } + else parseNormalArg(arg, rest) match { + case Some(xs) => xs + case None => args + } } doArgs(args) diff --git a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala index 2fc200227c..d7e8f0955b 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala @@ -36,7 +36,7 @@ trait Repository { def icode(sym: Symbol, force: Boolean): IClass = if (available(sym)) icode(sym).get else { - log("loading " + sym) + log("loading " + sym) load(sym) assert(available(sym)) loaded(sym) diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index 2b61724c49..50bd52d3fa 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -63,8 +63,8 @@ abstract class Plugin { * @author Lex Spoon * @version 1.0, 2007-5-21 */ -object Plugin -{ +object Plugin { + private val PluginXML = "scalac-plugin.xml" /** Create a class loader with the specified file plus @@ -78,7 +78,8 @@ object Plugin } /** Try to load a plugin description from the specified - * file, returning None if it does not work. */ + * file, returning None if it does not work. + */ private def loadDescription(jarfile: Path): Option[PluginDescription] = // XXX Return to this once we have some ARM support if (!jarfile.exists) None @@ -86,9 +87,9 @@ object Plugin val jar = new JarFile(jarfile.jfile) try { - (jar getEntry PluginXML) match { - case null => None - case entry => + jar getEntry PluginXML match { + case null => None + case entry => val in = jar getInputStream entry val packXML = XML load in in.close() @@ -104,19 +105,21 @@ object Plugin type AnyClass = Class[_] - /** Loads a plugin class from the named jar file. Returns None - * if the jar file has no plugin in it or if the plugin - * is badly formed. - */ - def loadFrom(jarfile: Path, loader: ClassLoader): Option[AnyClass] = { - val pluginInfo = loadDescription(jarfile).get + /** Loads a plugin class from the named jar file. - try Some(loader loadClass pluginInfo.classname) catch { - case _: ClassNotFoundException => - println("Warning: class not found for plugin in %s (%s)".format(jarfile, pluginInfo.classname)) - None + * @return None if the jar file has no plugin in it or + * if the plugin is badly formed. + */ + def loadFrom(jarfile: Path, loader: ClassLoader): Option[AnyClass] = + loadDescription(jarfile) match { + case None => None + case Some(pdesc) => + try Some(loader loadClass pdesc.classname) catch { + case _: Exception => + println("Warning: class not found for plugin in %s (%s)".format(jarfile, pdesc.classname)) + None + } } - } /** Load all plugins found in the argument list, both in the * jar files explicitly listed, and in the jar files in the diff --git a/src/library/scala/Equals.scala b/src/library/scala/Equals.scala index aa02cb0982..6ff2c2fcbc 100644 --- a/src/library/scala/Equals.scala +++ b/src/library/scala/Equals.scala @@ -8,19 +8,21 @@ // $Id: Equals.scala 18478 2009-08-13 21:30:20Z stepancheg $ + package scala -/** An interface containing operations for equality - * The only method not already present in AnyRef is canEqual +/** An interface containing operations for equality. + * The only method not already present in class `AnyRef` is `canEqual`. */ trait Equals { + /** A method that should be called from every well-designed equals method - * that is open to be overridden in a subclass. See Programming in Scala, Chapter 28 - * for discussion and design. + * that is open to be overridden in a subclass. See Programming in Scala, + * Chapter 28 for discussion and design. */ def canEqual(that: Any): Boolean - /** The equality method defined in AnyRef + /** The equality method defined in `AnyRef`. */ def equals(that: Any): Boolean } diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala index 58796b4ddc..5334dca078 100644 --- a/src/library/scala/LowPriorityImplicits.scala +++ b/src/library/scala/LowPriorityImplicits.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: Predef.scala 18558 2009-08-24 14:03:30Z moors $ +// $Id$ package scala @@ -14,9 +14,13 @@ package scala import collection.mutable._ import collection.immutable.WrappedString -/** The `LowPriorityImplicits` class provides implicit values that are - * valid in all Scala compilation units without explicit qualification, but that - * are partially overridden by higher-priority conmversions in Predef +/** The `LowPriorityImplicits` class provides implicit values that + * are valid in all Scala compilation units without explicit qualification, + * but that are partially overridden by higher-priority conversions in object + * `Predef`. + * + * @author Martin Odersky + * @since 2.8 */ class LowPriorityImplicits { diff --git a/src/library/scala/Numeric.scala b/src/library/scala/Numeric.scala index 0468970d35..ef3d771d6e 100644 --- a/src/library/scala/Numeric.scala +++ b/src/library/scala/Numeric.scala @@ -15,7 +15,7 @@ package scala * @since 2.8 */ object Numeric { - trait BigIntIsIntegral extends Integral[BigInt] { + trait BigIntIsIntegral extends Integral[BigInt] { def plus(x: BigInt, y: BigInt): BigInt = x + y def minus(x: BigInt, y: BigInt): BigInt = x - y def times(x: BigInt, y: BigInt): BigInt = x * y diff --git a/src/library/scala/UninitializedFieldError.scala b/src/library/scala/UninitializedFieldError.scala index fd4174b9ea..0c68e2bbd6 100644 --- a/src/library/scala/UninitializedFieldError.scala +++ b/src/library/scala/UninitializedFieldError.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ package scala diff --git a/src/library/scala/throws.scala b/src/library/scala/throws.scala index 5daa9ec945..201aa4798a 100644 --- a/src/library/scala/throws.scala +++ b/src/library/scala/throws.scala @@ -4,7 +4,7 @@ ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** -*/ +\* */ // $Id$ diff --git a/src/library/scala/util/Hashable.scala b/src/library/scala/util/Hashable.scala index 1ed1da30d8..117d749316 100644 --- a/src/library/scala/util/Hashable.scala +++ b/src/library/scala/util/Hashable.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ package scala.util diff --git a/src/library/scala/util/NameTransformer.scala b/src/library/scala/util/NameTransformer.scala index 9472413ca2..cce503e329 100644 --- a/src/library/scala/util/NameTransformer.scala +++ b/src/library/scala/util/NameTransformer.scala @@ -1,11 +1,19 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2009 LAMP/EPFL - * @author Martin Odersky - */ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + // $Id$ + package scala.util +/** + * @author Martin Odersky + */ object NameTransformer { private val nops = 128 private val ncodes = 26 * 26 diff --git a/src/library/scala/util/grammar/HedgeRHS.scala b/src/library/scala/util/grammar/HedgeRHS.scala index 92ead3642d..938508af0e 100644 --- a/src/library/scala/util/grammar/HedgeRHS.scala +++ b/src/library/scala/util/grammar/HedgeRHS.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ diff --git a/src/library/scala/util/grammar/TreeRHS.scala b/src/library/scala/util/grammar/TreeRHS.scala index dc3dc8fced..d0d4c1f628 100644 --- a/src/library/scala/util/grammar/TreeRHS.scala +++ b/src/library/scala/util/grammar/TreeRHS.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ -- cgit v1.2.3