Suppose I'm debugging the following code in IntelliJ:
for (SomeObject obj1 : iterable1) {
doSomething(obj1); // <--- I am currently paused on this line
for (SomeObject obj2 : iterable2) {
doSomething(obj1, obj2);
}
}
I would like to step over the whole inner loop to see how the inner loop affected obj1
's fields, but "run to cursor" to the first closing brace runs only the first iteration of the inner loop, while "run to cursor" on the second closing brace ends the iteration of the outer loop, and I no longer have access to obj1
.
Manually stepping through each of the iterations isn't an option since there may be thousands of items, and neither is adding a line between the braces since this is part of a library.
Is there any way I can simply step over a loop at the end of a block without exiting the containing block?
I found a workaround:
- While paused on the
doSomething(obj1);
line, I right-clicked theobj1
variable in the "Variables" pane and chose "Mark Object", naming it "obj1Instance" - I let the loop run one iteration and ran
obj1Instance_DebugLabel
in the "Evaluate Expression" window, which showed me all of its fields
I also submitted an IntelliJ issue here: https://youtrack.jetbrains.com/issue/IDEA-194103