From a87d9a20e00c4951b774976ef2350d11be764b3d Mon Sep 17 00:00:00 2001 From: michelou Date: Thu, 19 Apr 2007 15:45:58 +0000 Subject: updated for-comprehension syntax --- src/actors/scala/actors/Future.scala | 13 ++++- src/actors/scala/actors/TickedScheduler.scala | 24 +++++--- src/actors/scala/actors/TimerThread.scala | 7 ++- src/build/genprod.scala | 30 +++++----- src/compiler/scala/tools/ant/ScalaBazaar.scala | 10 ++-- src/compiler/scala/tools/ant/Scalac.scala | 2 +- src/compiler/scala/tools/ant/Scaladoc.scala | 6 +- src/compiler/scala/tools/nsc/CompileSocket.scala | 10 ++-- src/compiler/scala/tools/nsc/CompilerCommand.scala | 8 +-- .../scala/tools/nsc/GenericRunnerCommand.scala | 8 +-- src/compiler/scala/tools/nsc/Global.scala | 18 +++--- src/compiler/scala/tools/nsc/Interpreter.scala | 34 +++++------ src/compiler/scala/tools/nsc/InterpreterLoop.scala | 10 ++-- src/compiler/scala/tools/nsc/MainTokenMetric.scala | 10 ++-- src/compiler/scala/tools/nsc/ObjectRunner.scala | 5 +- src/compiler/scala/tools/nsc/ScriptRunner.scala | 14 ++--- .../scala/tools/nsc/symtab/Constants.scala | 5 +- src/compiler/scala/tools/nsc/symtab/Flags.scala | 66 +++++++++++----------- src/compiler/scala/tools/nsc/util/ClassPath.scala | 10 ++-- src/compiler/scala/tools/nsc/util/ListBuffer.scala | 4 +- .../scala/tools/nsc/util/ShowPickled.scala | 7 +-- src/dotnet-library/scala/runtime/RichString.scala | 14 ++--- src/library/scala/Array.scala | 30 +++++----- src/library/scala/List.scala | 26 ++++----- src/library/scala/Responder.scala | 8 +-- src/library/scala/collection/jcl/Buffer.scala | 10 +++- src/library/scala/runtime/RichException.scala | 7 +-- src/library/scala/runtime/RichString.scala | 6 +- src/library/scala/testing/Benchmark.scala | 14 ++--- src/library/scala/testing/SUnit.scala | 14 ++--- src/library/scala/xml/NodeTraverser.scala | 19 ++++--- src/library/scala/xml/PrettyPrinter.scala | 24 ++++---- src/library/scala/xml/TextBuffer.scala | 15 ++--- src/library/scala/xml/Utility.scala | 31 +++++----- src/manual/scala/tools/docutil/EmitHtml.scala | 16 +++--- src/manual/scala/tools/docutil/EmitManPage.scala | 14 ++--- 36 files changed, 273 insertions(+), 276 deletions(-) diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala index f7f4220a15..377e2f826f 100644 --- a/src/actors/scala/actors/Future.scala +++ b/src/actors/scala/actors/Future.scala @@ -1,3 +1,12 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ package scala.actors @@ -58,7 +67,7 @@ object Futures { var cnt = 0 val mappedFts = fts.map(ft => - Pair({cnt=cnt+1; cnt-1}, ft)) + Pair({cnt+=1; cnt-1}, ft)) val unsetFts = mappedFts.filter((p: Pair[int, Future[Any]]) => { if (p._2.isSet) { resultsMap(p._1) = Some(p._2()); false } @@ -101,7 +110,7 @@ object Futures { var results: List[Option[Any]] = Nil val size = resultsMap.size - for (val i <- 0 until size) { + for (i <- 0 until size) { results = resultsMap(size - i - 1) :: results } results diff --git a/src/actors/scala/actors/TickedScheduler.scala b/src/actors/scala/actors/TickedScheduler.scala index c4da9bd298..ffb451c971 100644 --- a/src/actors/scala/actors/TickedScheduler.scala +++ b/src/actors/scala/actors/TickedScheduler.scala @@ -1,12 +1,20 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ -package scala.actors +// $Id: $ -import compat.Platform +package scala.actors -import java.lang.{Runnable, Thread, InterruptedException} +import java.lang.{Thread, InterruptedException} import scala.collection.Set -import scala.collection.mutable.{ArrayBuffer, Buffer, HashMap, Queue, Stack, HashSet} +import scala.collection.mutable.{ArrayBuffer, Buffer, HashMap, Queue} +import scala.compat.Platform /** *

This scheduler uses a thread pool to execute tasks that are generated @@ -30,16 +38,16 @@ class TickedScheduler extends Thread with IScheduler { private var pendingReactions = 0 def pendReaction: unit = synchronized { - pendingReactions = pendingReactions + 1 + pendingReactions += 1 } def unPendReaction: unit = synchronized { - pendingReactions = pendingReactions - 1 + pendingReactions -= 1 } def printActorDump {} def start(task: Reaction): unit = synchronized { - pendingReactions = pendingReactions + 1 + pendingReactions += 1 execute(task) } @@ -48,7 +56,7 @@ class TickedScheduler extends Thread with IScheduler { private var TICK_FREQ = 5 private var CHECK_FREQ = 50 - for (val i <- List.range(0, 2)) { + for (i <- List.range(0, 2)) { val worker = new WorkerThread(this) workers += worker worker.start() diff --git a/src/actors/scala/actors/TimerThread.scala b/src/actors/scala/actors/TimerThread.scala index 7f355761fc..f6a45d98ff 100644 --- a/src/actors/scala/actors/TimerThread.scala +++ b/src/actors/scala/actors/TimerThread.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,9 +11,10 @@ package scala.actors -import compat.Platform import java.lang.{InterruptedException, Runnable, Thread} + import scala.collection.mutable.PriorityQueue +import scala.compat.Platform /** * This class allows the (local) sending of a message to an actor after @@ -50,7 +51,7 @@ object TimerThread { } // process guys waiting for signal and empty list - for (val wa <- lateList) { + for (wa <- lateList) { if (wa.valid) { wa.actor ! TIMEOUT } diff --git a/src/build/genprod.scala b/src/build/genprod.scala index 367809b847..b2f3d2de9d 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -45,19 +45,19 @@ object genprod { def choiceFilename(i: Int) = choiceClassname(i)+".scala" def targs(i: Int) = - for (val j <- List.range(1, i+1)) yield "T" + j + for (j <- List.range(1, i+1)) yield "T" + j def covariantArgs(i: Int) = - for (val t <- targs(i)) yield "+" + t + for (t <- targs(i)) yield "+" + t def contraCoArgs(i: Int) = - (for (val t <- targs(i)) yield "-" + t) ::: List("+R") + (for (t <- targs(i)) yield "-" + t) ::: List("+R") def vdefs(i: Int) = - for (val j <- List.range(1, i+1)) yield "v" + j + for (j <- List.range(1, i+1)) yield "v" + j def mdefs(i: Int) = - for (val j <- List.range(1, i+1)) yield "_" + j + for (j <- List.range(1, i+1)) yield "_" + j def zippedAndCommaSeparated (left: List[String], right: List[String]): String = { @@ -79,16 +79,16 @@ object genprod { def funArgs(i: Int) = zippedAndCommaSeparated(vdefs(i), targs(i)) def productFiles = - for(val i <- List.range(1, SUP_PRODUCT_ARITY)) yield ProductFile.make(i) + for (i <- List.range(1, SUP_PRODUCT_ARITY)) yield ProductFile.make(i) def tupleFiles = - for(val i <- List.range(1, SUP_TUPLE_ARITY)) yield TupleFile.make(i) + for (i <- List.range(1, SUP_TUPLE_ARITY)) yield TupleFile.make(i) def functionFiles = - for(val i <- List.range(0, SUP_FUNCTION_ARITY)) yield FunctionFile.make(i) + for (i <- List.range(0, SUP_FUNCTION_ARITY)) yield FunctionFile.make(i) //def choiceFiles = - // for(val i <- List.range(2, SUP_CHOICE_ARITY)) yield ChoiceFile.make(i) + // for (i <- List.range(2, SUP_CHOICE_ARITY)) yield ChoiceFile.make(i) def allfiles = productFiles ::: tupleFiles ::: functionFiles @@ -101,7 +101,7 @@ object genprod { import java.io.{File, FileOutputStream} import java.nio.channels.Channels val out = args(0) - for (val node <- allfiles) { + for (node <- allfiles) { val f = new File(out + File.separator + node.attributes("name")) try { f.createNewFile @@ -132,7 +132,7 @@ object FunctionFile { /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -239,7 +239,7 @@ object TupleFile { /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -338,11 +338,11 @@ trait {productClassname(i)}{__typeArgs__} extends Product {{ * @throws IndexOutOfBoundsException */ override def productElement(n: Int) = n match {{ - {for(val Tuple2(m, j) <- mdefs(i).zip(List.range(0, i))) + {for (Tuple2(m, j) <- mdefs(i).zip(List.range(0, i))) yield "case "+j+" => "+m+"\n "}case _ => throw new IndexOutOfBoundsException(n.toString()) }} - {for(val Tuple2(m, t) <- mdefs(i) zip targs(i)) yield + {for (Tuple2(m, t) <- mdefs(i) zip targs(i)) yield "/** projection of this product */\n def " + m + ": " + t + "\n\n" } }} diff --git a/src/compiler/scala/tools/ant/ScalaBazaar.scala b/src/compiler/scala/tools/ant/ScalaBazaar.scala index 6d60d98d5a..b3783299fb 100644 --- a/src/compiler/scala/tools/ant/ScalaBazaar.scala +++ b/src/compiler/scala/tools/ant/ScalaBazaar.scala @@ -257,7 +257,7 @@ package scala.tools.ant { {version.get}{ if (!depends.isEmpty) { - for (val depend <- depends) yield + for (depend <- depends) yield {depend} } else Nil @@ -289,13 +289,13 @@ package scala.tools.ant { val zipContent = for { - val Pair(folder, fileSets) <- fileSetsMap.fileSets - val fileSet <- fileSets - val file <- List.fromArray(fileSet.getDirectoryScanner(getProject).getIncludedFiles) + Pair(folder, fileSets) <- fileSetsMap.fileSets + fileSet <- fileSets + file <- List.fromArray(fileSet.getDirectoryScanner(getProject).getIncludedFiles) } yield Triple(folder, fileSet.getDir(getProject), file) val zip = new ZipOutputStream(new FileOutputStream(file.get, false)) if (!zipContent.isEmpty) { - for (val Triple(destFolder, srcFolder, file) <- zipContent) { + for (Triple(destFolder, srcFolder, file) <- zipContent) { log(file, Project.MSG_DEBUG) zip.putNextEntry(new ZipEntry(destFolder + "/" + file)) val input = new FileInputStream(nameToFile(srcFolder)(file)) diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index b06d916eec..069e274239 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -605,7 +605,7 @@ class Scalac extends MatchingTask { while (!args.isEmpty) { val argsBuf = args if (args.head startsWith "-") { - for (val setting <- settings.allSettings) + for (setting <- settings.allSettings) args = setting.tryToSet(args); } else error("Parameter '" + args.head + "' does not start with '-'.") if (argsBuf eq args) diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index 17b2852f52..fd8cfc61d0 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -439,8 +439,8 @@ class Scaladoc extends MatchingTask { // older than the .scala file will be used. val sourceFiles: List[File] = for { - val originDir <- getOrigin - val originFile <- { + originDir <- getOrigin + originFile <- { val includedFiles = getDirectoryScanner(originDir).getIncludedFiles() val list = List.fromArray(includedFiles) @@ -493,7 +493,7 @@ class Scaladoc extends MatchingTask { while (!args.isEmpty) { val argsBuf = args if (args.head startsWith "-") { - for (val setting <- settings.allSettings) + for (setting <- settings.allSettings) args = setting.tryToSet(args); } else error("Parameter '" + args.head + "' does not start with '-'.") if (argsBuf eq args) diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index d71347631f..a5a5f178e3 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -79,10 +79,10 @@ object CompileSocket { val potentials = for { - val trial <- totry + trial <- totry val expanded = expand(trial) - !expanded.isEmpty - isDirWritable(expanded.get) + if !expanded.isEmpty + if isDirWritable(expanded.get) } yield expanded.get @@ -138,7 +138,7 @@ object CompileSocket { if (hits.length == 0) -1 else try { - for (val i <- 1 until hits.length) hits(i).delete() + for (i <- 1 until hits.length) hits(i).delete() hits(0).getName.toInt } catch { case ex: NumberFormatException => @@ -159,7 +159,7 @@ object CompileSocket { if (port < 0) startNewServer(vmArgs) while (port < 0 && attempts < MaxAttempts) { - attempts = attempts + 1 + attempts += 1 Thread.sleep(sleepTime) port = pollPort() } diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 081af5b921..e34cf8c5b5 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -7,8 +7,6 @@ package scala.tools.nsc -import compat.StringBuilder - /** A class representing command line info for scalac */ class CompilerCommand(arguments: List[String], val settings: Settings, error: String => unit, interactive: boolean) { @@ -31,7 +29,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings, def format(s: String): String = { val buf = new StringBuilder(s) var i = s.length() - while (i < helpSyntaxColumnWidth) { buf.append(' '); i = i + 1 } + while (i < helpSyntaxColumnWidth) { buf.append(' '); i += 1 } buf.toString() } settings.allSettings @@ -55,7 +53,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings, ok = false } else { val args0 = args - for (val setting <- settings.allSettings) + for (setting <- settings.allSettings) if (args eq args0) args = setting.tryToSet(args) diff --git a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala index 9cd2e528e3..26742f5a88 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006 LAMP/EPFL + * Copyright 2007 LAMP/EPFL * @author Lex Spoon */ @@ -29,8 +29,8 @@ class GenericRunnerCommand(allargs: List[String], error: String => Unit) { while (!args.isEmpty && ok && args.head.startsWith("-")) { val args0 = args - for (val setting <- settings.allSettings) - if(args eq args0) + for (setting <- settings.allSettings) + if (args eq args0) args = setting.tryToSet(args) if (args eq args0) { error("unknown option: '" + args.head + "'") @@ -38,7 +38,7 @@ class GenericRunnerCommand(allargs: List[String], error: String => Unit) { } } - if(!args.isEmpty) { + if (!args.isEmpty) { thingToRun = Some(args.head) arguments = args.tail } diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 4df833f002..fb6d3ff139 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -204,8 +204,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable val global: Global.this.type = Global.this } - def rootLoader: LazyType = if (forMSIL) new loaders.NamespaceLoader(classPath.root) - else new loaders.PackageLoader(classPath.root /* getRoot() */) + def rootLoader: LazyType = + if (forMSIL) new loaders.NamespaceLoader(classPath.root) + else new loaders.PackageLoader(classPath.root /* getRoot() */) val migrateMsg = "migration problem when moving from Scala version 1.0 to version 2.0:\n" @@ -215,8 +216,8 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable val MaxPhases = 64 - val phaseWithId = new Array[Phase](MaxPhases); - { for (val i <- List.range(0, MaxPhases)) phaseWithId(i) = NoPhase } + val phaseWithId = new Array[Phase](MaxPhases) + for (i <- List.range(0, MaxPhases)) phaseWithId(i) = NoPhase abstract class GlobalPhase(prev: Phase) extends Phase(prev) { phaseWithId(id) = this @@ -412,7 +413,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable private var p: Phase = firstPhase - for (val pd <- phaseDescriptors.takeWhile(pd => !(settings.stop contains pd.phaseName))) + for (pd <- phaseDescriptors.takeWhile(pd => !(settings.stop contains pd.phaseName))) if (!(settings.skip contains pd.phaseName)) p = pd.newPhase(p) def cancel { reporter.cancelled = true } @@ -482,8 +483,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable def compileSources(sources: List[SourceFile]): unit = { val startTime = currentTime reporter.reset - for (val source <- sources) - addUnit(new CompilationUnit(source)) + for (source <- sources) addUnit(new CompilationUnit(source)) globalPhase = firstPhase while (globalPhase != terminalPhase && !reporter.hasErrors) { @@ -511,7 +511,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable showDef(newTermName(settings.Xshowobj.value), true) if (reporter.hasErrors) { - for (val (sym, file) <- symSource.elements) { + for ((sym, file) <- symSource.elements) { sym.reset(new loaders.SourcefileLoader(file)) if (sym.isTerm) sym.moduleClass.reset(loaders.moduleClassLoader) } @@ -524,7 +524,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable warning("there were unchecked warnings; re-run with -unchecked for details") } } - for (val (sym, file) <- symSource.elements) resetPackageClass(sym.owner) + for ((sym, file) <- symSource.elements) resetPackageClass(sym.owner) //units foreach (.clear()) informTime("total", startTime) } diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 4b385cf604..6ee45b4676 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -1,13 +1,13 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ package scala.tools.nsc -import java.lang.{Class, ClassLoader} import java.io.{File, PrintWriter, StringWriter} +import java.lang.{Class, ClassLoader} import java.net.{URL, URLClassLoader} import scala.collection.mutable @@ -281,7 +281,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) // loop through previous requests, adding imports // for each one - for(val req <- reqsToUse) { + for (req <- reqsToUse) { req match { case req:ImportReq => // If the user entered an import, then just use it @@ -305,8 +305,8 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) // For other requests, import each bound variable. // import them explicitly instead of with _, so that // ambiguity errors will not be generated. - for(val imv <- req.boundNames) { - if(currentImps.contains(imv)) + for (imv <- req.boundNames) { + if (currentImps.contains(imv)) addWrapper() code.append("import ") code.append(req.objectName + req.accessPath + "." + imv + ";\n") @@ -543,18 +543,14 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) /** list of methods defined */ val defNames = - for { - val DefDef(mods, name, _, _, _, _) <- trees - mods.isPublic - } yield name + for (DefDef(mods, name, _, _, _, _) <- trees if mods.isPublic) + yield name /** list of val's and var's defined */ val valAndVarNames = { val baseNames = - for { - val ValDef(mods, name, _, _) <- trees - mods.isPublic - } yield name + for (ValDef(mods, name, _, _) <- trees if mods.isPublic) + yield name if (needsVarName) compiler.encode(varName) :: baseNames // add a var name @@ -565,7 +561,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) /** list of modules defined */ val moduleNames = { val explicit = - for(val ModuleDef(mods, name, _) <- trees; mods.isPublic) + for (ModuleDef(mods, name, _) <- trees if mods.isPublic) yield name val caseClasses = for {val ClassDef(mods, name, _, _, _) <- trees @@ -577,12 +573,12 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) /** list of classes defined */ val classNames = - for (val ClassDef(mods, name, _, _, _) <- trees; mods.isPublic) + for (ClassDef(mods, name, _, _, _) <- trees if mods.isPublic) yield name /** list of type aliases defined */ val typeNames = - for (val AliasTypeDef(mods, name, _, _) <- trees; mods.isPublic) + for (AliasTypeDef(mods, name, _, _) <- trees if mods.isPublic) yield name /** all (public) names defined by these statements */ @@ -655,7 +651,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) }) def resultExtractionCode(code: PrintWriter): Unit = - for (val vname <- valAndVarNames) { + for (vname <- valAndVarNames) { code.print(" + \"" + vname + ": " + typeOf(vname) + " = \" + " + objectName + accessPath + "." + vname + " + \"\\n\"") @@ -752,7 +748,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) /** return a summary of the defined methods */ def defTypesSummary: String = stringFrom(summ => { - for (val methname <- defNames) + for (methname <- defNames) summ.println("" + methname + ": " + typeOf(methname)) }) } @@ -871,7 +867,7 @@ object Interpreter { path match { case _ if !path.exists => {} case _ if path.isDirectory => - for (val p <- path.listFiles) + for (p <- path.listFiles) deleteRecursively(p) path.delete case _ => path.delete diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index 15c984a034..b50633d043 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -12,7 +12,7 @@ import java.io.{BufferedReader, InputStreamReader, File, FileReader, PrintWriter import java.io.IOException import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} -import scala.tools.nsc.util.{Position} +import scala.tools.nsc.util.Position import nsc.{InterpreterResults=>IR} /** The main loop of the command-line interface to the @@ -118,7 +118,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { out.print("\nscala> ") out.flush } - if(first) { + if (first) { /* For some reason, the first interpreted command always takes * a second or two. So, wait until the welcome message * has been printed before calling bindSettings. That way, @@ -173,7 +173,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { def replay() { closeInterpreter createInterpreter - for (val cmd <- replayCommands) { + for (cmd <- replayCommands) { out.println("Replaying: " + cmd) command(cmd) out.println @@ -215,9 +215,9 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { shouldReplay = Some(line) }) } - else if (line.matches(replayRegexp)) + else if (line matches replayRegexp) replay - else if (line.startsWith(":")) + else if (line startsWith ":") out.println("Unknown command. Type :help for help.") else shouldReplay = interpretStartingWith(line) diff --git a/src/compiler/scala/tools/nsc/MainTokenMetric.scala b/src/compiler/scala/tools/nsc/MainTokenMetric.scala index 05b0f3c33c..1f1632fd48 100644 --- a/src/compiler/scala/tools/nsc/MainTokenMetric.scala +++ b/src/compiler/scala/tools/nsc/MainTokenMetric.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -16,20 +16,20 @@ object MainTokenMetric { private var reporter: ConsoleReporter = _ - def tokenMetric(compiler: Global, fnames: List[String]): unit = { + private def tokenMetric(compiler: Global, fnames: List[String]) { import compiler.CompilationUnit import compiler.syntaxAnalyzer.UnitScanner import ast.parser.Tokens.EOF var totale = 0 - for (val source <- fnames) { + for (source <- fnames) { val s = new UnitScanner(new CompilationUnit(compiler.getSourceFile(source))) var i = 0 while(s.token != EOF) { - i = i + 1 + i += 1 s.nextToken } var j = 0 ; while(j + log(i) / log(10) < 7) { - j = j+1 + j += 1 Console.print(' ') } Console.print(i.toString()) diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala index 7e3442ce02..5bafbd7cc7 100644 --- a/src/compiler/scala/tools/nsc/ObjectRunner.scala +++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Lex Spoon */ @@ -7,9 +7,8 @@ package scala.tools.nsc -import java.lang.Class -import java.lang.{ClassNotFoundException, NoSuchMethodException} import java.io.File +import java.lang.{Class, ClassNotFoundException, NoSuchMethodException} import java.lang.reflect.{Method,Modifier} import java.net.URLClassLoader diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 6ee8348600..40ad350fda 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -8,10 +8,9 @@ package scala.tools.nsc import java.io.{BufferedReader, File, FileInputStream, FileOutputStream, FileReader, InputStreamReader, PrintWriter} -import java.util.jar.{JarEntry, JarOutputStream} import java.lang.reflect.InvocationTargetException +import java.util.jar.{JarEntry, JarOutputStream} -import compat.StringBuilder import scala.tools.nsc.io.PlainFile import scala.tools.nsc.reporters.ConsoleReporter import scala.tools.nsc.util.{CompoundSourceFile, SourceFile, SourceFileFragment} @@ -67,7 +66,7 @@ object ScriptRunner { val buf = new Array[byte](10240) def addFromDir(dir: File, prefix: String): Unit = { - for (val entry <- dir.listFiles) { + for (entry <- dir.listFiles) { if (entry.isFile) { jar.putNextEntry(new JarEntry(prefix + entry.getName)) @@ -165,16 +164,13 @@ object ScriptRunner { scriptFileIn: String): Boolean = { val scriptFile = CompileClient.absFileName(scriptFileIn) - for { - val setting:settings.StringSetting <- List( + for (setting:settings.StringSetting <- List( settings.classpath, settings.sourcepath, settings.bootclasspath, settings.extdirs, - settings.outdir) - } { + settings.outdir)) setting.value = CompileClient.absFileNames(setting.value) - } val compSettingNames = (new Settings(error)).allSettings.map(.name) diff --git a/src/compiler/scala/tools/nsc/symtab/Constants.scala b/src/compiler/scala/tools/nsc/symtab/Constants.scala index 1bc5ddc489..e622d85d47 100644 --- a/src/compiler/scala/tools/nsc/symtab/Constants.scala +++ b/src/compiler/scala/tools/nsc/symtab/Constants.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -8,7 +8,6 @@ package scala.tools.nsc.symtab import java.lang.Integer.toOctalString -import compat.StringBuilder import classfile.PickleFormat._ @@ -200,7 +199,7 @@ trait Constants { def escapedStringValue: String = { def escape(text: String): String = { val buf = new StringBuilder - for (val c <- Iterator.fromString(text)) + for (c <- Iterator.fromString(text)) if (c.isControl) buf.append("\\0" + toOctalString(c.asInstanceOf[Int])) else diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala index 89d5060a88..ebe587acae 100644 --- a/src/compiler/scala/tools/nsc/symtab/Flags.scala +++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -128,7 +128,7 @@ object Flags extends Enumeration { ss.filter("" !=).mkString("", " ", "") def flagsToString(flags: long): String = - listToString(for (val i <- List.range(0, 63)) yield flagToString(flags & (1L << i))) + listToString(for (i <- List.range(0, 63)) yield flagToString(flags & (1L << i))) def flagsToString(flags: long, privateWithin: String): String = { var f = flags @@ -210,36 +210,36 @@ object Flags extends Enumeration { def isVariable = (mods & MUTABLE) != 0 def isPublic = !isPrivate && !isProtected } - case class FlagEnum(mask : Int) extends Val(maskToBit(mask), flagToString(mask)); - - val Implicit = FlagEnum(IMPLICIT) - val Final = FlagEnum(FINAL) - val Private = FlagEnum(PRIVATE) - val Protected= FlagEnum(PROTECTED) - val Sealed = FlagEnum(SEALED) - val Override = FlagEnum(OVERRIDE) - val Case = FlagEnum(CASE) - val Abstract = FlagEnum(ABSTRACT) - val Deferred = FlagEnum(DEFERRED) - val Method = FlagEnum(METHOD) - val Module = FlagEnum(MODULE) - val Interface= FlagEnum(INTERFACE) - val Mutable = FlagEnum(MUTABLE) - val Param = FlagEnum(PARAM) - val Package = FlagEnum(PACKAGE) - val Deprecated=FlagEnum(DEPRECATED) - val Covariant=FlagEnum(COVARIANT) - val Contravariant=FlagEnum(CONTRAVARIANT) - val AbsOverride=FlagEnum(ABSOVERRIDE) - val Local=FlagEnum(LOCAL) - val Synthetic=FlagEnum(SYNTHETIC) - val Stable=FlagEnum(STABLE) - val CaseAccessor=FlagEnum(CASEACCESSOR) - val Trait=FlagEnum(TRAIT) - val Bridge=FlagEnum(BRIDGE) - val Accessor=FlagEnum(ACCESSOR) - val SuperAccessor=FlagEnum(SUPERACCESSOR) - val ParamAccessor=FlagEnum(PARAMACCESSOR) - val ModuleVar=FlagEnum(MODULEVAR) + case class FlagEnum(mask: Int) extends Val(maskToBit(mask), flagToString(mask)) + + val Implicit = FlagEnum(IMPLICIT) + val Final = FlagEnum(FINAL) + val Private = FlagEnum(PRIVATE) + val Protected = FlagEnum(PROTECTED) + val Sealed = FlagEnum(SEALED) + val Override = FlagEnum(OVERRIDE) + val Case = FlagEnum(CASE) + val Abstract = FlagEnum(ABSTRACT) + val Deferred = FlagEnum(DEFERRED) + val Method = FlagEnum(METHOD) + val Module = FlagEnum(MODULE) + val Interface = FlagEnum(INTERFACE) + val Mutable = FlagEnum(MUTABLE) + val Param = FlagEnum(PARAM) + val Package = FlagEnum(PACKAGE) + val Deprecated = FlagEnum(DEPRECATED) + val Covariant = FlagEnum(COVARIANT) + val Contravariant = FlagEnum(CONTRAVARIANT) + val AbsOverride = FlagEnum(ABSOVERRIDE) + val Local = FlagEnum(LOCAL) + val Synthetic = FlagEnum(SYNTHETIC) + val Stable = FlagEnum(STABLE) + val CaseAccessor = FlagEnum(CASEACCESSOR) + val Trait = FlagEnum(TRAIT) + val Bridge = FlagEnum(BRIDGE) + val Accessor = FlagEnum(ACCESSOR) + val SuperAccessor = FlagEnum(SUPERACCESSOR) + val ParamAccessor = FlagEnum(PARAMACCESSOR) + val ModuleVar = FlagEnum(MODULEVAR) } diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index af89eb1603..2707e1675d 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -53,8 +53,8 @@ class ClassPath(onlyPresentation: Boolean) { } class Context(val entries: List[Entry]) { - def find(name: String, isDir: Boolean) : Context = if (isPackage) { - def find0(entries: List[Entry]) : Context = { + def find(name: String, isDir: Boolean): Context = if (isPackage) { + def find0(entries: List[Entry]): Context = { if (entries.isEmpty) new Context(Nil) else { val ret = find0(entries.tail) @@ -240,7 +240,7 @@ class ClassPath(onlyPresentation: Boolean) { while (strtok.hasMoreTokens()) { val file = AbstractFile.getDirectory(strtok.nextToken()) if (file ne null) { - for (val file0 <- file) { + for (file0 <- file) { val name = file0.name if (name.endsWith(".jar") || name.endsWith(".zip") || file0.isDirectory) { val archive = AbstractFile.getDirectory(new File(file.file, name)) diff --git a/src/compiler/scala/tools/nsc/util/ListBuffer.scala b/src/compiler/scala/tools/nsc/util/ListBuffer.scala index c4b90fa316..348b3f5700 100644 --- a/src/compiler/scala/tools/nsc/util/ListBuffer.scala +++ b/src/compiler/scala/tools/nsc/util/ListBuffer.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -18,7 +18,7 @@ class ListBuffer[T] extends Iterator[T] { } def ++=(xs: Iterable[T]): unit = - for (val x <- xs.elements) +=(x) + for (x <- xs.elements) +=(x) def +(x: T): ListBuffer[T] = { +=(x); this } def ++(xs: Iterable[T]): ListBuffer[T] = { ++=(xs); this } diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala index df7374778a..617ab47e47 100644 --- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala +++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -62,7 +62,7 @@ object ShowPickled extends Names { case _ => "***BAD TAG***(" + tag + ")" } - def printFile(buf: PickleBuffer, out: PrintStream): unit = { + def printFile(buf: PickleBuffer, out: PrintStream) { out.println("Version " + buf.readNat() + "." + buf.readNat()) val index = buf.createIndex @@ -169,8 +169,7 @@ object ShowPickled extends Names { ", factual = " + buf.readIndex) } - for (val i <- 0 until index.length) - printEntry(i) + for (i <- 0 until index.length) printEntry(i) } def main(args: Array[String]): unit = { diff --git a/src/dotnet-library/scala/runtime/RichString.scala b/src/dotnet-library/scala/runtime/RichString.scala index 0e0fc90ab1..1073acfe07 100644 --- a/src/dotnet-library/scala/runtime/RichString.scala +++ b/src/dotnet-library/scala/runtime/RichString.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -83,8 +83,8 @@ final class RichString(val self: String) extends Proxy with Seq[Char] with Order def next(): String = { if (index >= len) throw new NoSuchElementException("next on empty iterator") val start = index - while (index < len && !isLineBreak(apply(index))) index = index + 1 - index = index + 1 + while (index < len && !isLineBreak(apply(index))) index += 1 + index += 1 self.substring(start, index min len) } } @@ -113,10 +113,10 @@ final class RichString(val self: String) extends Proxy with Seq[Char] with Order */ def stripMargin(marginChar: Char): String = { val buf = new scala.compat.StringBuilder() - for (val line <- linesWithSeparators) { + for (line <- linesWithSeparators) { val len = line.length - var index = 0; - while (index < len && line.charAt(index) <= ' ') index = index + 1 + var index = 0 + while (index < len && line.charAt(index) <= ' ') index += 1 buf append (if (index < len && line.charAt(index) == marginChar) line.substring(index + 1) else line) } diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index 55c9d4d0a1..aed67110ea 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -51,12 +51,10 @@ object Array { */ def concat[T](xs: Array[T]*) = { var len = 0 - for (val x <- xs) { - len += x.length - } + for (x <- xs) len += x.length val result = new Array[T](len) var start = 0 - for (val x <- xs) { + for (x <- xs) { copy(x, 0, result, start, x.length) start += x.length } @@ -71,7 +69,7 @@ object Array { */ def range(start: Int, end: Int): Array[Int] = { val result = new Array[Int](end - start) - for (val i <- Iterator.range(start, end)) result(i - start) = i + for (i <- start until end) result(i - start) = i result } @@ -83,7 +81,7 @@ object Array { def apply[A <: AnyRef](xs: A*): Array[A] = { val array = new Array[A](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } @@ -99,7 +97,7 @@ object Array { def Array[A](xs: A*): Array[A] = { val array = new Array[A](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } */ @@ -107,55 +105,55 @@ object Array { def apply(xs: Boolean*): Array[Boolean] = { val array = new Array[Boolean](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Byte*): Array[Byte] = { val array = new Array[Byte](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Short*): Array[Short] = { val array = new Array[Short](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Char*): Array[Char] = { val array = new Array[Char](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Int*): Array[Int] = { val array = new Array[Int](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Long*): Array[Long] = { val array = new Array[Long](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Float*): Array[Float] = { val array = new Array[Float](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Double*): Array[Double] = { val array = new Array[Double](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Unit*): Array[Unit] = { val array = new Array[Unit](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index e34189cd44..12fce2c20b 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -54,7 +54,7 @@ object List { var i = from while (i < end) { b += i - i = i + step + i += step } b.toList } @@ -71,7 +71,7 @@ object List { var i = from while (i < end) { b += i - i = i + step(i) + i += step(i) } b.toList } @@ -87,7 +87,7 @@ object List { var i = 0 while (i < n) { b += elem - i = i + 1 + i += 1 } b.toList } @@ -106,7 +106,7 @@ object List { var i = 0 while (i < n) { b += maker(i) - i = i + 1 + i += 1 } b.toList } @@ -125,7 +125,7 @@ object List { */ def concat[a](xss: List[a]*): List[a] = { val b = new ListBuffer[a] - for (val xs <- xss) { + for (xs <- xss) { var xc = xs while (!xc.isEmpty) { b += xc.head @@ -180,7 +180,7 @@ object List { var res: List[a] = Nil var i = start + len while (i > start) { - i = i - 1 + i -= 1 res = arr(i) :: res } res @@ -452,7 +452,7 @@ sealed abstract class List[+a] extends Seq[a] { var these = this var len = 0 while (!these.isEmpty) { - len = len + 1 + len += 1 these = these.tail } len @@ -469,7 +469,7 @@ sealed abstract class List[+a] extends Seq[a] { var these = this while (!these.isEmpty) { b += i - i = i + 1 + i += 1 these = these.tail } b.toList @@ -537,7 +537,7 @@ sealed abstract class List[+a] extends Seq[a] { var i = 0 var these = this while (!these.isEmpty && i < n) { - i = i + 1 + i += 1 b += these.head these = these.tail } @@ -592,7 +592,7 @@ sealed abstract class List[+a] extends Seq[a] { var i = 0 var these = this while (!these.isEmpty && i < n) { - i = i + 1 + i += 1 b += these.head these = these.tail } @@ -716,7 +716,7 @@ sealed abstract class List[+a] extends Seq[a] { if (these.isEmpty) this else { val b = new ListBuffer[a] - var these1 = this; + var these1 = this while (these1 ne these) { b += these1.head these1 = these1.tail @@ -839,7 +839,7 @@ sealed abstract class List[+a] extends Seq[a] { var cnt = 0 var these = this while (!these.isEmpty) { - if (p(these.head)) cnt = cnt + 1 + if (p(these.head)) cnt += 1 these = these.tail } cnt @@ -1020,7 +1020,7 @@ sealed abstract class List[+a] extends Seq[a] { while(!these.isEmpty) { b += (these.head, idx) these = these.tail - idx = idx + 1 + idx += 1 } b.toList diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala index 050caa342e..da9e215ed3 100644 --- a/src/library/scala/Responder.scala +++ b/src/library/scala/Responder.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -47,10 +47,10 @@ object Responder { } def loop[a](r: Responder[unit]): Responder[Nothing] = - for (val _ <- r; val y <- loop(r)) yield y + for (_ <- r; val y <- loop(r)) yield y def loopWhile[a](cond: => boolean)(r: Responder[unit]): Responder[unit] = - if (cond) for (val _ <- r; val y <- loopWhile(cond)(r)) yield y + if (cond) for (_ <- r; val y <- loopWhile(cond)(r)) yield y else constant(()) } diff --git a/src/library/scala/collection/jcl/Buffer.scala b/src/library/scala/collection/jcl/Buffer.scala index 15033867e9..d7513cc314 100644 --- a/src/library/scala/collection/jcl/Buffer.scala +++ b/src/library/scala/collection/jcl/Buffer.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -18,18 +18,24 @@ trait Buffer[A] extends MutableSeq[A] with Collection[A] with Ranged[Int,A] { final protected type SortedSelf = Buffer[A]; trait MutableSeqProjection extends super[MutableSeq].Projection; + trait Projection extends MutableSeqProjection with super[Collection].Projection { override def filter(p : A => Boolean) = super[MutableSeqProjection].filter(p); } + override def projection = new Projection {} override def elements : BufferIterator[Int,A]; + /** The first index of a buffer is 0. */ override def first = 0; + /** The last index of a buffer is its size - 1. */ override def last = size - 1; + /** Indices are compared through subtraction. */ final def compare(k0 : Int, k1 : Int) = k0 - k1; + /** Removes the element at index "idx" */ def remove(idx : Int) = { val i = elements; @@ -69,7 +75,7 @@ trait Buffer[A] extends MutableSeq[A] with Collection[A] with Ranged[Int,A] { */ def addAll(idx: Int, that: Iterable[A]): Unit = { val i = elements; i.seek(idx); - for (val that <- that) { + for (that <- that) { i.add(that); i.next; } } diff --git a/src/library/scala/runtime/RichException.scala b/src/library/scala/runtime/RichException.scala index 99f5311446..a9559aa639 100644 --- a/src/library/scala/runtime/RichException.scala +++ b/src/library/scala/runtime/RichException.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -12,14 +12,13 @@ package scala.runtime import Predef._ -import compat.StringBuilder import compat.Platform.EOL final class RichException(exc: Throwable) { def getStackTraceString: String = { val s = new StringBuilder() - for (val trElem <- exc.getStackTrace()) { + for (trElem <- exc.getStackTrace()) { s.append(trElem.toString()) s.append(EOL) } diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index 375e096631..6786e1e692 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -113,7 +113,7 @@ final class RichString(val self: String) extends Proxy with Seq[Char] with Order */ def stripMargin(marginChar: Char): String = { val buf = new scala.compat.StringBuilder() - for (val line <- linesWithSeparators) { + for (line <- linesWithSeparators) { val len = line.length var index = 0; while (index < len && line.charAt(index) <= ' ') index = index + 1 diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala index 4d7cc751cf..77c5613572 100644 --- a/src/library/scala/testing/Benchmark.scala +++ b/src/library/scala/testing/Benchmark.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -50,11 +50,11 @@ trait Benchmark { * @return ... */ def runBenchmark(noTimes: Int): List[Long] = - for (val i <- List.range(1, noTimes + 1)) yield { + for (i <- List.range(1, noTimes + 1)) yield { val startTime = Platform.currentTime - var i = 0; while(i < multiplier) { + var i = 0; while (i < multiplier) { run() - i = i + 1 + i += 1 } val stopTime = Platform.currentTime Platform.collectGarbage @@ -70,10 +70,10 @@ trait Benchmark { def main(args: Array[String]): Unit = { if (args.length > 1) { val logFile = new java.io.FileWriter(args(1), true) // append, not overwrite - if(args.length >= 3) + if (args.length >= 3) multiplier = args(2).toInt logFile.write(getClass().getName()) - for (val t <- runBenchmark(args(0).toInt)) + for (t <- runBenchmark(args(0).toInt)) logFile.write("\t\t" + t) logFile.write(Platform.EOL) diff --git a/src/library/scala/testing/SUnit.scala b/src/library/scala/testing/SUnit.scala index 07a7fa0d1b..7c0f76303c 100644 --- a/src/library/scala/testing/SUnit.scala +++ b/src/library/scala/testing/SUnit.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -12,7 +12,6 @@ package scala.testing import scala.collection.mutable.ArrayBuffer -import compat.StringBuilder /** *

@@ -36,7 +35,7 @@ import compat.StringBuilder * * val r = new TestResult() * suite.run(r) - * for (val tf <- r.failures()) { + * for (tf <- r.failures()) { * Console.println(tf.toString()) * } * @@ -56,7 +55,7 @@ object SUnit { def main(args:Array[String]) { val r = new TestResult() suite.run(r) - for (val tf <- r.failures()) + for (tf <- r.failures()) Console.println(tf.toString()) } } @@ -131,10 +130,7 @@ object SUnit { buf += t def run(r: TestResult): Unit = - for(val t <- buf) { - t.run(r) - } - + for (t <- buf) t.run(r) } /** an AssertFailed is thrown for a failed assertion */ diff --git a/src/library/scala/xml/NodeTraverser.scala b/src/library/scala/xml/NodeTraverser.scala index f6fac46bb4..5cbf0aca30 100644 --- a/src/library/scala/xml/NodeTraverser.scala +++ b/src/library/scala/xml/NodeTraverser.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -19,14 +19,17 @@ package scala.xml abstract class NodeTraverser extends parsing.MarkupHandler { def traverse(n: Node): Unit = n match { - case x:ProcInstr => procInstr(0, x.target, x.text) - case x:Comment => comment(0, x.text) - case x:Text => text(0, x.data) - case x:EntityRef => entityRef(0, x.entityName) + case x:ProcInstr => + procInstr(0, x.target, x.text) + case x:Comment => + comment(0, x.text) + case x:Text => + text(0, x.data) + case x:EntityRef => + entityRef(0, x.entityName) case _ => elemStart(0, n.prefix, n.label, n.attributes, n.scope) - for (val m <- n.child) - traverse(m) + for (m <- n.child) traverse(m) elem(0, n.prefix, n.label, n.attributes, n.scope, NodeSeq.fromSeq(n.child)) elemEnd(0, n.prefix, n.label) } diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index 05724ade14..ad3f26c2ed 100644 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -86,10 +86,10 @@ class PrettyPrinter( width:Int, step:Int ) { if (cur < ind) cur == ind if (cur + s.length() > width) { // fits in this line - items = Box( ind, s ) :: items - cur = cur + s.length() + items = Box(ind, s) :: items + cur += s.length() } else try { - for (val b <- cut(s, ind).elements) // break it up + for (b <- cut(s, ind).elements) // break it up items = b :: items } catch { case _:BrokenException => makePara(ind, s) // give up, para @@ -187,9 +187,9 @@ class PrettyPrinter( width:Int, step:Int ) { val sq:Seq[String] = stg.split(" "); val it = sq.elements; it.next; - for( val c <- it ) { - makeBox( ind+len2-2, c ); - makeBreak(); + for(c <- it) { + makeBox( ind+len2-2, c ); + makeBreak(); } }*/ makeBox(ind, stg.substring(len2, stg.length())) @@ -205,7 +205,7 @@ class PrettyPrinter( width:Int, step:Int ) { } protected def traverse(it: Iterator[Node], scope: NamespaceBinding, ind: Int ): Unit = - for (val c <- it) { + for (c <- it) { traverse(c, scope, ind) makeBreak() } @@ -225,7 +225,7 @@ class PrettyPrinter( width:Int, step:Int ) { reset() traverse(n, pscope, 0) var cur = 0 - for (val b <- items.reverse) b match { + for (b <- items.reverse) b match { case Break => if (!lastwasbreak) sb.append('\n') // on windows: \r\n ? lastwasbreak = true @@ -239,7 +239,7 @@ class PrettyPrinter( width:Int, step:Int ) { lastwasbreak = false while (cur < i) { sb.append(' ') - cur = cur + 1 + cur += 1 } sb.append(s) case Para( s ) => @@ -299,7 +299,7 @@ class PrettyPrinter( width:Int, step:Int ) { * @param sb the string buffer to which to append to */ def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding, sb: StringBuilder): Unit = - for (val n <- nodes.elements) { + for (n <- nodes.elements) { sb.append(format(n, pscope)) } diff --git a/src/library/scala/xml/TextBuffer.scala b/src/library/scala/xml/TextBuffer.scala index 7831b38621..f48d04ece9 100644 --- a/src/library/scala/xml/TextBuffer.scala +++ b/src/library/scala/xml/TextBuffer.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -13,8 +13,7 @@ package scala.xml object TextBuffer { - def fromString(str: String): TextBuffer = - new TextBuffer().append(str) + def fromString(str: String): TextBuffer = new TextBuffer().append(str) } /** The class TextBuffer is for creating text nodes without @@ -36,12 +35,8 @@ class TextBuffer { * @return ... */ def append(cs: Seq[Char]): TextBuffer = { - for (val c <- cs) { - if (Utility.isSpace(c)) - appendSpace - else - appendChar(c) - } + for (c <- cs) + if (Utility.isSpace(c)) appendSpace else appendChar(c) this } @@ -54,7 +49,7 @@ class TextBuffer { if (len == 0) return Nil if (Utility.isSpace(sb.charAt(len - 1))) { - len = len - 1 + len -= 1 sb.setLength(len) } if (len == 0) return Nil diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index c0b28b89ae..f3cb5f4964 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,7 +11,6 @@ package scala.xml -import compat.StringBuilder import collection.mutable.{Set, HashSet} /** @@ -76,7 +75,7 @@ object Utility extends AnyRef with parsing.TokenTests { * @return ... */ final def escape(text: String, s: StringBuilder): StringBuilder = { - for (val c <- Iterator.fromString(text)) c match { + for (c <- Iterator.fromString(text)) c match { case '<' => s.append("<") case '>' => s.append(">") case '&' => s.append("&") @@ -130,13 +129,13 @@ object Utility extends AnyRef with parsing.TokenTests { def collectNamespaces(n: Node, set: Set[String]): Unit = { if (n.typeTag$ >= 0) { set += n.namespace - for (val a <- n.attributes) a match { + for (a <- n.attributes) a match { case _:PrefixedAttribute => set += a.getNamespace(n) case _ => } - for (val i <- n.child) - collectNamespaces(i, set); + for (i <- n.child) + collectNamespaces(i, set) } } @@ -186,17 +185,13 @@ object Utility extends AnyRef with parsing.TokenTests { x.toString(sb) case g: Group => - for (val c <- g.nodes) { - toXML(c, x.scope, sb, stripComment) - } + for (c <- g.nodes) toXML(c, x.scope, sb, stripComment) case _ => // print tag with namespace declarations sb.append('<') x.nameToString(sb) - if (x.attributes ne null) { - x.attributes.toString(sb) - } + if (x.attributes ne null) x.attributes.toString(sb) x.scope.toString(sb, pscope) sb.append('>') sequenceToXML(x.child, pscope, sb, stripComment) @@ -225,8 +220,8 @@ object Utility extends AnyRef with parsing.TokenTests { sb.append(' ') toXML(x, x.scope, sb, stripComment) } - } else for (val c <- children) { - toXML(c, c.scope, sb, stripComment) + } else { + for (c <- children) toXML(c, c.scope, sb, stripComment) } } @@ -238,7 +233,7 @@ object Utility extends AnyRef with parsing.TokenTests { */ final def prefix(name: String): Option[String] = { val i = name.indexOf(':'.asInstanceOf[Int]) - if( i != -1 ) Some( name.substring(0, i) ) else None + if (i != -1) Some(name.substring(0, i)) else None } /** @@ -330,7 +325,7 @@ object Utility extends AnyRef with parsing.TokenTests { */ def appendEscapedQuoted(s: String, sb: StringBuilder) = { sb.append('"') - for (val c <- s) c match { + for (c <- s) c match { case '"' => sb.append('\\'); sb.append('"') case _ => sb.append(c) } @@ -370,7 +365,7 @@ object Utility extends AnyRef with parsing.TokenTests { case '<' => return "< not allowed in attribute value"; case '&' => - val n = getName(value, i+1); + val n = getName(value, i+1) if (n eq null) return "malformed entity reference in attribute value ["+value+"]"; i = i + n.length() + 1 diff --git a/src/manual/scala/tools/docutil/EmitHtml.scala b/src/manual/scala/tools/docutil/EmitHtml.scala index 8f352b3d6f..700f8bf981 100644 --- a/src/manual/scala/tools/docutil/EmitHtml.scala +++ b/src/manual/scala/tools/docutil/EmitHtml.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Stephane Micheloud * Adapted from Lex Spoon's sbaz manual */ @@ -19,8 +19,8 @@ object EmitHtml { .replaceAll(">", ">") /* */ - def emitSection(section: Section, depth: int): Unit = { - def emitPara(text: AbstractText): Unit = { + def emitSection(section: Section, depth: int) { + def emitPara(text: AbstractText) { out.println("

") emitText(text) out.println("\n
") @@ -72,7 +72,7 @@ object EmitHtml { case DefinitionList(definitions @ _*) => out.println("
") - for (val d <- definitions) { + for (d <- definitions) { out.println("
") emitText(d.term) out.println("\n
") @@ -110,7 +110,7 @@ object EmitHtml { case lst:BulletList => out.println("
    ") - for (val item <- lst.items) { + for (item <- lst.items) { out.print("
  • ") emitText(item) out.println("
  • ") @@ -119,7 +119,7 @@ object EmitHtml { case lst:NumberedList => out.println("
      ") - for(val item <- lst.items) { + for (item <- lst.items) { out.print("
    1. ") emitText(item) } @@ -204,7 +204,7 @@ object EmitHtml { /* private def group(ns: Iterable[NodeSeq]): NodeSeq = { val zs = new NodeBuffer - for (val z <- ns) { zs &+ z } + for (z <- ns) { zs &+ z } zs } @@ -337,7 +337,7 @@ object EmitHtml { */ } */ - def main(args: Array[String]) = { + def main(args: Array[String]) { if (args.length < 1) { System.err.println("usage: EmitHtml ") exit(1) diff --git a/src/manual/scala/tools/docutil/EmitManPage.scala b/src/manual/scala/tools/docutil/EmitManPage.scala index 7be8229ce9..26efe4ee67 100644 --- a/src/manual/scala/tools/docutil/EmitManPage.scala +++ b/src/manual/scala/tools/docutil/EmitManPage.scala @@ -19,8 +19,8 @@ object EmitManPage { def escape(text: String) = text.replaceAll("-", "\\-") - def emitSection(section: Section, depth: int): Unit = { - def emitPara(text: AbstractText): Unit = { + def emitSection(section: Section, depth: int) { + def emitPara(text: AbstractText) { emitText(text) out.println("\n.IP") } @@ -68,12 +68,12 @@ object EmitManPage { case DefinitionList(definitions @ _*) => var n = definitions.length - for (val d <- definitions) { + for (d <- definitions) { out.println(".TP") emitText(d.term) out.println emitText(d.description) - if (n > 1) { out.println; n = n - 1 } + if (n > 1) { out.println; n -= 1 } } case Link(label, url) => @@ -101,7 +101,7 @@ object EmitManPage { out.println("\n.fi") case lst:BulletList => - for(val item <- lst.items) { + for(item <- lst.items) { out.println(".IP") emitText(item) out.println @@ -109,7 +109,7 @@ object EmitManPage { case lst:NumberedList => for { - val idx <- List.range(0, lst.items.length) + idx <- List.range(0, lst.items.length) val item = lst.items(idx) } { out.println(".IP \" " + (idx+1) + ".\"") @@ -143,7 +143,7 @@ object EmitManPage { section.paragraphs.foreach(emitParagraph) } - def emitDocument(doc: Document) = { + def emitDocument(doc: Document) { out.println(".\\\" ##########################################################################") out.println(".\\\" # __ #") out.println(".\\\" # ________ ___ / / ___ Scala 2 On-line Manual Pages #") -- cgit v1.2.3