summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/plugins
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-06-07 11:22:41 +0000
committermichelou <michelou@epfl.ch>2007-06-07 11:22:41 +0000
commit90fed9c4846f4549099e8c0c8ce2a7683004a92f (patch)
tree3fd0b40aefd4ea99e1cd077c4e2e7710fe641ba5 /src/compiler/scala/tools/nsc/plugins
parentd1aed7012af7439181c4696fb33f5f4337b83684 (diff)
downloadscala-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')
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala64
-rw-r--r--src/compiler/scala/tools/nsc/plugins/PluginComponent.scala10
-rw-r--r--src/compiler/scala/tools/nsc/plugins/PluginDescription.scala21
-rw-r--r--src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala12
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugins.scala19
5 files changed, 87 insertions, 39 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.
*/
diff --git a/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala b/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala
index 8a4cee80f7..978358e53b 100644
--- a/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala
+++ b/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala
@@ -1,9 +1,15 @@
+/* NSC -- new Scala compiler
+ * Copyright 2007-2008 LAMP/EPFL
+ * @author Lex Spoon
+ */
+// $Id$
+
package scala.tools.nsc.plugins
/** A component that is part of a Plugin.
*
- * @version 1.0
- * @author Lex Spoon, 2007/5/29
+ * @author Lex Spoon
+ * @version 1.0, 2007/5/29
*/
abstract class PluginComponent extends SubComponent {
/** the phase this plugin wants to run after */
diff --git a/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala b/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala
index f7abda65aa..769b9a9ac4 100644
--- a/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala
+++ b/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala
@@ -1,7 +1,15 @@
+/* NSC -- new Scala compiler
+ * Copyright 2007-2008 LAMP/EPFL
+ * @author Lex Spoon
+ */
+// $Id$
+
package scala.tools.nsc.plugins
-import scala.xml.{Node,NodeSeq}
+
import java.io.File
+import scala.xml.{Node,NodeSeq}
+
/** A description of a compiler plugin, suitable for serialization
* to XML for inclusion in the plugin's .jar file.
*
@@ -9,18 +17,20 @@ import java.io.File
* @version 1.0, 2007-5-21
*/
abstract class PluginDescription {
+
/** A short name of the compiler, used to identify it in
* various contexts. The phase defined by the plugin
- * should have the same name. */
+ * should have the same name.
+ */
val name: String
-
/** The name of the main class for the plugin */
val classname: String
/** An XML representation of this description. It can be
- * read back using PluginDescription.fromXML . It should
- * be stored inside the jor. */
+ * read back using <code>PluginDescription.fromXML</code>.
+ * It should be stored inside the jar.
+ */
def toXML: Node = {
<plugin>
<name>{name}</name>
@@ -30,7 +40,6 @@ abstract class PluginDescription {
}
-
/** Utilities for the PluginDescription class.
*
* @author Lex Spoon
diff --git a/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala b/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala
index d69a5e098c..4bd9b33549 100644
--- a/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala
+++ b/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala
@@ -1,5 +1,15 @@
-package scala.tools.nsc.plugins
+/* NSC -- new Scala compiler
+ * Copyright 2007-2008 LAMP/EPFL
+ * @author Lex Spoon
+ */
+// $Id$
+package scala.tools.nsc.plugins
+/** ...
+ *
+ * @author Lex Spoon
+ * @version 1.0, 2007-5-21
+ */
class PluginLoadException(filename: String, cause: Exception)
extends Exception(cause)
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
index b8d618a3fc..c9792aa211 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
@@ -1,7 +1,18 @@
+/* NSC -- new Scala compiler
+ * Copyright 2007-2008 LAMP/EPFL
+ * @author Lex Spoon
+ */
+// $Id$
+
package scala.tools.nsc.plugins
+
import java.io.File
-/** Support for run-time loading of compiler plugins */
+/** Support for run-time loading of compiler plugins.
+ *
+ * @author Lex Spoon
+ * @version 1.0, 2007-5-21
+ */
trait Plugins { self: Global =>
/** Load all available plugin. Skips plugins that
@@ -28,7 +39,7 @@ trait Plugins { self: Global =>
plugins match {
case Nil => Nil
case plug :: rest =>
- val plugPhaseNames = Set.empty ++ plug.components.map(.phaseName)
+ val plugPhaseNames = Set.empty ++ plug.components.map(_.phaseName)
def withoutPlug = pick(rest, plugNames, plugPhaseNames)
def withPlug =
(plug ::
@@ -64,7 +75,7 @@ trait Plugins { self: Global =>
val plugs =
pick(initPlugins,
Set.empty,
- Set.empty ++ builtInPhaseDescriptors.map(.phaseName))
+ Set.empty ++ builtInPhaseDescriptors.map(_.phaseName))
for (req <- settings.require.value; if !plugs.exists(p => p.name==req))
error("Missing required plugin: " + req)
@@ -124,7 +135,7 @@ trait Plugins { self: Global =>
}
var descriptors = builtInPhaseDescriptors
- var plugsLeft = plugins.flatMap(.components)
+ var plugsLeft = plugins.flatMap(_.components)
// Insert all the plugins, one by one. Note that
// plugins are allowed to depend on each other, thus