From 4850e825a752e8f88223bebe0a5b998f9e22eb3b Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Thu, 16 Dec 2010 15:24:41 +0000 Subject: Added more logging to the presentation compiler. --- src/compiler/scala/tools/nsc/interactive/Global.scala | 10 +++++++++- src/compiler/scala/tools/nsc/interactive/REPL.scala | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index f44093dc5e..5936cbdc5d 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -367,6 +367,7 @@ self => /** Make sure a set of compilation units is loaded and parsed */ def reloadSources(sources: List[SourceFile]) { + if (debugIDE) inform("reloadSources " + sources) currentTyperRun = newTyperRun for (source <- sources) { val unit = new RichCompilationUnit(source) @@ -378,6 +379,7 @@ self => /** Make sure a set of compilation units is loaded and parsed */ def reload(sources: List[SourceFile], response: Response[Unit]) { + if (debugIDE) inform("reload" + sources) respond(response)(reloadSources(sources)) if (outOfDate) throw FreshRunReq // cancel background compile else outOfDate = true // proceed normally and enable new background compile @@ -385,6 +387,7 @@ self => /** A fully attributed tree located at position `pos` */ def typedTreeAt(pos: Position): Tree = { + if (debugIDE) inform("typedTreeAt " + pos) val unit = unitOf(pos) val sources = List(unit.source) if (unit.status == NotLoaded) reloadSources(sources) @@ -395,6 +398,7 @@ self => /** A fully attributed tree corresponding to the entire compilation unit */ def typedTree(source: SourceFile, forceReload: Boolean): Tree = { + if (debugIDE) inform("typedTree" + source + " forceReload: " + forceReload) val unit = unitOf(source) val sources = List(source) if (unit.status == NotLoaded || forceReload) reloadSources(sources) @@ -404,6 +408,7 @@ self => /** Set sync var `response` to a fully attributed tree located at position `pos` */ def getTypedTreeAt(pos: Position, response: Response[Tree]) { + if (debugIDE) inform("getTypedTreeAt" + pos) respond(response)(typedTreeAt(pos)) } @@ -414,6 +419,7 @@ self => /** Set sync var `result` to the last fully attributed tree produced from the entire compilation unit */ def getLastTypedTree(source : SourceFile, result: Response[Tree]) { + if (debugIDE) inform("getLastTyped" + source) respond(result) { val unit = unitOf(source) if (unit.status > JustParsed) unit.body @@ -441,6 +447,7 @@ self => import analyzer.{SearchResult, ImplicitSearch} def getScopeCompletion(pos: Position, response: Response[List[Member]]) { + if (debugIDE) inform("getScopeCompletion" + pos) respond(response) { scopeMembers(pos) } } @@ -485,6 +492,7 @@ self => } def getTypeCompletion(pos: Position, response: Response[List[Member]]) { + if (debugIDE) inform("getTypeCompletion " + pos) respondGradually(response) { typeMembers(pos) } if (debugIDE) typeMembers(pos) } @@ -622,7 +630,7 @@ self => val lastPrintTypings = printTypings try { println("starting targeted type check") - if (debugIDE) printTypings = true + //if (debugIDE) printTypings = true typeCheck(unit) throw new FatalError("tree not found") } catch { diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala index 4225460d1c..9572f25a69 100644 --- a/src/compiler/scala/tools/nsc/interactive/REPL.scala +++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala @@ -83,6 +83,8 @@ object REPL { val reloadResult = new Response[Unit] val typeatResult = new Response[comp.Tree] val completeResult = new Response[List[comp.Member]] + val typedResult = new Response[comp.Tree] + def makePos(file: String, off1: String, off2: String) = { val source = toSourceFile(file) comp.rangePos(source, off1.toInt, off1.toInt, off2.toInt) @@ -95,11 +97,23 @@ object REPL { comp.askTypeCompletion(pos, completeResult) show(completeResult) } + def doTypedTree(file: String) { + comp.askType(toSourceFile(file), true, typedResult) + show(typedResult) + } + loop { line => (line split " ").toList match { case "reload" :: args => comp.askReload(args map toSourceFile, reloadResult) show(reloadResult) + case "reloadAndAskType" :: file :: millis :: Nil => + comp.askReload(List(toSourceFile(file)), reloadResult) + Thread.sleep(millis.toInt) + comp.askType(toSourceFile(file), false, typedResult) + show(typedResult) + case List("typed", file) => + doTypedTree(file) case List("typeat", file, off1, off2) => doTypeAt(makePos(file, off1, off2)) case List("typeat", file, off1) => -- cgit v1.2.3