diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/ant/Scalac.scala | 284 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/script.js | 161 |
2 files changed, 291 insertions, 154 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index 7a3d233aba..14ee20340a 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -8,7 +8,6 @@ package scala.tools.ant { - import java.io.File import java.net.{URL, URLClassLoader} import java.util.{ArrayList, Vector} @@ -24,37 +23,46 @@ package scala.tools.ant { import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} import scala.tools.nsc.{Global, FatalError, Settings} - /** An Ant task to compile with the new Scala compiler (NSC). - * This task can take the following parameters as attributes:<ul> - * <li>srcdir (mandatory),</li> - * <li>srcref,</li> - * <li>destdir,</li> - * <li>classpath,</li> - * <li>classpathref,</li> - * <li>sourcepath,</li> - * <li>sourcepathref,</li> - * <li>bootclasspath,</li> - * <li>bootclasspathref,</li> - * <li>extdirs,</li> - * <li>extdirsref,</li> - * <li>encoding,</li> - * <li>target,</li> - * <li>force,</li> - * <li>logging,</li> - * <li>logphase,</li> - * <li>usepredefs,</li> - * <li>debuginfo,</li> - * <li>addparams.</li> - * </ul> - * It also takes the following parameters as nested elements:<ul> - * <li>src (for srcdir),</li> - * <li>classpath,</li> - * <li>sourcepath,</li> - * <li>bootclasspath,</li> - * <li>extdirs.</li> - * </ul> - * - * @author Gilles Dubochet */ + /** <p> + * An Ant task to compile with the new Scala compiler (NSC). + * </p> + * <p> + * This task can take the following parameters as attributes: + * </p> + * <ul> + * <li>srcdir (mandatory),</li> + * <li>srcref,</li> + * <li>destdir,</li> + * <li>classpath,</li> + * <li>classpathref,</li> + * <li>sourcepath,</li> + * <li>sourcepathref,</li> + * <li>bootclasspath,</li> + * <li>bootclasspathref,</li> + * <li>extdirs,</li> + * <li>extdirsref,</li> + * <li>encoding,</li> + * <li>target,</li> + * <li>force,</li> + * <li>logging,</li> + * <li>logphase,</li> + * <li>usepredefs,</li> + * <li>debuginfo,</li> + * <li>addparams.</li> + * </ul> + * <p> + * It also takes the following parameters as nested elements: + * </p> + * <ul> + * <li>src (for srcdir),</li> + * <li>classpath,</li> + * <li>sourcepath,</li> + * <li>bootclasspath,</li> + * <li>extdirs.</li> + * </ul> + * + * @author Gilles Dubochet + */ class Scalac extends MatchingTask { private val SCALA_PRODUCT: String = @@ -65,9 +73,9 @@ package scala.tools.ant { /** The unique Ant file utilities instance to use in this task. */ private val fileUtils = FileUtils.newFileUtils() -/******************************************************************************\ +/*============================================================================*\ ** Ant user-properties ** -\******************************************************************************/ +\*============================================================================*/ abstract class PermissibleValue { val values: List[String] @@ -131,66 +139,86 @@ package scala.tools.ant { * in case of failure. */ private var scalacDebugging: Boolean = false -/******************************************************************************\ +/*============================================================================*\ ** Properties setters ** -\******************************************************************************/ +\*============================================================================*/ /** Sets the srcdir attribute. Used by Ant. - * @param input The value of <code>origin</code>. */ + * + * @param input The value of <code>origin</code>. + */ def setSrcdir(input: Path) = if (origin.isEmpty) origin = Some(input) else origin.get.append(input) /** Sets the <code>origin</code> as a nested src Ant parameter. - * @return An origin path to be configured. */ + * + * @return An origin path to be configured. + */ def createSrc(): Path = { if (origin.isEmpty) origin = Some(new Path(getProject())) origin.get.createPath() } /** Sets the <code>origin</code> as an external reference Ant parameter. - * @param input A reference to an origin path. */ + * + * @param input A reference to an origin path. + */ def setSrcref(input: Reference) = createSrc().setRefid(input) - /** Sets the destdir attribute. Used by Ant. - * @param input The value of <code>destination</code>. */ + /** Sets the <code>destdir</code> attribute. Used by Ant. + * + * @param input The value of <code>destination</code>. + */ def setDestdir(input: File) = destination = Some(input) - /** Sets the classpath attribute. Used by Ant. - * @param input The value of <code>classpath</code>. */ + /** Sets the <code>classpath</code> attribute. Used by Ant. + * + * @param input The value of <code>classpath</code>. + */ def setClasspath(input: Path) = if (classpath.isEmpty) classpath = Some(input) else classpath.get.append(input) /** Sets the <code>classpath</code> as a nested classpath Ant parameter. - * @return A class path to be configured. */ + * + * @return A class path to be configured. + */ def createClasspath(): Path = { if (classpath.isEmpty) classpath = Some(new Path(getProject())) classpath.get.createPath() } /** Sets the <code>classpath</code> as an external reference Ant parameter. - * @param input A reference to a class path. */ + * + * @param input A reference to a class path. + */ def setClasspathref(input: Reference) = createClasspath().setRefid(input) - /** Sets the sourcepath attribute. Used by Ant. - * @param input The value of <code>sourcepath</code>. */ + /** Sets the <code>sourcepath</code> attribute. Used by Ant. + * + * @param input The value of <code>sourcepath</code>. + */ def setSourcepath(input: Path) = if (sourcepath.isEmpty) sourcepath = Some(input) else sourcepath.get.append(input) /** Sets the <code>sourcepath</code> as a nested sourcepath Ant parameter. - * @return A source path to be configured. */ + * + * @return A source path to be configured. + */ def createSourcepath(): Path = { if (sourcepath.isEmpty) sourcepath = Some(new Path(getProject())) sourcepath.get.createPath() } /** Sets the <code>sourcepath</code> as an external reference Ant parameter. - * @param input A reference to a source path. */ + * + * @param input A reference to a source path. + */ def setSourcepathref(input: Reference) = createSourcepath().setRefid(input) @@ -209,45 +237,63 @@ package scala.tools.ant { } /** Sets the <code>bootclasspath</code> as an external reference Ant - * parameter. - * @param input A reference to a source path. */ + * parameter. + * + * @param input A reference to a source path. + */ def setBootclasspathref(input: Reference) = createBootclasspath().setRefid(input) /** Sets the external extensions path attribute. Used by Ant. - * @param input The value of <code>extdirs</code>. */ + * + * @param input The value of <code>extdirs</code>. + */ def setExtdirs(input: Path) = if (extdirs.isEmpty) extdirs = Some(input) else extdirs.get.append(input) /** Sets the <code>extdirs</code> as a nested sourcepath Ant parameter. - * @return An extensions path to be configured. */ + * + * @return An extensions path to be configured. + */ def createExtdirs(): Path = { if (extdirs.isEmpty) extdirs = Some(new Path(getProject())) extdirs.get.createPath() } /** Sets the <code>extdirs</code> as an external reference Ant parameter. - * @param input A reference to an extensions path. */ + * + * @param input A reference to an extensions path. + */ def setExtdirsref(input: Reference) = createExtdirs().setRefid(input) - /** Sets the encoding attribute. Used by Ant. - * @param input The value of <code>encoding</code>. */ + /** Sets the <code>encoding</code> attribute. Used by Ant. + * + * @param input The value of <code>encoding</code>. + */ def setEncoding(input: String): Unit = encoding = Some(input) + /** Sets the <code>target</code> attribute. Used by Ant. + * + * @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 + "'") - /** Sets the force attribute. Used by Ant. - * @param input The value for <code>force</code>. */ + /** Sets the <code>force</code> attribute. Used by Ant. + * + * @param input The value for <code>force</code>. + */ def setForce(input: Boolean): Unit = force = input /** Sets the logging level attribute. Used by Ant. - * @param input The value for <code>logging</code>. */ + * + * @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.") @@ -283,76 +329,97 @@ package scala.tools.ant { def setScalacdebugging(input: Boolean): Unit = scalacDebugging = input -/******************************************************************************\ +/*============================================================================*\ ** Properties getters ** -\******************************************************************************/ +\*============================================================================*/ - /** Gets the value of the classpath attribute in a Scala-friendly form. - * @returns The class path as a list of files. */ + /** Gets the value of the <code>classpath</code> attribute in a Scala-friendly form. + * + * @return The class path as a list of files. + */ private def getClasspath: List[File] = if (classpath.isEmpty) error("Member 'classpath' is empty.") - else - List.fromArray(classpath.get.list()).map(nameToFile) + else List.fromArray(classpath.get.list()).map(nameToFile) - /** Gets the value of the origin attribute in a Scala-friendly form. - * @returns The origin path as a list of files. */ + /** Gets the value of the <code>origin</code> attribute in a Scala-friendly form. + * + * @return The origin path as a list of files. + */ private def getOrigin: List[File] = if (origin.isEmpty) error("Member 'origin' is empty.") else List.fromArray(origin.get.list()).map(nameToFile) - /** Gets the value of the destination attribute in a Scala-friendly form. - * @returns The destination as a file. */ + /** Gets the value of the <code>destination</code> attribute in a + * Scala-friendly form. + * + * @return The destination as a file. + */ private def getDestination: File = if (destination.isEmpty) error("Member 'destination' is empty.") else existing(getProject().resolveFile(destination.get.toString())) - /** Gets the value of the sourcepath attribute in a Scala-friendly form. - * @returns The source path as a list of files. */ + /** Gets the value of the <code>sourcepath</code> attribute in a + * Scala-friendly form. + * + * @return The source path as a list of files. + */ private def getSourcepath: List[File] = if (sourcepath.isEmpty) error("Member 'sourcepath' is empty.") else List.fromArray(sourcepath.get.list()).map(nameToFile) - /** Gets the value of the bootclasspath attribute in a Scala-friendly form. - * @returns The boot class path as a list of files. */ + /** Gets the value of the <code>bootclasspath</code> attribute in a + * Scala-friendly form. + * + * @return The boot class path as a list of files. + */ private def getBootclasspath: List[File] = if (bootclasspath.isEmpty) error("Member 'bootclasspath' is empty.") else List.fromArray(bootclasspath.get.list()).map(nameToFile) /** Gets the value of the extdirs attribute in a Scala-friendly form. - * @returns The extensions path as a list of files. */ + * + * @return The extensions path as a list of files. + */ private def getExtdirs: List[File] = if (extdirs.isEmpty) error("Member 'extdirs' is empty.") else List.fromArray(extdirs.get.list()).map(nameToFile) -/******************************************************************************\ +/*============================================================================*\ ** Compilation and support methods ** -\******************************************************************************/ +\*============================================================================*/ /** This is forwarding method to circumvent bug #281 in Scala 2. Remove when - * bug has been corrected. */ - override protected def getDirectoryScanner(baseDir: java.io.File) = + * bug has been corrected. + */ + override protected def getDirectoryScanner(baseDir: File) = super.getDirectoryScanner(baseDir) /** Transforms a string name into a file relative to the provided base - * directory. - * @param base A file pointing to the location relative to which the name - * will be resolved. - * @param name A relative or absolute path to the file as a string. - * @return A file created from the name and the base file. */ + * directory. + * + * @param base A file pointing to the location relative to which the name + * will be resolved. + * @param name A relative or absolute path to the file as a string. + * @return A file created from the name and the base file. + */ private def nameToFile(base: File)(name: String): File = existing(fileUtils.resolveFile(base, name)) /** Transforms a string name into a file relative to the build root - * directory. - * @param name A relative or absolute path to the file as a string. - * @return A file created from the name. */ + * directory. + * + * @param name A relative or absolute path to the file as a string. + * @return A file created from the name. + */ private def nameToFile(name: String): File = existing(getProject().resolveFile(name)) /** Tests if a file exists and prints a warning in case it doesn't. Always - * returns the file, even if it doesn't exist. - * @param file A file to test for existance. - * @return The same file. */ + * returns the file, even if it doesn't exist. + * + * @param file A file to test for existance. + * @return The same file. + */ private def existing(file: File): File = { if (!file.exists()) log("Element '" + file.toString() + "' does not exist.", @@ -361,27 +428,33 @@ package scala.tools.ant { } /** Transforms a path into a Scalac-readable string. - * @param path A path to convert. - * @return A string-representation of the path like 'a.jar:b.jar'. */ + * + * @param path A path to convert. + * @return A string-representation of the path like <code>a.jar:b.jar</code>. + */ private def asString(path: List[File]): String = path.map(asString).mkString("", File.pathSeparator, "") /** Transforms a file into a Scalac-readable string. - * @param path A file to convert. - * @return A string-representation of the file like '/x/k/a.scala'. */ + * + * @param path A file to convert. + * @return A string-representation of the file like <code>/x/k/a.scala</code>. + */ private 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. */ + * ant file. + * + * @param message A message describing the error. + * @throws BuildException A build error exception thrown in every case. + */ private def error(message: String): Nothing = throw new BuildException(message, getLocation()) -/******************************************************************************\ +/*============================================================================*\ ** The big execute method ** -\******************************************************************************/ +\*============================================================================*/ /** Performs the compilation. */ override def execute() = { @@ -459,8 +532,8 @@ package scala.tools.ant { settings.debug.value = true } if (!logPhase.isEmpty) settings.log.value = logPhase - settings.nopredefs.value = !usepredefs; - settings.debuginfo.value = debugInfo; + settings.nopredefs.value = !usepredefs + settings.debuginfo.value = debugInfo log("Scalac params = '" + addParams + "'", Project.MSG_DEBUG) var args = @@ -492,20 +565,17 @@ package scala.tools.ant { } reporter.printSummary() if (reporter.errors > 0) { - error ( + error( "Compile failed with " + reporter.errors + " error" + (if (reporter.errors > 1) "s" else "") + - "; see the compiler error output for details." - ) + "; see the compiler error output for details.") } else if (reporter.warnings > 0) - log ( + log( "Compile suceeded with " + reporter.warnings + " warning" + (if (reporter.warnings > 1) "s" else "") + - "; see the compiler output for details." - ) - + "; see the compiler output for details.") } } diff --git a/src/compiler/scala/tools/nsc/doc/script.js b/src/compiler/scala/tools/nsc/doc/script.js index a63d6834f8..480e415221 100644 --- a/src/compiler/scala/tools/nsc/doc/script.js +++ b/src/compiler/scala/tools/nsc/doc/script.js @@ -1,62 +1,129 @@ <!-- function setWindowTitle(title) { - parent.document.title = title; + parent.document.title = title; } -var api_root = 'http://java.sun.com/j2se/1.5.0/docs/api/'; -//var api_root = 'file:///home/linuxsoft/apps/java/docs/api/'; +var java_api_root = 'http://java.sun.com/j2se/1.5.0/docs/api/'; +//var java_api_root = 'http://lamp.epfl.ch/~linuxsoft/java/jdk1.5/docs/api/'; -// hashtable +var ant_api_root = 'http://lamp.epfl.ch/~linuxsoft/ant/manual/api/'; +//var ant_api_root = 'http://www.net-freaks.org/doc/ant-1.6.5/manual/api/'; + +var eclipse_api_root = 'http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/'; + +// hashtable_classes var table = new Array() function init() { - // initialize hashtable - table['java_io_BufferedReader'] = true; - table['java_io_BufferedWriter'] = true; - table['java_io_DataInputStream'] = true; - table['java_io_DataOutputStream'] = true; - table['java_io_File'] = true; - table['java_io_FileDescriptor'] = true; - table['java_io_FileReader'] = true; - table['java_io_FileWriter'] = true; - table['java_io_InputStream'] = true; - table['java_io_OutputStream'] = true; - table['java_io_PrintStream'] = true; - table['java_io_PrintWriter'] = true; - table['java_io_Reader'] = true; - table['java_io_StringReader'] = true; - table['java_io_StringWriter'] = true; - table['java_io_Writer'] = true; - table['java_lang_Exception'] = true; - table['java_lang_Long'] = true; - table['java_lang_Object'] = true; - table['java_lang_String'] = true; - table['java_math_BigDecimal'] = true; - table['java_math_BigInteger'] = true; - table['java_math_MathContext'] = true; - table['java_net_InetAddress'] = true; - table['java_net_ServerSocket'] = true; - table['java_net_Socket'] = true; - table['java_net_SocketPermission'] = true; - table['java_net_URI'] = true; - table['java_net_URL'] = true; - table['java_sql_Connection'] = true; - table['java_sql_ResultSet'] = true; - table['java_sql_ResultSetMetaData'] = true; - table['java_util_LinkedHashMap'] = true; - table['java_util_LinkedHashSet'] = true; - table['java_util_Map'] = true; - table['java_util_Properties'] = true; - table['java_util_Random'] = true; - table['java_util_Set'] = true; - table['java_util_WeakHashMap'] = true; - table['scala_Unit'] = true; + // initialize Java classes + table['java_io_BufferedReader'] = java_api_root; + table['java_io_BufferedWriter'] = java_api_root; + table['java_io_DataInputStream'] = java_api_root; + table['java_io_DataOutputStream'] = java_api_root; + table['java_io_File'] = java_api_root; + table['java_io_FileDescriptor'] = java_api_root; + table['java_io_FileReader'] = java_api_root; + table['java_io_FileWriter'] = java_api_root; + table['java_io_IOException'] = java_api_root; + table['java_io_InputStream'] = java_api_root; + table['java_io_OutputStream'] = java_api_root; + table['java_io_PrintStream'] = java_api_root; + table['java_io_PrintWriter'] = java_api_root; + table['java_io_Reader'] = java_api_root; + table['java_io_StringReader'] = java_api_root; + table['java_io_StringWriter'] = java_api_root; + table['java_io_Writer'] = java_api_root; + table['java_lang_Exception'] = java_api_root; + table['java_lang_Long'] = java_api_root; + table['java_lang_Object'] = java_api_root; + table['java_lang_String'] = java_api_root; + table['java_math_BigDecimal'] = java_api_root; + table['java_math_BigInteger'] = java_api_root; + table['java_math_MathContext'] = java_api_root; + table['java_net_InetAddress'] = java_api_root; + table['java_net_ServerSocket'] = java_api_root; + table['java_net_Socket'] = java_api_root; + table['java_net_SocketPermission'] = java_api_root; + table['java_net_URI'] = java_api_root; + table['java_net_URL'] = java_api_root; + table['java_sql_Connection'] = java_api_root; + table['java_sql_ResultSet'] = java_api_root; + table['java_sql_ResultSetMetaData'] = java_api_root; + table['java_util_LinkedHashMap'] = java_api_root; + table['java_util_LinkedHashSet'] = java_api_root; + table['java_util_Map'] = java_api_root; + table['java_util_Properties'] = java_api_root; + table['java_util_Random'] = java_api_root; + table['java_util_Set'] = java_api_root; + table['java_util_WeakHashMap'] = java_api_root; + + // initialize Ant classes + table['org_apache_tools_ant_BuildEvent'] = ant_api_root; + table['org_apache_tools_ant_DirectoryScanner'] = ant_api_root; + table['org_apache_tools_ant_Project'] = ant_api_root; + table['org_apache_tools_ant_Target'] = ant_api_root; + table['org_apache_tools_ant_Task'] = ant_api_root; + table['org_apache_tools_ant_taskdefs_Ant'] = ant_api_root; + table['org_apache_tools_ant_taskdefs_Available'] = ant_api_root; + table['org_apache_tools_ant_taskdefs_MatchingTask'] = ant_api_root; + table['org_apache_tools_ant_types_FileSet'] = ant_api_root; + table['org_apache_tools_ant_types_FilterChain'] = ant_api_root; + table['org_apache_tools_ant_types_FilterSet'] = ant_api_root; + table['org_apache_tools_ant_types_Path'] = ant_api_root; + table['org_apache_tools_ant_types_Reference'] = ant_api_root; + table['org_apache_tools_ant_types_Resource'] = ant_api_root; + table['org_apache_tools_ant_util_FileUtils'] = ant_api_root; + table['org_apache_tools_mail_MailMessage'] = ant_api_root; + table['org_apache_tools_zip_ZipFile'] = ant_api_root; + + // initialize Eclipse classes + table['org_eclipse_ant_core_Property'] = eclipse_api_root; + table['org_eclipse_ant_core_Task'] = eclipse_api_root; + table['org_eclipse_ant_core_Type'] = eclipse_api_root; + table['org_eclipse_core_runtime_Assert'] = eclipse_api_root; + table['org_eclipse_core_runtime_AssertFailedException'] = eclipse_api_root; + table['org_eclipse_core_runtime_CoreException'] = eclipse_api_root; + table['org_eclipse_core_runtime_Path'] = eclipse_api_root; + table['org_eclipse_core_runtime_Platform'] = eclipse_api_root; + table['org_eclipse_core_runtime_Plugin'] = eclipse_api_root; + table['org_eclipse_core_runtime_Preferences'] = eclipse_api_root; + table['org_eclipse_core_runtime_RegistryFactory'] = eclipse_api_root; + table['org_eclipse_core_runtime_Status'] = eclipse_api_root; + table['org_eclipse_debug_core_ILaunch'] = eclipse_api_root; + table['org_eclipse_debug_core_ILaunchConfiguration'] = eclipse_api_root; + table['org_eclipse_debug_core_ILaunchManager'] = eclipse_api_root; + table['org_eclipse_debug_core_ILaunchMode'] = eclipse_api_root; + table['org_eclipse_debug_core_IProcessFactory'] = eclipse_api_root; + table['org_eclipse_jdt_core_IAccessRule'] = eclipse_api_root; + table['org_eclipse_jdt_core_IBuffer'] = eclipse_api_root; + table['org_eclipse_jdt_core_IClassFile'] = eclipse_api_root; + table['org_eclipse_jdt_core_IClasspathEntry'] = eclipse_api_root; + table['org_eclipse_jdt_core_ICodeAssist'] = eclipse_api_root; + table['org_eclipse_jdt_core_ICodeFormatter'] = eclipse_api_root; + table['org_eclipse_jdt_core_ICompilationUnit'] = eclipse_api_root; + table['org_eclipse_jdt_core_IField'] = eclipse_api_root; + table['org_eclipse_jdt_core_IImportContainer'] = eclipse_api_root; + table['org_eclipse_jdt_core_IInitializer'] = eclipse_api_root; + table['org_eclipse_jdt_core_IJavaElement'] = eclipse_api_root; + table['org_eclipse_jdt_core_IMember'] = eclipse_api_root; + table['org_eclipse_jdt_core_IMethod'] = eclipse_api_root; + table['org_eclipse_jdt_core_IOpenable'] = eclipse_api_root; + table['org_eclipse_jdt_core_IParent'] = eclipse_api_root; + table['org_eclipse_jdt_core_ISourceRange'] = eclipse_api_root; + table['org_eclipse_jdt_core_IType'] = eclipse_api_root; + table['org_eclipse_jdt_core_IWorkingCopy'] = eclipse_api_root; + table['org_eclipse_jdt_launching_JavaRuntime'] = eclipse_api_root; + table['org_eclipse_jdt_launching_LibraryLocation'] = eclipse_api_root; + table['org_eclipse_jdt_launching_PropertyChangeEvent'] = eclipse_api_root; + table['org_eclipse_jdt_launching_SocketUtil'] = eclipse_api_root; + table['org_eclipse_jdt_launching_VMStandin'] = eclipse_api_root; var elems = document.getElementsByTagName('a'); for (i = 0; i < elems.length; i++) { try { key = elems[i].getAttribute('class'); - if (table[key] != null) { + api_root = table[key]; + if (api_root != null) { value = api_root + key.replace(/_/g, "/") + ".html"; elems[i].setAttribute('href', value); } @@ -64,6 +131,6 @@ function init() { catch (e) { // do nothing } - } + } } --> |