summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interactive
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-04 05:22:57 +0000
committerPaul Phillips <paulp@improving.org>2010-03-04 05:22:57 +0000
commit34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec (patch)
treeb2ae69f2731acde0ec4b921cf2e1a73295ea3250 /src/compiler/scala/tools/nsc/interactive
parent65520ac86f5362bfa438c0b9e1a84f1f558e2618 (diff)
downloadscala-34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec.tar.gz
scala-34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec.tar.bz2
scala-34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec.zip
A few yards short of the goal posts attempt at ...
A few yards short of the goal posts attempt at making our usage of Throwable subclasses more consistent. This patch eliminates a lot of ad hoc Exception/Error/etc. creation and various arbitrary choices are rendered slightly less arbitrary. From now on let's try not to use the word "Exception" or "Error" in the names of Throwable subclasses unless they actually derive (and make sense to derive) from Exception or Error. Review by community.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interactive')
-rw-r--r--src/compiler/scala/tools/nsc/interactive/CompilerControl.scala18
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala32
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RangePositions.scala4
3 files changed, 25 insertions, 29 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
index ab02ae7460..5c16bb4465 100644
--- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -2,7 +2,7 @@ package scala.tools.nsc
package interactive
import scala.concurrent.SyncVar
-import scala.util.control.ControlException
+import scala.util.control.ControlThrowable
import scala.tools.nsc.io.AbstractFile
import scala.tools.nsc.util.{SourceFile, Position, WorkScheduler}
import scala.tools.nsc.symtab._
@@ -124,23 +124,19 @@ trait CompilerControl { self: Global =>
}
/** Cancel currently pending high-priority jobs */
- def askCancel() =
- scheduler.raise(new CancelActionReq)
+ def askCancel() = scheduler raise CancelActionReq
/** Cancel current compiler run and start a fresh one where everything will be re-typechecked
* (but not re-loaded).
*/
- def askReset() =
- scheduler.raise(new FreshRunReq)
+ def askReset() = scheduler raise FreshRunReq
/** Tell the compile server to shutdown, and do not restart again */
- def askShutdown() =
- scheduler.raise(new ShutdownReq)
+ def askShutdown() = scheduler raise ShutdownReq
// ---------------- Interpreted exeptions -------------------
- class CancelActionReq extends Exception with ControlException
- class FreshRunReq extends Exception with ControlException
- class ShutdownReq extends Exception with ControlException
-
+ object CancelActionReq extends ControlThrowable
+ object FreshRunReq extends ControlThrowable
+ object ShutdownReq extends ControlThrowable
}
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index 1f2a606e6b..c4fec12667 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -5,7 +5,7 @@ import java.io.{ PrintWriter, StringWriter }
import scala.collection.mutable.{LinkedHashMap, SynchronizedMap}
import scala.concurrent.SyncVar
-import scala.util.control.ControlException
+import scala.util.control.ControlThrowable
import scala.tools.nsc.io.AbstractFile
import scala.tools.nsc.util.{SourceFile, Position, RangePosition, OffsetPosition, NoPosition, WorkScheduler}
import scala.tools.nsc.reporters._
@@ -91,10 +91,10 @@ self =>
// it will still be null now?
if (context.unit != null)
integrateNew()
- throw new FreshRunReq
- } catch {
- case ex : ValidateError => // Ignore, this will have been reported elsewhere
- case t : Throwable => throw t
+ throw FreshRunReq
+ }
+ catch {
+ case ex : ValidateException => // Ignore, this will have been reported elsewhere
}
}
}
@@ -114,9 +114,9 @@ self =>
* Poll for work reload/typedTreeAt/doFirst commands during background checking.
*/
def pollForWork() {
- scheduler.pollException() match {
- case Some(ex: CancelActionReq) => if (acting) throw ex
- case Some(ex: FreshRunReq) =>
+ scheduler.pollThrowable() match {
+ case Some(ex @ CancelActionReq) => if (acting) throw ex
+ case Some(ex @ FreshRunReq) =>
currentTyperRun = newTyperRun
minRunId = currentRunId
if (outOfDate) throw ex
@@ -132,7 +132,7 @@ self =>
action()
if (debugIDE) println("done with work item: "+action)
} catch {
- case ex: CancelActionReq =>
+ case CancelActionReq =>
if (debugIDE) println("cancelled work item: "+action)
} finally {
if (debugIDE) println("quitting work item: "+action)
@@ -195,19 +195,19 @@ self =>
backgroundCompile()
outOfDate = false
} catch {
- case ex: FreshRunReq =>
+ case FreshRunReq =>
}
}
}
} catch {
- case ex: ShutdownReq =>
+ case ShutdownReq =>
;
case ex =>
outOfDate = false
compileRunner = newRunnerThread
ex match {
- case _ : FreshRunReq => // This shouldn't be reported
- case _ : ValidateError => // This will have been reported elsewhere
+ case FreshRunReq => // This shouldn't be reported
+ case _ : ValidateException => // This will have been reported elsewhere
case _ => ex.printStackTrace(); inform("Fatal Error: "+ex)
}
}
@@ -276,7 +276,7 @@ self =>
result set Left(op)
return
} catch {
- case ex : FreshRunReq =>
+ case ex @ FreshRunReq =>
scheduler.postWorkItem(() => respond(result)(op))
throw ex
case ex =>
@@ -298,7 +298,7 @@ self =>
/** Make sure a set of compilation units is loaded and parsed */
def reload(sources: List[SourceFile], result: Response[Unit]) {
respond(result)(reloadSources(sources))
- if (outOfDate) throw new FreshRunReq
+ if (outOfDate) throw FreshRunReq
else outOfDate = true
}
@@ -534,7 +534,7 @@ self =>
def newTyperRun = new TyperRun
- class TyperResult(val tree: Tree) extends Exception with ControlException
+ class TyperResult(val tree: Tree) extends ControlThrowable
assert(globalPhase.id == 0)
}
diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
index 49fc8be185..0186103aa1 100644
--- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
@@ -199,7 +199,7 @@ self: scala.tools.nsc.Global =>
inform(tree.toString)
inform("")
inform("=======")
- throw new ValidateError(msg)
+ throw new ValidateException(msg)
}
def validate(tree: Tree, encltree: Tree): Unit = {
@@ -238,7 +238,7 @@ self: scala.tools.nsc.Global =>
validate(tree, tree)
}
- class ValidateError(msg : String) extends Exception(msg)
+ class ValidateException(msg : String) extends Exception(msg)
// ---------------- Locating trees ----------------------------------