Scala: programmatically program a breakpoint to be recognized by IntelliJ

In Visual Studio / C #, I can set a software breakpoint easily. Is there a similar feature for IntelliJ / Scala -Plugin and Scala language?

To clarify: In C #, you can call an API function

System.Diagnostics.Debugger.Break();

      

and then the debugger in VS stops, as with any breakpoint set in the IDE.

+3


source to share


1 answer


I don't know of such a possibility, but in any programming environment you can get rid of the adhoc solution: just define a method debugBreak

, add a breakpoint to it, and then use that. Example:

def debugBreak() {
  println("Breakpoint hit!") // Manually set a breakpoint here
}

//.... then somwhere in your code base
if (<<some condition>>) {
  debugBreak
}

      

What is it. Every time the condition is met, the debugger stops and you just need to go up the stack one frame.



As an aside, in most cases, a simpler and simpler solution is to simply set a conditional breakpoint in IntelliJ (essentially by inserting a condition expression in the condition field). See https://www.jetbrains.com/idea/help/configuring-breakpoints.html .

However, sometimes IntelliJ cannot evaluate your expression, so in those cases the adhoc solution described above is a useful replacement.

+2


source







All Articles