diff options
author | michelou <michelou@epfl.ch> | 2007-06-07 11:22:41 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-06-07 11:22:41 +0000 |
commit | 90fed9c4846f4549099e8c0c8ce2a7683004a92f (patch) | |
tree | 3fd0b40aefd4ea99e1cd077c4e2e7710fe641ba5 /src/compiler/scala/tools/nsc/plugins/Plugin.scala | |
parent | d1aed7012af7439181c4696fb33f5f4337b83684 (diff) | |
download | scala-90fed9c4846f4549099e8c0c8ce2a7683004a92f.tar.gz scala-90fed9c4846f4549099e8c0c8ce2a7683004a92f.tar.bz2 scala-90fed9c4846f4549099e8c0c8ce2a7683004a92f.zip |
updated deprecated &f, updated svn:keywords
Diffstat (limited to 'src/compiler/scala/tools/nsc/plugins/Plugin.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/plugins/Plugin.scala | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index 73ebb66134..f4c5a7b301 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -1,18 +1,32 @@ +/* NSC -- new Scala compiler + * Copyright 2007-2008 LAMP/EPFL + * @author Lex Spoon + */ +// $Id$ + package scala.tools.nsc.plugins + import java.io.File +import java.net.URLClassLoader import java.util.jar.JarFile import java.util.zip.ZipException -import scala.xml.XML -import java.net.URLClassLoader + import scala.collection.mutable import mutable.ListBuffer +import scala.xml.XML -/** Information about a plugin loaded from a jar file. - * - * The concrete subclass must have a one-argument constructor - * that accepts an instance of Global. - * +/** <p> + * Information about a plugin loaded from a jar file. + * </p> + * <p> + * The concrete subclass must have a one-argument constructor + * that accepts an instance of <code>Global</code>. + * </p><pre> * (val global: Global) + * </pre> + * + * @author Lex Spoon + * @version 1.0, 2007-5-21 */ abstract class Plugin { /** The name of this plugin */ @@ -30,30 +44,34 @@ abstract class Plugin { /** Handle any plugin-specific options. The -P:plugname: part * will not be present. */ - def processOptions(options: List[String], error: String=>Unit) { + def processOptions(options: List[String], error: String => Unit) { if (!options.isEmpty) error("Error: " + name + " has no options") } /** A description of this plugin's options, suitable as a response * to the -help command-line option. Conventionally, the - * options should be listed with the -P:plugname: part included. + * options should be listed with the <code>-P:plugname:</code> + * part included. */ val optionsHelp: Option[String] = None } +/** ... + * + * @author Lex Spoon + * @version 1.0, 2007-5-21 + */ object Plugin { /** Create a class loader with the specified file plus * the loader that loaded the Scala compiler. */ private def loaderFor(jarfiles: Seq[File]): ClassLoader = { val compilerLoader = classOf[Plugin].getClassLoader - val jarurls = jarfiles.map(.toURL).toArray + val jarurls = jarfiles.map(_.toURL).toArray new URLClassLoader(jarurls, compilerLoader) } - - /** Try to load a plugin description from the specified * file, returning None if it does not work. */ private def loadDescription(jarfile: File): Option[PluginDescription] = { @@ -78,14 +96,11 @@ object Plugin { } } - - /** 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: File, - loader: ClassLoader): Option[Class] = - { + * is badly formed. + */ + def loadFrom(jarfile: File, loader: ClassLoader): Option[Class] = { val pluginInfo = loadDescription(jarfile).get try { @@ -98,12 +113,11 @@ object Plugin { } } - - - /** Load all plugins found in the argument list, bot hin - * the jar files explicitly listed, and in the jar files in - * the directories specified. Skips all plugins in `ignoring'. - * A single classloader is created and used to load all of them. */ + /** Load all plugins found in the argument list, both in the + * jar files explicitly listed, and in the jar files in the + * directories specified. Skips all plugins in <code>ignoring</code>. + * A single classloader is created and used to load all of them. + */ def loadAllFrom(jars: List[File], dirs: List[File], ignoring: List[String]): List[Class] = @@ -126,8 +140,6 @@ object Plugin { alljars.toList.map(f => loadFrom(f,loader)).flatMap(x => x) } - - /** Instantiate a plugin class, given the class and * the compiler it is to be used in. */ |