diff options
author | Miles Sabin <miles@milessabin.com> | 2009-06-29 12:20:33 +0000 |
---|---|---|
committer | Miles Sabin <miles@milessabin.com> | 2009-06-29 12:20:33 +0000 |
commit | f5c93803e45f78c316e239f36e038e725d526a28 (patch) | |
tree | 3a3c000e5f419b12d73098b4ea6c47bb52b70cca | |
parent | 73a4bffc830d2ba3041dce199ea900f6b4ebd52a (diff) | |
download | scala-f5c93803e45f78c316e239f36e038e725d526a28.tar.gz scala-f5c93803e45f78c316e239f36e038e725d526a28.tar.bz2 scala-f5c93803e45f78c316e239f36e038e725d526a28.zip |
Added default implementation for debug hover in...
Added default implementation for debug hover info; export FJBG for use
in the IDE.
-rw-r--r-- | .classpath | 2 | ||||
-rw-r--r-- | META-INF/MANIFEST.MF | 3 | ||||
-rwxr-xr-x | src/compiler/scala/tools/nsc/interactive/Global.scala | 28 |
3 files changed, 30 insertions, 3 deletions
diff --git a/.classpath b/.classpath index bb255263fc..1e83ae27e7 100644 --- a/.classpath +++ b/.classpath @@ -5,6 +5,6 @@ <classpathentry kind="lib" path="lib/msil.jar"/> <classpathentry kind="lib" path="lib/jline.jar"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="lib" path="lib/fjbg.jar"/> + <classpathentry exported="true" kind="lib" path="lib/fjbg.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 7442856cd6..8300fde1bf 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -23,7 +23,8 @@ Export-Package: scala.tools.nsc.symtab, scala.tools.nsc.symtab.classfile, scala.tools.nsc.typechecker, - scala.tools.nsc.util + scala.tools.nsc.util, + ch.epfl.lamp.fjbg Require-Bundle: org.apache.ant, scala.library diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 029a98cb10..e6993f5000 100755 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -1,6 +1,9 @@ package scala.tools.nsc.interactive +import java.io.{ PrintWriter, StringWriter } + import scala.collection.mutable.{LinkedHashMap, SynchronizedMap} +import scala.concurrent.SyncVar import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.util.{SourceFile, Position, RangePosition, OffsetPosition, NoPosition, WorkScheduler} import scala.tools.nsc.reporters._ @@ -125,7 +128,30 @@ self => } } - def hoverInfo(): String = "" + def debugInfo(source : SourceFile, start : Int, length : Int): String = { + val end = start+length + val pos = rangePos(source, start, start, end) + + val tree = locateTree(pos) + val sw = new StringWriter + val pw = new PrintWriter(sw) + treePrinters.create(pw).print(tree) + pw.flush + + val typed = new SyncVar[Either[Tree, Throwable]] + askTypeAt(pos, typed) + val typ = typed.get.left.toOption match { + case Some(tree) => + val sw = new StringWriter + val pw = new PrintWriter(sw) + treePrinters.create(pw).print(tree) + pw.flush + sw.toString + case None => "<None>" + } + + source.content.view.drop(start).take(length).mkString+" : "+source.path+" ("+start+", "+end+")\n\nlocateTree:\n"+sw.toString+"\n\naskTypeAt:\n"+typ + } // ----------------- The Background Runner Thread ----------------------- |