blob: 38ac2984c1086b34ffa437f850e486cbc56d62e7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()
}
}
|