summaryrefslogtreecommitdiff
path: root/test/files/presentation/find-trees/FindTrees.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/presentation/find-trees/FindTrees.scala')
-rw-r--r--test/files/presentation/find-trees/FindTrees.scala43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/files/presentation/find-trees/FindTrees.scala b/test/files/presentation/find-trees/FindTrees.scala
new file mode 100644
index 0000000000..38ac2984c1
--- /dev/null
+++ b/test/files/presentation/find-trees/FindTrees.scala
@@ -0,0 +1,43 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+import scala.tools.nsc.util.Position
+
+
+/** Example interactive test that does everything by hand. It would be much simpler
+ * to just add the markers in the test file. This test shows how to drive
+ * the presentation compiler manually.
+ */
+object Test extends InteractiveTest {
+
+ def askForPos(pos: Position) {
+ import compiler._
+ val response = new Response[Tree]
+
+ println("asking position at %d:%d".format(pos.line, pos.column))
+ compiler.askTypeAt(pos, response)
+ response.get match {
+ case Left(EmptyTree) =>
+ println("error retrieving tree at %d:%d".format(pos.line, pos.column))
+ case Left(t) =>
+ println("retrieved tree: " + t)
+ }
+ println(this.reporter.infos.mkString("\n"))
+ }
+
+ override def runTest {
+ import compiler._
+ val src = sourceFiles(0) // only one under src/
+ val pos = rangePos(src, 426, 426, 433)
+ val pos1 = src.position(19, 15)
+
+ // reload is issued already by the framework, but we can redo it here as an example
+ val reload = new Response[Unit]
+ compiler.askReload(List(src), reload)
+ reload.get // it's important to let reload finish before asking other things.
+
+ askForPos(pos)
+ println("=" * 20)
+ askForPos(pos1)
+
+ compiler.askShutdown()
+ }
+}