diff options
Diffstat (limited to 'src')
32 files changed, 414 insertions, 409 deletions
diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala index 95dc2eb149..ffe67b8229 100644 --- a/src/compiler/scala/tools/ant/ScalaTool.scala +++ b/src/compiler/scala/tools/ant/ScalaTool.scala @@ -109,11 +109,11 @@ class ScalaTool extends ScalaMatchingTask { * Note that this mechanism of setting the classpath is generally preferred * for general purpose scripts, as this does not assume all elements are * relative to the ant basedir. Additionally, the platform specific demarcation - * of any script variables (e.g. ${SCALA_HOME} or %SCALA_HOME%) can be specified - * in a platform independant way (e.g. @SCALA_HOME@) and automatically translated + * of any script variables (e.g. `${SCALA_HOME}` or `%SCALA_HOME%`) can be specified + * in a platform independant way (e.g. `@SCALA_HOME@`) and automatically translated * for you. */ - def setClassPath(input: String): Unit = { + def setClassPath(input: String) { classpath = classpath ::: input.split(",").toList } @@ -130,7 +130,7 @@ class ScalaTool extends ScalaMatchingTask { * this is not a mechanism for setting the classpath for more general use scripts, * such as those distributed within sbaz distribution packages. */ - def setClassPathRef(input: Reference): Unit = { + def setClassPathRef(input: Reference) { val tmpPath = emptyPath tmpPath.setRefid(input) classpath = classpath ::: tmpPath.list.toList @@ -239,7 +239,7 @@ class ScalaTool extends ScalaMatchingTask { buildError("File " + file + " is not writable") else { val writer = new FileWriter(file, false) - writer.write(content) + writer write content writer.close() } @@ -262,13 +262,13 @@ class ScalaTool extends ScalaMatchingTask { // Consolidate Paths into classpath classpath = classpath ::: classpathPath.list.toList // Generate the scripts - if (platforms.contains("unix")) { + if (platforms contains "unix") { val unixPatches = patches + (("classpath", getUnixclasspath)) val unixTemplateResource = resourceRoot + "tool-unix.tmpl" val unixTemplate = readAndPatchResource(unixTemplateResource, unixPatches) writeFile(file.get, unixTemplate) } - if (platforms.contains("windows")) { + if (platforms contains "windows") { val winPatches = patches + (("classpath", getWinclasspath)) val winTemplateResource = resourceRoot + "tool-windows.tmpl" val winTemplate = readAndPatchResource(winTemplateResource, winPatches) diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index 5cb7a1d811..25a80bc4a6 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -76,7 +76,7 @@ trait CompilerControl { self: Global => /** Removes the CompilationUnit corresponding to the given SourceFile * from consideration for recompilation. */ - def removeUnitOf(s: SourceFile): Option[RichCompilationUnit] = { toBeRemoved += s.file; unitOfFile get s.file } + def removeUnitOf(s: SourceFile): Option[RichCompilationUnit] = { toBeRemoved += s.file; unitOfFile get s.file } /** Returns the top level classes and objects that were deleted * in the editor since last time recentlyDeleted() was called. diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala index b3ebc4aa1b..98b6f44e29 100644 --- a/src/compiler/scala/tools/nsc/interactive/REPL.scala +++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala @@ -176,8 +176,7 @@ object REPL { println(instrument(toSourceFile(file), line.toInt).map(_.mkString)) case List("quit") => comp.askShutdown() - // deleted sys. as this has to run on 2.8 also - exit(1) + exit(1) // Don't use sys yet as this has to run on 2.8.2 also. case List("structure", file) => doStructure(file) case _ => diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 6076f5add5..9edf7f44f3 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -306,8 +306,9 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp /** Given a simple repl-defined name, returns the real name of * the class representing it, e.g. for "Bippy" it may return - * + * {{{ * $line19.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$Bippy + * }}} */ def generatedName(simpleName: String): Option[String] = { if (simpleName endsWith "$") optFlatName(simpleName.init) map (_ + "$") @@ -329,7 +330,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp private def mostRecentlyHandledTree: Option[Tree] = { prevRequests.reverse foreach { req => req.handlers.reverse foreach { - case x: MemberDefHandler if x.definesValue && !isInternalVarName(x.name) => return Some(x.member) + case x: MemberDefHandler if x.definesValue && !isInternalVarName(x.name) => return Some(x.member) case _ => () } } @@ -352,6 +353,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp repldbg("Redefining term '%s'\n %s -> %s".format(name, t1, t2)) } } + def recordRequest(req: Request) { if (req == null || referencedNameMap == null) return @@ -383,9 +385,10 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp } } - private[nsc] def replwarn(msg: => String): Unit = + private[nsc] def replwarn(msg: => String) { if (!settings.nowarnings.value) printMessage(msg) + } def isParseable(line: String): Boolean = { beSilentDuring { @@ -430,6 +433,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp case idx => s take idx }) mkString "\n" } + private def safePos(t: Tree, alt: Int): Int = try t.pos.startOrPoint catch { case _: UnsupportedOperationException => alt } @@ -755,7 +759,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp /** One line of code submitted by the user for interpretation */ // private class Request(val line: String, val trees: List[Tree]) { - val lineRep = new ReadEvalPrint() + val lineRep = new ReadEvalPrint() import lineRep.lineAfterTyper private var _originalLine: String = null @@ -951,6 +955,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp try Some(definitions.getClass(newTypeName(name))) catch { case _: MissingRequirementError => None } } + def safeModule(name: String): Option[Symbol] = { try Some(definitions.getModule(newTermName(name))) catch { case _: MissingRequirementError => None } @@ -971,6 +976,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp case nme.ROOTPKG => Some(definitions.RootClass.tpe) case name => requestForName(name) flatMap (_.compilerTypeOf get name) } + def symbolOfTerm(id: String): Symbol = requestForIdent(id) flatMap (_.definedSymbols get newTermName(id)) getOrElse NoSymbol @@ -1085,6 +1091,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp parse(code) foreach (ts => ts foreach (t => withoutUnwrapping(repldbg(asCompactString(t))))) } } + // debugging def debugging[T](msg: String)(res: T) = { repldbg(msg + " " + res) diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala index 850042700f..cd2c04dbd8 100755 --- a/src/library/scala/AnyVal.scala +++ b/src/library/scala/AnyVal.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/src/library/scala/App.scala b/src/library/scala/App.scala index bc731963a5..85d2f9075e 100644 --- a/src/library/scala/App.scala +++ b/src/library/scala/App.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2010-2011, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -14,9 +14,9 @@ import scala.collection.mutable.ListBuffer /** The `App` trait can be used to quickly turn objects * into executable programs. Here is an example: * {{{ - * object Main extends App { - * Console.println("Hello World: " + (args mkString ", ")) - * } + * object Main extends App { + * Console.println("Hello World: " + (args mkString ", ")) + * } * }}} * Here, object `Main` inherits the `main` method of `App`. * diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala index d3c024b38e..021e499530 100644 --- a/src/library/scala/Application.scala +++ b/src/library/scala/Application.scala @@ -1,68 +1,60 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ + package scala import scala.compat.Platform.currentTime -/** <p> - * The <code>Application</code> trait can be used to quickly turn objects - * into executable programs, but is <em>not recommended</em>. - * Here is an example: - * </p><pre> - * <b>object</b> Main <b>extends</b> Application { +/** The `Application` trait can be used to quickly turn objects + * into executable programs, but is ''not recommended''. + * Here is an example: + * {{{ + * object Main extends Application { * Console.println("Hello World!") * } - * </pre> - * <p> - * Here, object <code>Main</code> inherits the <code>main</code> method - * of <code>Application</code>. The body of the <code>Main</code> object - * defines the main program. This technique does not work if the main - * program depends on command-line arguments (which are not accessible - * with the technique presented here). - * </p> - * <p> - * It is possible to time the execution of objects that inherit from class - * <code>Application</code> by setting the global <code>scala.time</code> - * property. Here is an example for benchmarking object <code>Main</code>: - * </p><pre> + * }}} + * Here, object `Main` inherits the `main` method of `Application`. + * The body of the `Main` object defines the main program. This technique + * does not work if the main program depends on command-line arguments + * (which are not accessible with the technique presented here). + * + * It is possible to time the execution of objects that inherit from class + * `Application` by setting the global `scala.time` + * property. Here is an example for benchmarking object `Main`: + * {{{ * java -Dscala.time Main - * </pre> - * <p> - * In practice the <code>Application</code> trait has a number of serious - * pitfalls: - * </p> - * <ul> - * <li> Threaded code that references the object will block until static - * initialization is complete. However, because the entire execution of an - * <code>object</code> extending <code>Application</code> takes place during - * static initialization, concurrent code will <em>always</em> deadlock if - * it must synchronize with the enclosing object.</li> - * <li>As described above, there is no way to obtain the - * command-line arguments because all code in body of an <code>object</code> - * extending <code>Application</code> is run as part of the static initialization - * which occurs before <code>Application</code>'s <code>main</code> method - * even begins execution.</li> - * <li>Static initializers are run only once during program execution, and + * }}} + * In practice the `Application` trait has a number of serious pitfalls: + * + * - Threaded code that references the object will block until static + * initialization is complete. However, because the entire execution + * of an `object` extending `Application` takes place during + * static initialization, concurrent code will ''always'' deadlock if + * it must synchronize with the enclosing object. + * - As described above, there is no way to obtain the + * command-line arguments because all code in body of an `object` + * extending `Application` is run as part of the static initialization + * which occurs before `Application`'s `main` method + * even begins execution. + * - Static initializers are run only once during program execution, and * JVM authors usually assume their execution to be relatively short. - * Therefore, certain JVM configurations may become confused, or simply fail to - * optimize or JIT the code in the body of an <code>object</code> extending - * <code>Application</code>. This can lead to a significant - * performance degradation.</li> - * </ul> + * Therefore, certain JVM configurations may become confused, or simply + * fail to optimize or JIT the code in the body of an `object` extending + * `Application`. This can lead to a significant performance degradation. * - * It is recommended to use the `App` trait instead. - * <pre> - * <b>object</b> Main { - * <b>def</b> main(args: Array[String]) { + * It is recommended to use the `[[scala.App]]` trait instead. + * {{{ + * object Main { + * def main(args: Array[String]) { * //.. * } * } - * </pre> + * }}} * * @author Matthias Zenger * @version 1.0, 10/09/2003 @@ -70,8 +62,8 @@ import scala.compat.Platform.currentTime @deprecated("use App instead", "2.9.0") trait Application { - /** The time when the execution of this program started, in milliseconds since 1 - * January 1970 UTC. */ + /** The time when the execution of this program started, + * in milliseconds since 1 January 1970 UTC. */ val executionStart: Long = currentTime /** The default main method. @@ -79,7 +71,7 @@ trait Application { * @param args the arguments passed to the main method */ def main(args: Array[String]) { - if (util.Properties.propIsSet("scala.time")) { + if (util.Properties propIsSet "scala.time") { val total = currentTime - executionStart Console.println("[total " + total + "ms]") } diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index c8f61d0625..060a5250ba 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -21,11 +21,11 @@ import scala.runtime.ScalaRunTime.{ array_apply, array_update } class FallbackArrayBuilding { /** A builder factory that generates a generic array. - * Called instead of Array.newBuilder if the element type of an array + * Called instead of `Array.newBuilder` if the element type of an array * does not have a class manifest. Note that fallbackBuilder factory - * needs an implicit parameter (otherwise it would not be dominated in implicit search - * by Array.canBuildFrom). We make sure that that implicit search is always - * successful. + * needs an implicit parameter (otherwise it would not be dominated in + * implicit search by `Array.canBuildFrom`). We make sure that that + * implicit search is always successful. */ implicit def fallbackCanBuildFrom[T](implicit m: DummyImplicit): CanBuildFrom[Array[_], T, ArraySeq[T]] = new CanBuildFrom[Array[_], T, ArraySeq[T]] { @@ -306,8 +306,8 @@ object Array extends FallbackArrayBuilding { b.result } - /** Returns a two-dimensional array containing values of a given function over - * ranges of integer values starting from 0. + /** Returns a two-dimensional array containing values of a given function + * over ranges of integer values starting from `0`. * * @param n1 the number of elements in the 1st dimension * @param n2 the number of elements in the 2nd dimension @@ -316,35 +316,35 @@ object Array extends FallbackArrayBuilding { def tabulate[T: ClassManifest](n1: Int, n2: Int)(f: (Int, Int) => T): Array[Array[T]] = tabulate(n1)(i1 => tabulate(n2)(f(i1, _))) - /** Returns a three-dimensional array containing values of a given function over - * ranges of integer values starting from 0. + /** Returns a three-dimensional array containing values of a given function + * over ranges of integer values starting from `0`. * * @param n1 the number of elements in the 1st dimension * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension + * @param n3 the number of elements in the 3rd dimension * @param f The function computing element values */ def tabulate[T: ClassManifest](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => T): Array[Array[Array[T]]] = tabulate(n1)(i1 => tabulate(n2, n3)(f(i1, _, _))) - /** Returns a four-dimensional array containing values of a given function over - * ranges of integer values starting from 0. + /** Returns a four-dimensional array containing values of a given function + * over ranges of integer values starting from `0`. * * @param n1 the number of elements in the 1st dimension * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension + * @param n3 the number of elements in the 3rd dimension * @param n4 the number of elements in the 4th dimension * @param f The function computing element values */ def tabulate[T: ClassManifest](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => T): Array[Array[Array[Array[T]]]] = tabulate(n1)(i1 => tabulate(n2, n3, n4)(f(i1, _, _, _))) - /** Returns a five-dimensional array containing values of a given function over - * ranges of integer values starting from 0. + /** Returns a five-dimensional array containing values of a given function + * over ranges of integer values starting from `0`. * * @param n1 the number of elements in the 1st dimension * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension + * @param n3 the number of elements in the 3rd dimension * @param n4 the number of elements in the 4th dimension * @param n5 the number of elements in the 5th dimension * @param f The function computing element values @@ -409,7 +409,7 @@ object Array extends FallbackArrayBuilding { /** Called in a pattern match like `{ case Array(x,y,z) => println('3 elements')}`. * * @param x the selector value - * @return sequence wrapped in a [[scala.Some]], if x is a Seq, otherwise `None` + * @return sequence wrapped in a [[scala.Some]], if `x` is a Seq, otherwise `None` */ def unapplySeq[T](x: Array[T]): Option[IndexedSeq[T]] = if (x == null) None else Some(x.toIndexedSeq) diff --git a/src/library/scala/Cell.scala b/src/library/scala/Cell.scala index f4fc3e3e77..f1e7dc8d86 100644 --- a/src/library/scala/Cell.scala +++ b/src/library/scala/Cell.scala @@ -10,9 +10,9 @@ package scala -/** A <code>Cell</code> is a generic wrapper which completely +/** A `Cell` is a generic wrapper which completely * hides the functionality of the wrapped object. The wrapped - * object is accessible via the <code>elem</code> accessor method. + * object is accessible via the `elem` accessor method. * * @author Martin Odersky * @version 1.0, 08/08/2003 diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala index f27393a294..7eadcb7b09 100644 --- a/src/library/scala/Console.scala +++ b/src/library/scala/Console.scala @@ -18,8 +18,7 @@ import scala.util.DynamicVariable /** Implements functionality for * printing Scala values on the terminal as well as reading specific values. - * Also defines - * constants for marking up text on ANSI terminals. + * Also defines constants for marking up text on ANSI terminals. * * @author Matthias Zenger * @version 1.0, 03/09/2003 @@ -117,7 +116,6 @@ object Console { /** Sets the default output stream for the duration * of execution of one thunk. * - * * @param out the new output stream. * @param thunk the code to execute with * the new output stream active @@ -198,7 +196,6 @@ object Console { def withIn[T](reader: Reader)(thunk: =>T): T = inVar.withValue(new BufferedReader(reader))(thunk) - /** Sets the default input stream. * * @param in the new input stream. @@ -243,13 +240,12 @@ object Console { */ def println(x: Any) { out.println(x) } - /** - * Prints its arguments as a formatted string to the default output, based on a string - * pattern (in a fashion similar to printf in C). + /** Prints its arguments as a formatted string to the default output, + * based on a string pattern (in a fashion similar to printf in C). * - * The interpretation of the formatting patterns is described in - * <a href="" target="contentFrame" class="java/util/Formatter"> - * <code>java.util.Formatter</code></a>. + * The interpretation of the formatting patterns is described in + * <a href="" target="contentFrame" class="java/util/Formatter"> + * `java.util.Formatter`</a>. * * @param text the pattern for formatting the arguments. * @param args the arguments used to instantiating the pattern. @@ -265,7 +261,7 @@ object Console { def readLine(): String = in.readLine() /** Print formatted text to the default output and read a full line from the default input. - * Returns null if the end of the input stream has been reached. + * Returns `null` if the end of the input stream has been reached. * * @param text the format of the text to print out, as in `printf`. * @param args the parameters used to instantiate the format, as in `printf`. @@ -277,7 +273,7 @@ object Console { } /** Reads a boolean value from an entire line of the default input. - * Has a fairly liberal interpretation of the input. + * Has a fairly liberal interpretation of the input. * * @return the boolean value read, or false if it couldn't be converted to a boolean * @throws java.io.EOFException if the end of the input stream has been reached. @@ -426,8 +422,9 @@ object Console { */ def readf1(format: String): Any = readf(format).head - /** Reads in some structured input (from the default input), specified by a format specifier, returning - * only the first two values extracted, according to the format specification. + /** Reads in some structured input (from the default input), specified + * by a format specifier, returning only the first two values extracted, + * according to the format specification. * * @param format format string, as accepted by `readf`. * @return A [[scala.Tuple2]] containing the first two values extracted @@ -437,8 +434,9 @@ object Console { (res.head, res.tail.head) } - /** Reads in some structured input (from the default input), specified by a format specifier, returning - * only the first three values extracted, according to the format specification. + /** Reads in some structured input (from the default input), specified + * by a format specifier, returning only the first three values extracted, + * according to the format specification. * * @param format format string, as accepted by `readf`. * @return A [[scala.Tuple3]] containing the first three values extracted diff --git a/src/library/scala/DelayedInit.scala b/src/library/scala/DelayedInit.scala index c54c28f9aa..e898bca720 100644 --- a/src/library/scala/DelayedInit.scala +++ b/src/library/scala/DelayedInit.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2010-2011, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -10,12 +10,13 @@ package scala /** Classes and traits inheriting the `DelayedInit` marker trait * will have their initialization code rewritten as follows: - * `code` becomes `delayedInit(code)` + * `code` becomes `delayedInit(code)`. * * Initialization code comprises all statements and all value definitions * that are executed during initialization. + * + * @author Martin Odersky */ trait DelayedInit { def delayedInit(x: => Unit): Unit } - diff --git a/src/library/scala/Dynamic.scala b/src/library/scala/Dynamic.scala index 2f99518988..32b57ee88f 100644 --- a/src/library/scala/Dynamic.scala +++ b/src/library/scala/Dynamic.scala @@ -1,12 +1,20 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2010-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala -/** A marker trait that enables dynamic invocations. Instances `x` of this trait - * allow calls `x.meth(args)` for arbitrary method names `meth` and argument lists - * `args`. If a call is not natively supported by `x`, it is rewritten to - * `x.applyDynamic("meth", args)`. +/** A marker trait that enables dynamic invocations. Instances `x` of this + * trait allow calls `x.meth(args)` for arbitrary method names `meth` and + * argument lists `args`. If a call is not natively supported by `x`, it + * is rewritten to `x.applyDynamic("meth", args)`. * - * As of scala 2.9, scalac must receive the -Xexperimental optional for Dynamic - * to receive this treatment. + * As of scala 2.9, `scalac` must receive the `-Xexperimental` option for + * `Dynamic` to receive this treatment. */ trait Dynamic diff --git a/src/library/scala/Either.scala b/src/library/scala/Either.scala index 29b75a4c82..e0f840a609 100644 --- a/src/library/scala/Either.scala +++ b/src/library/scala/Either.scala @@ -10,13 +10,11 @@ package scala -/** - * Represents a value of one of two possible - * types (a disjoint union). The data constructors [[scala.Left]] and - * [[scala.Right]] represent the two possible values. - * The `Either` type is often used as an alternative to - * [[scala.Option]] where `Left` represents failure - * (by convention) and `Right` is akin to `Some`. +/** Represents a value of one of two possible types (a disjoint union). + * The data constructors [[scala.Left]] and [[scala.Right]] represent + * the two possible values. + * The `Either` type is often used as an alternative to [[scala.Option]] + * where `Left` represents failure (by convention) and `Right` is akin to `Some`. * * @author <a href="mailto:research@workingmouse.com">Tony Morris</a>, Workingmouse * @version 1.0, 11/10/2008 @@ -35,6 +33,7 @@ sealed abstract class Either[+A, +B] { /** * Applies `fa` if this is a `Left` or `fb` if this is a `Right`. + * * @param fa the function to apply if this is a `Left` * @param fb the function to apply if this is a `Right` * @return the results of applying the function @@ -329,8 +328,8 @@ object Either { case Right(t) => t } - /** If the condition satisfies, return the given A in `Left`, - * otherwise, return the given B in `Right`. + /** If the condition satisfies, return the given `A` in `Left`, + * otherwise, return the given `B` in `Right`. */ def cond[A, B](test: Boolean, right: => B, left: => A): Either[A, B] = if (test) Right(right) else Left(left) diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 63e5582a99..c1b64808b0 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -35,18 +35,18 @@ object Option { * `foreach`: * * {{{ - * val name:Option[String] = request.getParameter("name") + * val name: Option[String] = request getParameter "name" * val upper = name map { _.trim } filter { _.length != 0 } map { _.toUpperCase } - * println(upper.getOrElse("")) + * println(upper getOrElse "") * }}} * * Note that this is equivalent to {{{ * val upper = for { - * name <- request.getParameter("name") + * name <- request getParameter "name" * trimmed <- Some(name.trim) * upper <- Some(trimmed.toUpperCase) if trimmed.length != 0 * } yield upper - * println(upper.getOrElse("")) + * println(upper getOrElse "") * }}} * * Because of how for comprehension works, if $none is returned @@ -57,14 +57,12 @@ object Option { * having to check for the existence of a value. * * A less-idiomatic way to use $option values is via pattern matching: {{{ - * val nameMaybe = request.getParameter("name") + * val nameMaybe = request getParameter "name" * nameMaybe match { - * case Some(name) => { + * case Some(name) => * println(name.trim.toUppercase) - * } - * case None => { + * case None => * println("No name value") - * } * } * }}} * diff --git a/src/library/scala/Proxy.scala b/src/library/scala/Proxy.scala index c9573fbb5e..f79b01bf83 100644 --- a/src/library/scala/Proxy.scala +++ b/src/library/scala/Proxy.scala @@ -9,14 +9,14 @@ package scala /** This class implements a simple proxy that forwards all calls to - * the public, non-final methods defined in class "Any" to another + * the public, non-final methods defined in class `Any` to another * object self. Those methods are: - * + * {{{ * def hashCode(): Int * def equals(other: Any): Boolean * def toString(): String - * - * Note: forwarding methods in this way will most likely create + * }}} + * '''Note:''' forwarding methods in this way will most likely create * an asymmetric equals method, which is not generally recommended. * * @author Matthias Zenger diff --git a/src/library/scala/collection/DefaultMap.scala b/src/library/scala/collection/DefaultMap.scala index cd6d7f8024..3af535bdaa 100644 --- a/src/library/scala/collection/DefaultMap.scala +++ b/src/library/scala/collection/DefaultMap.scala @@ -12,21 +12,17 @@ package scala.collection import generic._ -/** <p> - * A default map which implements the <code>+</code> and <code>-</code> - * methods of maps.<br/> - * Instances that inherit from <code>DefaultMap[A, B]</code> still have to - * define: - * </p><pre> - * <b>def</b> get(key: A): Option[B] - * <b>def</b> iterator: Iterator[(A, B)]</pre> - * <p> - * It refers back to the original map. - * </p> - * <p> - * It might also be advisable to override <code>foreach</code> or - * <code>size</code> if efficient implementations can be found. - * </p> +/** A default map which implements the `+` and `-` methods of maps. + * + * Instances that inherit from `DefaultMap[A, B]` still have to define: + * {{{ + * def get(key: A): Option[B] + * def iterator: Iterator[(A, B)] + * }}} + * It refers back to the original map. + * + * It might also be advisable to override `foreach` or `size` if efficient + * implementations can be found. * * @since 2.8 */ diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala index 34ba60a80e..442d50c6ea 100644 --- a/src/library/scala/collection/mutable/UnrolledBuffer.scala +++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala @@ -147,7 +147,7 @@ extends collection.mutable.Buffer[T] } else throw new IndexOutOfBoundsException(idx.toString) def +=:(elem: T) = { - headptr = headptr.prepend(elem) + headptr = headptr prepend elem sz += 1 this } @@ -160,8 +160,8 @@ extends collection.mutable.Buffer[T] private def writeObject(out: java.io.ObjectOutputStream) { out.defaultWriteObject - out.writeInt(sz) - for (elem <- this) out.writeObject(elem) + out writeInt sz + for (elem <- this) out writeObject elem } private def readObject(in: java.io.ObjectInputStream) { @@ -208,7 +208,7 @@ object UnrolledBuffer extends ClassManifestTraversableFactory[UnrolledBuffer] { this } else { next = new Unrolled[T](0, new Array[T](nextlength), null, buff) - next.append(elem) + next append elem } def foreach[U](f: T => U) { var unrolled = this @@ -242,7 +242,7 @@ object UnrolledBuffer extends ClassManifestTraversableFactory[UnrolledBuffer] { // allocate a new node and store element // then make it point to this val newhead = new Unrolled[T](buff) - newhead.append(elem) + newhead append elem newhead.next = this newhead } @@ -324,4 +324,3 @@ object UnrolledBuffer extends ClassManifestTraversableFactory[UnrolledBuffer] { } } - diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala index 917d61ec25..5d1e695add 100644 --- a/src/library/scala/io/Position.scala +++ b/src/library/scala/io/Position.scala @@ -10,24 +10,26 @@ package scala.io /** The object Position provides convenience methods to encode * line and column number in one single integer. The encoded line - * (column) numbers range from 0 to LINE_MASK (COLUMN_MASK), - * where 0 indicates that the line (column) is undefined and 1 - * represents the first line (column). + * (column) numbers range from 0 to `LINE_MASK` (`COLUMN_MASK`), + * where `0` indicates that the line (column) is undefined and + * `1` represents the first line (column). * - * Line (Column) numbers greater than LINE_MASK (COLUMN_MASK) are - * replaced by LINE_MASK (COLUMN_MASK). Furthermore, if the encoded - * line number is LINE_MASK, the column number is always set to 0. + * Line (Column) numbers greater than `LINE_MASK` (`COLUMN_MASK`) are + * replaced by `LINE_MASK` (`COLUMN_MASK`). Furthermore, if the encoded + * line number is `LINE_MASK`, the column number is always set to 0. * * The following properties hold: * - * the undefined position is 0: encode(0,0) == 0 - * encodings are non-negative : encode(line,column) >= 0 + * the undefined position is 0: `encode(0,0) == 0` + * encodings are non-negative : `encode(line,column) >= 0` * position order is preserved: - * + * {{{ * (line1 <= line2) || (line1 == line2 && column1 <= column2) - * implies + * }}} + * implies + * {{{ * encode(line1,column1) <= encode(line2,column2) - * + * }}} * @author Burak Emir (translated from work by Matthias Zenger and others) */ abstract class Position { diff --git a/src/library/scala/math/Equiv.scala b/src/library/scala/math/Equiv.scala index 6075951975..37654bd3fd 100644 --- a/src/library/scala/math/Equiv.scala +++ b/src/library/scala/math/Equiv.scala @@ -19,10 +19,10 @@ import java.util.Comparator * relation</a> is a binary relation on a type. This relation is exposed as * the `equiv` method of the `Equiv` trait. The relation must be: * - * 1. reflexive: equiv(x, x) == true for any x of type T. - * 2. symmetric: equiv(x, y) == equiv(y, x) for any x and y of type T. - * 3. transitive: if equiv(x, y) == true and equiv(y, z) == true, then - * equiv(x, z) == true for any x, y, and z of type T. + * 1. reflexive: `equiv(x, x) == true` for any x of type `T`. + * 2. symmetric: `equiv(x, y) == equiv(y, x)` for any x and y of type T. + * 3. transitive: if `equiv(x, y) == true` and `equiv(y, z) == true`, then + * `equiv(x, z) == true` for any x, y, and z of type T. * * @author Geoffrey Washburn, Paul Phillips * @version 1.0, 2008-04-03 diff --git a/src/library/scala/reflect/BeanProperty.scala b/src/library/scala/reflect/BeanProperty.scala index 84a2429240..1c7b84a7c8 100644 --- a/src/library/scala/reflect/BeanProperty.scala +++ b/src/library/scala/reflect/BeanProperty.scala @@ -12,23 +12,20 @@ package scala.reflect import annotation.target._ -/** <p> - * When attached to a field, this annotation adds a setter and a getter - * method following the Java Bean convention. For example: - * </p><pre> +/** When attached to a field, this annotation adds a setter and a getter + * method following the Java Bean convention. For example: + * {{{ * @BeanProperty - * <b>var</b> status = ""</pre> - * <p> - * adds the following methods to the class: - * </p><pre> - * <b>def</b> setStatus(s: String) { <b>this</b>.status = s } - * <b>def</b> getStatus: String = <b>this</b>.status - * </pre> - * <p> - * For fields of type <code>Boolean</code>, if you need a getter - * named <code>isStatus</code>, use the - * <code>scala.reflect.BooleanBeanProperty</code> annotation instead. - * </p> + * var status = "" + * }}} + * adds the following methods to the class: + * {{{ + * def setStatus(s: String) { this.status = s } + * def getStatus: String = this.status + * }}} + * For fields of type `Boolean`, if you need a getter + * named <code>isStatus</code>, use the + * `scala.reflect.BooleanBeanProperty` annotation instead. */ @field class BeanProperty extends annotation.StaticAnnotation diff --git a/src/library/scala/runtime/MethodCache.scala b/src/library/scala/runtime/MethodCache.scala index dbdf249a95..562f7dfd4d 100644 --- a/src/library/scala/runtime/MethodCache.scala +++ b/src/library/scala/runtime/MethodCache.scala @@ -14,18 +14,18 @@ import java.lang.{ Class => JClass } import scala.annotation.tailrec /** An element of a polymorphic object cache. - * This class is refered to by the CleanUp phase. Each PolyMethodCache chain - * must only relate to one method as PolyMethodCache does not identify - * the method name and argument types. In practice, one variable will be - * generated per call point, and will uniquely relate to the method called - * at that point, making the method name and argument types irrelevant. **/ + * This class is refered to by the `CleanUp` phase. Each `PolyMethodCache` chain + * must only relate to one method as `PolyMethodCache` does not identify + * the method name and argument types. In practice, one variable will be + * generated per call point, and will uniquely relate to the method called + * at that point, making the method name and argument types irrelevant. */ /* TODO: if performance is acceptable, PolyMethodCache should be made generic on the method type */ sealed abstract class MethodCache { - /** Searches for a cached method in the MethodCache chain that - * is compatible with receiver class "forReceiver". If none is cached, - * "null" is returned. If "null is returned", find's caller should look- - * up the right method using whichever means it prefers, and add it to - * the cache for later use. */ + /** Searches for a cached method in the `MethodCache` chain that + * is compatible with receiver class `forReceiver`. If none is cached, + * `null` is returned. If `null` is returned, find's caller should look- + * up the right method using whichever means it prefers, and add it to + * the cache for later use. */ def find(forReceiver: JClass[_]): JMethod def add(forReceiver: JClass[_], forMethod: JMethod): MethodCache } @@ -59,7 +59,7 @@ final class PolyMethodCache( ) extends MethodCache { /** To achieve tail recursion this must be a separate method - * from find, because the type of next is not PolyMethodCache. + * from `find`, because the type of next is not `PolyMethodCache`. */ @tailrec private def findInternal(forReceiver: JClass[_]): JMethod = if (forReceiver eq receiver) method diff --git a/src/library/scala/specialized.scala b/src/library/scala/specialized.scala index 3254a0c967..902faa166e 100644 --- a/src/library/scala/specialized.scala +++ b/src/library/scala/specialized.scala @@ -12,16 +12,15 @@ package scala /** Annotate type parameters on which code should be automatically * specialized. For example: - * <code> + * {{{ * class MyList[@specialized T] ... - * </code> + * }}} * * Type T can be specialized on a subset of the primitive types by * specifying a list of primitive types to specialize at: - * - * <code> - * class MyList[@specialized(Int, Double, Boolean) T] .. - * </code> + * {{{ + * class MyList[@specialized(Int, Double, Boolean) T] .. + * }}} * * @since 2.8 */ @@ -30,4 +29,3 @@ class specialized(types: SpecializableCompanion*) extends annotation.StaticAnnot this(Unit, Boolean, Byte, Short, Char, Int, Long, Float, Double) } } - diff --git a/src/library/scala/unchecked.scala b/src/library/scala/unchecked.scala index 379a03a266..74cb14e6e3 100644 --- a/src/library/scala/unchecked.scala +++ b/src/library/scala/unchecked.scala @@ -10,34 +10,30 @@ package scala -/** <p> - * An annotation that gets applied to a selector in a match expression. - * If it is present, exhaustiveness warnings for that expression will be - * suppressed. - * </p> - * <p> - * For example, compiling the code: - * </p><pre> - * <b>object</b> test <b>extends</b> Application { - * <b>def</b> f(x: Option[int]) = x <b>match</b> { - * <b>case</b> Some(y) => y +/** An annotation that gets applied to a selector in a match expression. + * If it is present, exhaustiveness warnings for that expression will be + * suppressed. + * For example, compiling the code: + * {{{ + * object test extends Application { + * def f(x: Option[Int]) = x match { + * case Some(y) => y * } * f(None) - * }</pre> - * <p> - * will display the following warning: - * </p><pre> + * } + * }}} + * will display the following warning: + * {{{ * test.scala:2: warning: does not cover case {object None} * def f(x: Option[int]) = x match { * ^ - * one warning found</pre> - * <p> - * The above message may be suppressed by substituting the expression - * <code>x</code> with <code>(x: @unchecked)</code>. Then the - * modified code will compile silently, but, in any case, a - * <a href="MatchError.html"><code>MatchError</code></a> - * will be raised at runtime. - * </p> + * one warning found + * }}} + * The above message may be suppressed by substituting the expression + * `x` with `(x: @unchecked)`. Then the + * modified code will compile silently, but, in any case, a + * <a href="MatchError.html"><code>MatchError</code></a> + * will be raised at runtime. * * @since 2.4 */ diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 0e9faccda3..a572ff3a66 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -71,22 +71,22 @@ import java.net.{ URL, MalformedURLException } * <code>parse()</code> method</li> * </ol> * - * <p> e.g.</p> - * <pre><code>XIncludeFilter includer = new XIncludeFilter(base); - * includer.setParent(parser); - * includer.setContentHandler(new SAXXIncluder(System.out)); - * includer.parse(args[i]);</code> - * </pre> - * </p> - * translated from Elliotte Rusty Harold's Java source + * e.g. + * {{{ + * val includer = new XIncludeFilter(base) + * includer setParent parser + * includer setContentHandler new SAXXIncluder(System.out) + * includer parse args(i) + * }}} + * translated from Elliotte Rusty Harold's Java source. * @author Burak Emir */ class XIncludeFilter extends XMLFilterImpl { - final val XINCLUDE_NAMESPACE = "http://www.w3.org/2001/XInclude"; + final val XINCLUDE_NAMESPACE = "http://www.w3.org/2001/XInclude" - private val bases = new Stack[URL](); - private val locators = new Stack[Locator](); + private val bases = new Stack[URL]() + private val locators = new Stack[Locator]() /* private EntityResolver resolver; @@ -103,7 +103,7 @@ class XIncludeFilter extends XMLFilterImpl { // do I need to check this in startDocument() and push something // there???? override def setDocumentLocator(locator: Locator) { - locators.push(locator) + locators push locator val base = locator.getSystemId() try { bases.push(new URL(base)) @@ -152,30 +152,30 @@ class XIncludeFilter extends XMLFilterImpl { + currentBase, e) } } - bases.push(currentBase); + bases push currentBase if (uri.equals(XINCLUDE_NAMESPACE) && localName.equals("include")) { // include external document val href = atts.getValue("href") // Verify that there is an href attribute - if (href==null) { + if (href == null) { throw new SAXException("Missing href attribute") } - var parse = atts.getValue("parse") + var parse = atts getValue "parse" if (parse == null) parse = "xml" - if (parse.equals("text")) { - val encoding = atts.getValue("encoding"); + if (parse equals "text") { + val encoding = atts getValue "encoding" includeTextDocument(href, encoding); } - else if (parse.equals("xml")) { + else if (parse equals "xml") { includeXMLDocument(href); } // Need to check this also in DOM and JDOM???? else { throw new SAXException( - "Illegal value for parse attribute: " + parse); + "Illegal value for parse attribute: " + parse) } level += 1 } @@ -196,7 +196,7 @@ class XIncludeFilter extends XMLFilterImpl { override def endElement(uri: String, localName: String, qName: String) { if (uri.equals(XINCLUDE_NAMESPACE) && localName.equals("include")) { - level -= 1; + level -= 1 } else if (level == 0) { bases.pop() @@ -214,7 +214,7 @@ class XIncludeFilter extends XMLFilterImpl { override def endDocument() { locators.pop() - bases.pop(); // pop the URL for the document itself + bases.pop() // pop the URL for the document itself depth -= 1 if (depth == 0) super.endDocument() } @@ -321,29 +321,26 @@ class XIncludeFilter extends XMLFilterImpl { val c = new Array[Char](1024) var charsRead: Int = 0 // bogus init value do { - charsRead = reader.read(c, 0, 1024); - if (charsRead > 0) this.characters(c, 0, charsRead); - } while (charsRead != -1) ; + charsRead = reader.read(c, 0, 1024) + if (charsRead > 0) this.characters(c, 0, charsRead) + } while (charsRead != -1) } catch { case e: UnsupportedEncodingException => throw new SAXException("Unsupported encoding: " - + encoding + getLocation(), e); + + encoding + getLocation(), e) case e: IOException => throw new SAXException("Document not found: " - + source.toExternalForm() + getLocation(), e); + + source.toExternalForm() + getLocation(), e) } } private var atRoot = false - /** - * <p> - * This utility method reads a document at a specified URL - * and fires off calls to various <code>ContentHandler</code> methods. - * It's used to include files with <code>parse="xml"</code> - * </p> + /** This utility method reads a document at a specified URL + * and fires off calls to various `ContentHandler` methods. + * It's used to include files with `parse="xml"`. * * @param url URL of the document that will be read * @return void diff --git a/src/library/scala/xml/parsing/ConstructingParser.scala b/src/library/scala/xml/parsing/ConstructingParser.scala index 78490d4b43..8ea3fc839d 100644 --- a/src/library/scala/xml/parsing/ConstructingParser.scala +++ b/src/library/scala/xml/parsing/ConstructingParser.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -29,18 +29,18 @@ object ConstructingParser { * * {{{ * object parseFromURL { - * def main(args:Array[String]): Unit = { - * val url = args(0); - * val src = scala.io.Source.fromURL(url); - * val cpa = scala.xml.parsing.ConstructingParser.fromSource(src, false); // fromSource initializes automatically - * val doc = cpa.document(); + * def main(args: Array[String]) { + * val url = args(0) + * val src = scala.io.Source.fromURL(url) + * val cpa = scala.xml.parsing.ConstructingParser.fromSource(src, false) // fromSource initializes automatically + * val doc = cpa.document() * * // let's see what it is - * val ppr = new scala.xml.PrettyPrinter(80,5); - * val ele = doc.docElem; - * Console.println("finished parsing"); - * val out = ppr.format(ele); - * Console.println(out); + * val ppr = new scala.xml.PrettyPrinter(80,5) + * val ele = doc.docElem + * println("finished parsing") + * val out = ppr.format(ele) + * println(out) * } * } * }}} */ @@ -52,4 +52,3 @@ with MarkupParser { // default impl. of Logged override def log(msg: String): Unit = {} } - diff --git a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala index 6cab639efe..699c5b2b5f 100644 --- a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala +++ b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala @@ -12,7 +12,7 @@ package scala.xml package parsing -/** default implementation of markup handler always returns NodeSeq.Empty */ +/** Default implementation of markup handler always returns `NodeSeq.Empty` */ abstract class DefaultMarkupHandler extends MarkupHandler { def elem(pos: Int, pre: String, label: String, attrs: MetaData, diff --git a/src/manual/scala/tools/docutil/EmitHtml.scala b/src/manual/scala/tools/docutil/EmitHtml.scala index 394e32cb4b..ddfb8cb0f2 100644 --- a/src/manual/scala/tools/docutil/EmitHtml.scala +++ b/src/manual/scala/tools/docutil/EmitHtml.scala @@ -20,110 +20,110 @@ object EmitHtml { /* */ def emitSection(section: Section, depth: Int) { def emitPara(text: AbstractText) { - out.println("<div>") + out println "<div>" emitText(text) - out.println("\n</div>") + out println "\n</div>" } def emitText(text: AbstractText) { text match { case seq:SeqText => - seq.components.foreach(emitText) + seq.components foreach emitText case seq:SeqPara => - seq.components.foreach(emitPara) + seq.components foreach emitPara case Text(text) => - out.print(escape(text)) + out print escape(text) case BSlash => - out.print("\\") + out print "\\" case MDash => - out.print("—") + out print "—" case NDash => - out.print("–") + out print "–" case Bold(text) => - out.print("<b>") + out print "<b>" emitText(text) - out.print("</b>") + out print "</b>" case Italic(text) => - out.print("<i>") + out print "<i>" emitText(text) - out.print("</i>") + out print "</i>" case Emph(text) => - out.print("<em>") + out print "<em>" emitText(text) - out.print("</em>") + out print "</em>" case Mono(text) => - out.print("<code>") + out print "<code>" emitText(text) - out.print("</code>") + out print "</code>" case Quote(text) => - out.print("\"") + out print "\"" emitText(text) - out.print("\"") + out print "\"" case DefinitionList(definitions @ _*) => - out.println("<ins><dl>") + out println "<ins><dl>" for (d <- definitions) { - out.println("<dt>") + out println "<dt>" emitText(d.term) - out.println("\n</dt>") - out.println("<dd>") + out println "\n</dt>" + out println "<dd>" emitText(d.description) - out.println("</dd>") + out println "</dd>" } - out.println("</dl></ins>") + out println "</dl></ins>" case Link(label, url) => out.print("<a href=\"" + url + "\">") emitText(label) - out.print("</a>") + out print "</a>" case _ => - error("unknown text node: " + text) + sys.error("unknown text node: " + text) } } def emitParagraph(para: Paragraph) { para match { case TextParagraph(text) => - out.println("<p>") + out println "<p>" emitText(text) - out.println("</p>") + out println "</p>" case BlockQuote(text) => - out.println("<blockquote><p>") + out println "<blockquote><p>" emitText(text) - out.println("</p></blockquote>") + out println "</p></blockquote>" case CodeSample(text) => - out.print("<pre>") - out.print(escape(text)) - out.println("</pre>") + out print "<pre>" + out print escape(text) + out println "</pre>" case lst:BulletList => - out.println("<ul>") + out println "<ul>" for (item <- lst.items) { - out.print("<li>") + out print "<li>" emitText(item) - out.println("</li>") + out println "</li>" } - out.println("</ul>") + out println "</ul>" case lst:NumberedList => - out.println("<ol>") + out println "<ol>" for (item <- lst.items) { - out.print("<li>") + out print "<li>" emitText(item) } - out.println("</ol>") + out println "</ol>" case TitledPara(title, text) => out.println("<p><strong>" + escape(title) + "</strong></p>") @@ -133,7 +133,7 @@ object EmitHtml { emitSection(sect, depth + 1) case _ => - error("unknown paragraph node: " + para) + sys.error("unknown paragraph node: " + para) } } @@ -141,33 +141,33 @@ object EmitHtml { out.println("\n<h" + depth + " id=\"" + name + "\">" + section.title + "</h" + depth + ">") - section.paragraphs.foreach(emitParagraph) + section.paragraphs foreach emitParagraph } private def emit3columns(col1: String, col2: String, col3: String) { - out.println("<div style=\"float:left;\">") - out.println(col1) - out.println("</div>") - out.println("<div style=\"float:right;\">") - out.println(col3) - out.println("</div>") - out.println("<div style=\"text-align:center;\">") - out.println(col2) - out.println("</div>") + out println "<div style=\"float:left;\">" + out println col1 + out println "</div>" + out println "<div style=\"float:right;\">" + out println col3 + out println "</div>" + out println "<div style=\"text-align:center;\">" + out println col2 + out println "</div>" } private def emitHeader(col1: String, col2: String, col3: String) { - out.println("<!-- header -->") - out.println("<div style=\"margin: 0 0 2em 0;\">") + out println "<!-- header -->" + out println "<div style=\"margin: 0 0 2em 0;\">" emit3columns(col1, col2, col3) - out.println("</div>") + out println "</div>" } private def emitFooter(col1: String, col2: String, col3: String) { - out.println("<!-- footer -->") - out.println("<div style=\"margin: 2em 0 0 0;\">") + out println "<!-- footer -->" + out println "<div style=\"margin: 2em 0 0 0;\">" emit3columns(col1, col2, col3) - out.println("</div>") + out println "</div>" } def emitDocument(document: Document) { @@ -175,31 +175,31 @@ object EmitHtml { out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">") out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n") - out.println("<head>") + out println "<head>" out.println("<title>" + document.title + " man page</title>") out.println("<meta http-equiv=\"Content-Language\" content=\"en\"/>") out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + document.encoding + "\"/>") out.println("<meta name=\"Author\" content=\"" + document.author + "\"/>") - out.println("<style type=\"text/css\">") - out.println(" <!--") - out.println(" blockquote, pre { margin:1em 4em 1em 4em; }") - out.println(" dt { margin: 0.6em 0 0 0; }") - out.println(" p { margin:0.6em 2em 0.6em 2em; text-align:justify; }") - out.println(" //-->") - out.println("</style>") - out.println("</head>\n") - - out.println("<body>") + out println "<style type=\"text/css\">" + out println " <!--" + out println " blockquote, pre { margin:1em 4em 1em 4em; }" + out println " dt { margin: 0.6em 0 0 0; }" + out println " p { margin:0.6em 2em 0.6em 2em; text-align:justify; }" + out println " //-->" + out println "</style>" + out println "</head>\n" + + out println "<body>" val name = document.title + "(" + document.category.id + ")" emitHeader(name, "" + document.category, name) - document.sections.foreach(s => emitSection(s, 3)) + document.sections foreach (s => emitSection(s, 3)) emitFooter("version " + document.version, document.date, name) - out.println("</body>") - out.println("</html>") + out println "</body>" + out println "</html>" } /* */ /* @@ -340,25 +340,25 @@ object EmitHtml { */ def main(args: Array[String]) { if (args.length < 1) { - System.err.println("usage: EmitHtml <classname>") - exit(1) + System.err println "usage: EmitHtml <classname>" + sys.exit(1) } try { val cl = this.getClass.getClassLoader() - val clasz = cl.loadClass(args(0)) - val meth = clasz.getDeclaredMethod("manpage") + val clasz = cl loadClass args(0) + val meth = clasz getDeclaredMethod "manpage" val doc = meth.invoke(null).asInstanceOf[Document] emitDocument(doc) } catch { case ex: Exception => ex.printStackTrace() - System.err.println("Error in EmitHtml") - exit(1) + System.err println "Error in EmitHtml" + sys.exit(1) } } def emitHtml(classname: String, outStream: java.io.OutputStream) { - out.setOut(outStream) + out setOut outStream main(Array(classname)) } } diff --git a/src/manual/scala/tools/docutil/EmitManPage.scala b/src/manual/scala/tools/docutil/EmitManPage.scala index bab685274b..4a66e2ed07 100644 --- a/src/manual/scala/tools/docutil/EmitManPage.scala +++ b/src/manual/scala/tools/docutil/EmitManPage.scala @@ -21,34 +21,34 @@ object EmitManPage { def emitSection(section: Section, depth: Int) { def emitPara(text: AbstractText) { emitText(text) - out.println("\n.IP") + out println "\n.IP" } def emitText(text: AbstractText) { text match { case seq:SeqText => - seq.components.foreach(emitText) + seq.components foreach emitText case seq:SeqPara => - seq.components.foreach(emitPara) + seq.components foreach emitPara case Text(text) => - out.print(escape(text)) + out print escape(text) case BSlash => - out.print("\\e") + out print "\\e" case NDash | MDash => - out.print("\\-") + out print "\\-" case Bold(text) => - out.print("\\fB") + out print "\\fB" emitText(text) - out.print("\\fR") + out print "\\fR" case Italic(text) => - out.print("\\fI") + out print "\\fI" emitText(text) - out.print("\\fR") + out print "\\fR" case Emph(text) => out.print("\\fI") @@ -68,7 +68,7 @@ object EmitManPage { case DefinitionList(definitions @ _*) => var n = definitions.length for (d <- definitions) { - out.println(".TP") + out println ".TP" emitText(d.term) out.println emitText(d.description) @@ -79,30 +79,30 @@ object EmitManPage { emitText(label) case _ => - error("unknown text node: " + text) + sys.error("unknown text node: " + text) } } def emitParagraph(para: Paragraph) { para match { case TextParagraph(text) => - out.println(".PP") + out println ".PP" emitText(text) out.println case BlockQuote(text) => - out.println(".TP") + out println ".TP" emitText(text) out.println case CodeSample(text) => - out.println("\n.nf") + out println "\n.nf" out.print(text) - out.println("\n.fi") + out println "\n.fi" case lst:BulletList => for (item <- lst.items) { - out.println(".IP") + out println ".IP" emitText(item) out.println } @@ -118,68 +118,68 @@ object EmitManPage { } case TitledPara(title, text) => - out.println(".PP") - out.print("\\fB") + out println ".PP" + out print "\\fB" emitText(title) - out.print("\\fR") + out print "\\fR" emitText(text) case EmbeddedSection(sect) => emitSection(sect, depth + 1) case _ => - error("unknown paragraph node: " + para) + sys.error("unknown paragraph node: " + para) } } - out.println(".\\\"") + out println ".\\\"" out.println(".\\\" ############################## " + section.title + " ###############################") - out.println(".\\\"") + out println ".\\\"" val tag = if (depth > 1) ".SS" else ".SH" val title = if (section.title.indexOf(" ") > 0) "\"" + section.title + "\"" else section.title out.println(tag + " " + title) - section.paragraphs.foreach(emitParagraph) + section.paragraphs foreach emitParagraph } def emitDocument(doc: Document) { - out.println(".\\\" ##########################################################################") - out.println(".\\\" # __ #") - out.println(".\\\" # ________ ___ / / ___ Scala 2 On-line Manual Pages #") - out.println(".\\\" # / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL #") - out.println(".\\\" # __\\ \\/ /__/ __ |/ /__/ __ | #") - out.println(".\\\" # /____/\\___/_/ |_/____/_/ | | http://scala-lang.org/ #") - out.println(".\\\" # |/ #") - out.println(".\\\" ##########################################################################") - out.println(".\\\"") - out.println(".\\\" Process this file with nroff -man scala.1") - out.println(".\\\"") + out println ".\\\" ##########################################################################" + out println ".\\\" # __ #" + out println ".\\\" # ________ ___ / / ___ Scala 2 On-line Manual Pages #" + out println ".\\\" # / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL #" + out println ".\\\" # __\\ \\/ /__/ __ |/ /__/ __ | #" + out println ".\\\" # /____/\\___/_/ |_/____/_/ | | http://scala-lang.org/ #" + out println ".\\\" # |/ #" + out println ".\\\" ##########################################################################" + out println ".\\\"" + out println ".\\\" Process this file with nroff -man scala.1" + out println ".\\\"" out.println(".TH " + doc.title + " " + doc.category.id + " \"" + doc.date + "\" \"version " + doc.version + "\" \"" + doc.category + "\"") - doc.sections.foreach(s => emitSection(s, 1)) + doc.sections foreach (s => emitSection(s, 1)) } def main(args: Array[String]) { try { val cl = this.getClass.getClassLoader() - val clasz = cl.loadClass(args(0)) - val meth = clasz.getDeclaredMethod("manpage") + val clasz = cl loadClass args(0) + val meth = clasz getDeclaredMethod "manpage" val doc = meth.invoke(null).asInstanceOf[Document] emitDocument(doc) } catch { case ex: Exception => ex.printStackTrace() - System.err.println("Error in EmitManPage") - exit(1) + System.err println "Error in EmitManPage" + sys.exit(1) } } def emitManPage(classname: String, outStream: java.io.OutputStream) { - out.setOut(outStream) + out setOut outStream main(Array(classname)) } } diff --git a/src/manual/scala/tools/docutil/ManMaker.scala b/src/manual/scala/tools/docutil/ManMaker.scala index b947e3dce4..fa35e658dd 100644 --- a/src/manual/scala/tools/docutil/ManMaker.scala +++ b/src/manual/scala/tools/docutil/ManMaker.scala @@ -1,3 +1,9 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2011 LAMP/EPFL + * @author Stephane Micheloud + * Adapted from Lex Spoon's sbaz manual + */ + package scala.tools.docutil import org.apache.tools.ant.Task @@ -32,9 +38,9 @@ class ManMaker extends Task { } override def execute() { - if (command.isEmpty) error("Attribute 'command' is not set.") - if (htmlout.isEmpty) error("Attribute 'htmlout' is not set.") - if (manout.isEmpty) error("Attribute 'manout' is not set.") + if (command.isEmpty) sys.error("Attribute 'command' is not set.") + if (htmlout.isEmpty) sys.error("Attribute 'htmlout' is not set.") + if (manout.isEmpty) sys.error("Attribute 'manout' is not set.") command foreach (cmd => { val classname = "scala.man1."+ cmd diff --git a/src/manual/scala/tools/docutil/resources/css/style.css b/src/manual/scala/tools/docutil/resources/css/style.css index 3072be4012..62768298cb 100644 --- a/src/manual/scala/tools/docutil/resources/css/style.css +++ b/src/manual/scala/tools/docutil/resources/css/style.css @@ -61,6 +61,19 @@ span.tool { font-weight: bold; } -th { +table.basic { + width: 100%; +} + +table.basic td { + margin: 0; + padding: 2px; +} + +table.basic th { + text-align: left; +} + +table.basic th.links, td.links { white-space: nowrap; } diff --git a/src/manual/scala/tools/docutil/resources/index.html b/src/manual/scala/tools/docutil/resources/index.html index 67913e7aac..4e5130aa3d 100644 --- a/src/manual/scala/tools/docutil/resources/index.html +++ b/src/manual/scala/tools/docutil/resources/index.html @@ -114,11 +114,11 @@ use to create and build applications. </p> -<table cellspacing="0" cellpadding="2" style="width:100%;"> +<table class="basic"> <tr> <th>Tool Name</th> <th>Brief Description</th> - <th>Links to Reference Pages</th> + <th class="links">Links to Reference Pages</th> </tr> <tr> <td width="13%" valign="top"> @@ -127,7 +127,7 @@ <td width="70%" valign="top"> The fast Scala compiler. </td> - <td width="17%" valign="top"> + <td width="17%" valign="top" class="links"> [<a href="fsc.html">Solaris, Linux and Windows</a>] </td> </tr> @@ -138,7 +138,7 @@ <td width="70%" valign="top"> The Scala sharing tool. </td> - <td width="17%" valign="top"> + <td width="17%" valign="top" class="links"> [<a href="sbaz.html">Solaris, Linux and Windows</a>] </td> </tr> @@ -149,7 +149,7 @@ <td width="70%" valign="top"> Run Scala code. </td> - <td width="17%" valign="top"> + <td width="17%" valign="top" class="links"> [<a href="scala.html">Solaris, Linux and Windows</a>] </td> </tr> @@ -160,7 +160,7 @@ <td width="70%" valign="top"> Compile Scala code ahead of time. </td> - <td width="17%" valign="top"> + <td width="17%" valign="top" class="links"> [<a href="scalac.html">Solaris, Linux and Windows</a>] </td> </tr> @@ -171,7 +171,7 @@ <td width="70%" valign="top"> The API document generator. </td> - <td width="17%" valign="top"> + <td width="17%" valign="top" class="links"> [<a href="scaladoc.html">Solaris, Linux and Windows</a>] </td> </tr> @@ -182,7 +182,7 @@ <td width="70%" valign="top"> The Scala class file decoder. </td> - <td width="17%" valign="top"> + <td width="17%" valign="top" class="links"> [<a href="scalap.html">Solaris, Linux and Windows</a>] </td> </tr> diff --git a/src/scalacheck/org/scalacheck/Test.scala b/src/scalacheck/org/scalacheck/Test.scala index 3261862062..0a39707ce0 100644 --- a/src/scalacheck/org/scalacheck/Test.scala +++ b/src/scalacheck/org/scalacheck/Test.scala @@ -259,7 +259,7 @@ object Test { type TestResCallback = (String,Result) => Unit /** @deprecated (v1.8) Use <code>check(prms.copy(testCallback = myCallback), p)</code> instead. */ - @deprecated("(v1.8) Use check(prms.copy(testCallback = myCallback), p) instead") + @deprecated("Use check(prms.copy(testCallback = myCallback), p) instead", "1.8") def check(prms: Params, p: Prop, propCallb: PropEvalCallback): Result = { val testCallback = new TestCallback { override def onPropEval(n: String, t: Int, s: Int, d: Int) = propCallb(s,d) @@ -271,13 +271,13 @@ object Test { * <code>maxDiscarded</code> parameter specifies how many * discarded tests that should be allowed before ScalaCheck * @deprecated (v1.8) Use <code>check(Params(maxDiscardedTests = n, testCallback = ConsoleReporter()), p)</code> instead. */ - @deprecated("(v1.8) Use check(Params(maxDiscardedTests = n, testCallback = ConsoleReporter()), p) instead.") + @deprecated("Use check(Params(maxDiscardedTests = n, testCallback = ConsoleReporter()), p) instead.", "1.8") def check(p: Prop, maxDiscarded: Int): Result = check(Params(maxDiscardedTests = maxDiscarded, testCallback = ConsoleReporter()), p) /** Tests a property and prints results to the console * @deprecated (v1.8) Use <code>check(Params(testCallback = ConsoleReporter()), p)</code> instead. */ - @deprecated("(v1.8) Use check(Params(testCallback = ConsoleReporter()), p) instead.") + @deprecated("Use check(Params(testCallback = ConsoleReporter()), p) instead.", "1.8") def check(p: Prop): Result = check(Params(testCallback = ConsoleReporter()), p) /** Tests all properties with the given testing parameters, and returns @@ -285,7 +285,7 @@ object Test { * time a property is evaluted. <code>g</code> is a function called each * time a property has been fully tested. * @deprecated (v1.8) Use <code>checkProperties(prms.copy(testCallback = myCallback), ps)</code> instead. */ - @deprecated("(v1.8) Use checkProperties(prms.copy(testCallback = myCallback), ps) instead.") + @deprecated("Use checkProperties(prms.copy(testCallback = myCallback), ps) instead.", "1.8") def checkProperties(ps: Properties, prms: Params, propCallb: NamedPropEvalCallback, testCallb: TestResCallback ): Seq[(String,Result)] = { @@ -299,7 +299,7 @@ object Test { /** Tests all properties with the given testing parameters, and returns * the test results. * @deprecated (v1.8) Use checkProperties(prms, ps) instead */ - @deprecated("(v1.8) Use checkProperties(prms, ps) instead") + @deprecated("Use checkProperties(prms, ps) instead", "1.8") def checkProperties(ps: Properties, prms: Params): Seq[(String,Result)] = checkProperties(ps, prms, (n,s,d) => (), (n,s) => ()) @@ -307,7 +307,7 @@ object Test { * the test results. The results are also printed on the console during * testing. * @deprecated (v1.8) Use <code>checkProperties(Params(), ps)</code> instead. */ - @deprecated("(v1.8) Use checkProperties(Params(), ps) instead.") + @deprecated("Use checkProperties(Params(), ps) instead.", "1.8") def checkProperties(ps: Properties): Seq[(String,Result)] = checkProperties(Params(), ps) } |