summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-02-07 17:31:53 +0000
committerMartin Odersky <odersky@gmail.com>2011-02-07 17:31:53 +0000
commitc89ea6e3ae82d9b6bacda25dceb74a958d2fa4f6 (patch)
tree255e58fbe69b33c7436f63efb46bfde6565f3670
parent23aee8758aa9d1db56b815c4e9132640d078c409 (diff)
downloadscala-c89ea6e3ae82d9b6bacda25dceb74a958d2fa4f6.tar.gz
scala-c89ea6e3ae82d9b6bacda25dceb74a958d2fa4f6.tar.bz2
scala-c89ea6e3ae82d9b6bacda25dceb74a958d2fa4f6.zip
redesigned error message handling for presentat...
redesigned error message handling for presentation compiler.
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala1
-rw-r--r--src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala43
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Reporters.scala39
3 files changed, 43 insertions, 40 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index a64b4c1826..f369190016 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -26,7 +26,6 @@ class Global(settings: Settings, reporter: Reporter)
with RangePositions
with ContextTrees
with RichCompilationUnits
- with Reporters
with Picklers {
self =>
diff --git a/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala
new file mode 100644
index 0000000000..3c3d986f81
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala
@@ -0,0 +1,43 @@
+package scala.tools.nsc
+package interactive
+
+import collection.mutable.ArrayBuffer
+import util.Position
+import reporters.Reporter
+
+case class Problem(pos: Position, msg: String, severityLevel: Int)
+
+abstract class InteractiveReporter extends Reporter {
+
+ def compiler: Global
+
+ val otherProblems = new ArrayBuffer[Problem]
+
+ override def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit = try {
+ severity.count += 1
+ val problems =
+ if (compiler eq null) {
+ otherProblems
+ } else if (pos.isDefined) {
+ compiler.getUnit(pos.source) match {
+ case Some(unit) =>
+ compiler.debugLog(pos.source.file.name + ":" + pos.line + ": " + msg)
+ unit.problems
+ case None =>
+ compiler.debugLog(pos.source.file.name + "[not loaded] :" + pos.line + ": " + msg)
+ otherProblems
+ }
+ } else {
+ compiler.debugLog("[no position] :" + msg)
+ otherProblems
+ }
+ problems += Problem(pos, msg, severity.id)
+ } catch {
+ case ex: UnsupportedOperationException =>
+ }
+
+ override def reset() {
+ super.reset()
+ otherProblems.clear()
+ }
+}
diff --git a/src/compiler/scala/tools/nsc/interactive/Reporters.scala b/src/compiler/scala/tools/nsc/interactive/Reporters.scala
deleted file mode 100644
index 7538801b00..0000000000
--- a/src/compiler/scala/tools/nsc/interactive/Reporters.scala
+++ /dev/null
@@ -1,39 +0,0 @@
-package scala.tools.nsc
-package interactive
-
-import collection.mutable.ArrayBuffer
-import util.Position
-import reporters.Reporter
-
-trait Reporters { self: Global =>
-
- case class Problem(pos: Position, msg: String, severity: Int)
-
- val otherProblems = new ArrayBuffer[Problem]
-
- class InteractiveReporter extends Reporter {
- override def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit = {
- severity.count += 1
- val problems =
- if (pos.isDefined) {
- getUnit(pos.source) match {
- case Some(unit) =>
- debugLog(pos.source.file.name + ":" + pos.line + ": " + msg)
- unit.problems
- case None =>
- debugLog(pos.source.file.name + "[not loaded] :" + pos.line + ": " + msg)
- otherProblems
- }
- } else {
- debugLog("[no position] :" + msg)
- otherProblems
- }
- problems += Problem(pos, msg, severity.id)
- }
-
- override def reset() {
- super.reset()
- otherProblems.clear()
- }
- }
-} \ No newline at end of file