Hints on how to get Intellij Scala Plugin to stop at breakpoints

The screenshot of the following tiny scala script shows four breakpoints set.

object WC {

  val code = """import org.apache.hadoop.conf.Configuration

// This class performs the map operation, translating raw input into the key-value

class TokenizerMapper extends Mapper[Object,Text,Text,IntWritable] {

"""

  def sloc(str: String): Int = {

    val x: List[String] = str.split("\\n").map(_.trim).toList.filter { line =>

      line.length!=0 && !line.startsWith("import ") && !line.startsWith("/*")  && !line.startsWith("//") && !line.equals("{") && !line.equals("}") }

    println(x.mkString("\n"))

    x.size

  }

}

println (WC.sloc(WC.code))

Screen Shot 2013-11-20 at 10.32.49 AM.png
only the very last breakpoint - on the "println (WC.sloc(WC.code))" - is actually respected. The others are ignored
However, I can step through the other three lines in the debugger
I am wondering if others have discovered any "pattern" to how to get the scala debugger to respect the breakpoints. OK we know that the scala plugin is buggy - it is here a matter of trying to get the "most" out of what we have.

BTW I am using the latest IJ ULtimate 12.1.6.  (Note: this has also been posted to StackOverflow)..


6 comments

the best solution is to write code in a style that is debuggable, meaning mostly one statement per line, just like in java :|
scala is very hard to debug, because you can basically have 5 expressions and 3 classes in a single line, if you want to

i rely on the repl & tests rather than debugging. on the long run, it's better anyway

0

Hi HOD,   thx for responding.   The interesting thing here is that it DOES step through each line with the debugger.  It just does not stop at those lines when configured as  breakpoints.  I wonder why that would be..   I would not be much in favor of "writing scala like java" approach - given the better tooling then I'd in that case just write java.

0

Breakpoints in your example works for regular Scala run, but not for Scala script. We will create a ticket for this problem.
For scripts it seem we don't have mapping mechanism to generated classes. It's a bug, but you still can wrap into object, which extends App and run.

Best regards,
Alexander Podkhalyuzin.

0

Thx Alexander.  Yes I have stopped writing scala "scripts" due to several issues in IJ with them (not just this one).  IJ -even with its various bugs wrt to scala - is still better than eclipse-based Scala IDE so I adjust my development style to work around its shortcomings.

0

Thanks for creating the ticket. I am going to upvote.

0

Please sign in to leave a comment.