diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/Global.scala | 10 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala | 35 |
2 files changed, 18 insertions, 27 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index a2426d2212..ddc870a045 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -24,7 +24,7 @@ import scala.reflect.generic.Flags.{ACCESSOR, PARAMACCESSOR} /** The main class of the presentation compiler in an interactive environment such as an IDE */ -class Global(settings: Settings, reporter: Reporter) +class Global(settings: Settings, reporter: Reporter, projectName: String = "") extends scala.tools.nsc.Global(settings, reporter) with CompilerControl with RangePositions @@ -61,11 +61,11 @@ class Global(settings: Settings, reporter: Reporter) /** Print msg only when debugIDE is true. */ @inline final def debugLog(msg: => String) = - if (debugIDE) println(msg) + if (debugIDE) println("[%s] %s".format(projectName, msg)) /** Inform with msg only when verboseIDE is true. */ @inline final def informIDE(msg: => String) = - if (verboseIDE) println("["+msg+"]") + if (verboseIDE) println("[%s][%s]".format(projectName, msg)) override def forInteractive = true @@ -390,9 +390,9 @@ class Global(settings: Settings, reporter: Reporter) /** Create a new presentation compiler runner. */ - private[interactive] def newRunnerThread(): Thread = { + private def newRunnerThread(): Thread = { threadId += 1 - compileRunner = new PresentationCompilerThread(this, threadId) + compileRunner = new PresentationCompilerThread(this, projectName) compileRunner.start() compileRunner } diff --git a/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala b/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala index b61d7f6638..951cba286f 100644 --- a/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala +++ b/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala @@ -8,30 +8,25 @@ package scala.tools.nsc.interactive /** A presentation compiler thread. This is a lightweight class, delegating most * of its functionality to the compiler instance. * - * @note This thread class may not be GCd, so it's important not to keep around - * large objects. For instance, the JDT weaving framework keeps threads around - * in a map, preventing them from being GCd. This prompted the separation between - * interactive.Global and this class. */ -class PresentationCompilerThread(var compiler: Global, threadId: Int) extends Thread("Scala Presentation Compiler V"+threadId) { +final class PresentationCompilerThread(var compiler: Global, name: String = "") extends Thread("Scala Presentation Compiler V [" + name + "]") { + /** The presentation compiler loop. */ override def run() { compiler.debugLog("starting new runner thread") - try { - while (true) { - compiler.checkNoResponsesOutstanding() - compiler.log.logreplay("wait for more work", { compiler.scheduler.waitForMoreWork(); true }) - compiler.pollForWork(compiler.NoPosition) - while (compiler.isOutOfDate) { - try { - compiler.backgroundCompile() - } catch { - case FreshRunReq => - compiler.debugLog("fresh run req caught, starting new pass") - } - compiler.log.flush() + while (true) try { + compiler.checkNoResponsesOutstanding() + compiler.log.logreplay("wait for more work", { compiler.scheduler.waitForMoreWork(); true }) + compiler.pollForWork(compiler.NoPosition) + while (compiler.isOutOfDate) { + try { + compiler.backgroundCompile() + } catch { + case FreshRunReq => + compiler.debugLog("fresh run req caught, starting new pass") } + compiler.log.flush() } } catch { case ex @ ShutdownReq => @@ -42,7 +37,6 @@ class PresentationCompilerThread(var compiler: Global, threadId: Int) extends Th compiler = null case ex => compiler.log.flush() - compiler.newRunnerThread() ex match { case FreshRunReq => @@ -51,9 +45,6 @@ class PresentationCompilerThread(var compiler: Global, threadId: Int) extends Th compiler.debugLog("validate exception caught outside presentation compiler loop; ignored") case _ => ex.printStackTrace(); compiler.informIDE("Fatal Error: "+ex) } - - // make sure we don't keep around stale instances - compiler = null } } } |