I have a code base with mixed Java and Groovy code. For iteration in the Groovy code, we tend to use closures:
String[] strings = ["First", "Second", "Third"]
strings.each { string ->
println string
}
When I debug this in IntelliJ IDEA (v. 11) by stepping one row at a time, the code executing in strings.each()
(that is println string
) is stepped over. I can put a breakpoint at the println
row, and I will be able to debug it, but it is a little workaround that would be nice to avoid.
Is there a way to configure intelliJ to not step over Groovy closures? There are no applicable options in File->Settings->Debugger->Groovy.
Edit:
To clarify what I expect intelliJ to do:
Say I have a Java style iteration like this:
for (String string : strings) {
println string
}
If I use "Step over", the debugger steps into the iteration with no problems. I can the continue "stepping over" and still be in the loop until there are no more objects to iterate over. This is what I would expect for closures like above to.
It might not be a problem in a case with one or two closures where you manually have to set breakpoints. But if there are many, it would be really neat to "automatically" step into them.
each
is a closure, so if you step over it will skip the whole function, and if you step in you will have to deal with lots of 'noise', like in Java when you want to step into a Spring bean method call and end up in Proxies... Setting a breakpoint on the first line in your closure is the only solution I'm aware of. EDIT: I just found out IntelliJ'sDebugger > Stepping
options, which could prevent you from struggling with groovy's internals... It's worth giving it a try :) – Lian