Can I step over a whole loop in IntelliJ?

user1779715 :

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?

user1779715 :

I found a workaround:

  1. While paused on the doSomething(obj1); line, I right-clicked the obj1 variable in the "Variables" pane and chose "Mark Object", naming it "obj1Instance"
  2. 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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=467949&siteId=1