diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/Settings.scala | 58 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/Repository.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/plugins/Plugin.scala | 37 |
3 files changed, 51 insertions, 46 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 <code>None</code> 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 <code>None</code> 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 |