Skip to content

Instantly share code, notes, and snippets.

Created November 28, 2013 15:39
Show Gist options
  • Save anonymous/7693857 to your computer and use it in GitHub Desktop.
Save anonymous/7693857 to your computer and use it in GitHub Desktop.
inspired by Pythons: >> import pdb;pdb.set_trace() I hacked something similar to have breakpoints in Scala 2.9 && 2.10 by typing: import break._;break[someClass]("MainObject" -> MainObject)
import scala.tools.nsc.interpreter._
import scala.tools.nsc.Settings
//USAGE EXAMPLE: import break._;break[someClass]("MainObject" -> MainObject)
object break{
def echo(x: Any) = Console.println(x)
def break[T: Manifest](args: NamedParam*) = {
val repl = new ILoop
repl.settings = new Settings(echo)
repl.settings.embeddedDefaults[T]
repl.createInterpreter()
repl.in = SimpleReader()
// repl.bind("p", "Array[page]", MainObject.pages)
val params = args.toList
println(args)
params foreach (p => repl.bind(p.name, p.tpe, p.value))
var k = ""
while( k !="q"){
k = Console.readLine()
repl.interpret(k)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment