summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-02-07 11:41:22 +0000
committerMartin Odersky <odersky@gmail.com>2011-02-07 11:41:22 +0000
commitcd579b986641ed15687dfb5d665f2e67f656f7af (patch)
tree7cd1f6489db6ade08235afe1bafbc894c8f72b30 /src/compiler/scala/tools
parenta589cb084bf93facd9a6bd69a2b57de87d0d9134 (diff)
downloadscala-cd579b986641ed15687dfb5d665f2e67f656f7af.tar.gz
scala-cd579b986641ed15687dfb5d665f2e67f656f7af.tar.bz2
scala-cd579b986641ed15687dfb5d665f2e67f656f7af.zip
Towards better error handling in the IDE.
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Main.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/IMain.scala8
6 files changed, 14 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 56426cfcfd..b1490e411a 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -878,7 +878,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
return
val startTime = currentTime
- reporter.reset
+ reporter.reset()
for (source <- sources) addUnit(new CompilationUnit(source))
globalPhase = firstPhase
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala
index eee5807df1..ff197a125c 100644
--- a/src/compiler/scala/tools/nsc/Main.scala
+++ b/src/compiler/scala/tools/nsc/Main.scala
@@ -34,7 +34,7 @@ object Main extends AnyRef with EvalLoop {
loop { line =>
val args = line.split(' ').toList
val command = new CompilerCommand(args, new Settings(scalacError))
- compiler.reporter.reset
+ compiler.reporter.reset()
new compiler.Run() compile command.files
}
}
@@ -59,7 +59,7 @@ object Main extends AnyRef with EvalLoop {
reloaded.get.right.toOption match {
case Some(ex) => reporter.cancelled = true // Causes exit code to be non-0
- case None => reporter.reset // Causes other compiler errors to be ignored
+ case None => reporter.reset() // Causes other compiler errors to be ignored
}
askShutdown
}
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index 033776e7eb..a64b4c1826 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -26,6 +26,7 @@ class Global(settings: Settings, reporter: Reporter)
with RangePositions
with ContextTrees
with RichCompilationUnits
+ with Reporters
with Picklers {
self =>
@@ -373,6 +374,7 @@ self =>
unit.toCheck.clear()
unit.targetPos = NoPosition
unit.contexts.clear()
+ unit.problems.clear()
unit.body = EmptyTree
unit.status = NotLoaded
}
diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala
index 5e20656c94..8ef7310378 100644
--- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala
@@ -101,7 +101,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana
private def update(files: Set[AbstractFile]) = {
val coll: mutable.Map[AbstractFile, immutable.Set[AbstractFile]] =
mutable.HashMap[AbstractFile, immutable.Set[AbstractFile]]()
- compiler.reporter.reset
+ compiler.reporter.reset()
// See if we really have corresponding symbols, not just those
// which share the name
diff --git a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
index 7e8809c8cd..993277cad1 100644
--- a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
@@ -2,6 +2,7 @@ package scala.tools.nsc
package interactive
import scala.tools.nsc.util.{SourceFile, Position, NoPosition}
+import collection.mutable.ArrayBuffer
trait RichCompilationUnits { self: Global =>
@@ -33,6 +34,9 @@ trait RichCompilationUnits { self: Global =>
/** the current edit point offset */
var editPoint: Int = -1
+ /** The problems reported for this unit */
+ val problems = new ArrayBuffer[Problem]
+
/** The position of a targeted type check
* If this is different from NoPosition, the type checking
* will stop once a tree that contains this position range
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
index 8c02296904..02016d746b 100644
--- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
@@ -448,7 +448,7 @@ class IMain(val settings: Settings, protected val out: PrintWriter) {
reporter.withIncompleteHandler((pos,msg) => {justNeedsMore = true}) {
// simple parse: just parse it, nothing else
def simpleParse(code: String): List[Tree] = {
- reporter.reset
+ reporter.reset()
val unit = new CompilationUnit(new BatchSourceFile("<console>", code))
val scanner = new syntaxAnalyzer.UnitParser(unit)
@@ -475,7 +475,7 @@ class IMain(val settings: Settings, protected val out: PrintWriter) {
* no compilation errors, or false otherwise.
*/
def compileSources(sources: SourceFile*): Boolean = {
- reporter.reset
+ reporter.reset()
new Run() compileSources sources.toList
!reporter.hasErrors
}
@@ -693,7 +693,7 @@ class IMain(val settings: Settings, protected val out: PrintWriter) {
}
private def compileAndSaveRun(label: String, code: String) = {
showCodeIfDebugging(code)
- reporter.reset
+ reporter.reset()
lastRun = new Run()
lastRun.compileSources(List(new BatchSourceFile(label, packaged(code))))
!reporter.hasErrors
@@ -804,7 +804,7 @@ class IMain(val settings: Settings, protected val out: PrintWriter) {
* If all goes well, the "types" map is computed. */
lazy val compile: Boolean = {
// error counting is wrong, hence interpreter may overlook failure - so we reset
- reporter.reset
+ reporter.reset()
// compile the object containing the user's code
lineRep.compile(ObjectSourceCode(handlers)) && {