Tips & Tricks

Debugger: working with sub-ranges for arrays and lists

During debugging IntelliJ IDEA shows only the first 100 elements of arrays and collections. It’s enough in most cases. However, it’s sometimes convenient to use a custom range. Exactly for this the ‘Adjust Range’ action has been available for arrays for quite a long time. But recently we’ve made a couple of improvements to it. Namely:

  • ‘Adjust Range’ works with lists now
  • adjusted range is preserved for local variables delivered to another stack frame

Quick demonstration example:

  1. Start debugger and wait until target break point is hit;
  2. Right click on target array/list and select the ‘Adjust Range…’ action:
  3. Define a range:
  4. Check the result:
Comments below can no longer be edited.

12 Responses to Debugger: working with sub-ranges for arrays and lists

  1. Avatar

    Evgeny Gerashchenko says:

    September 30, 2011

    Cool! I have waited for this feature for a long time!

  2. Avatar

    Igor Kolomiets says:

    September 30, 2011

    Denis, if I were your manager I would punish you for brown color scheme πŸ™‚

  3. Avatar

    Denis.Zhdanov says:

    September 30, 2011

    Fyi, that’s a standard gnome theme

  4. Avatar

    Igor Kolomiets says:

    September 30, 2011

    I know. Unfortunately many Linux products harmed by untasteful aesthetics. IDEA is not that kind of product though πŸ™‚

  5. Avatar

    Alex says:

    October 1, 2011

    That’s nice. But is It possible to add some navigation buttons (like scroll down) instead of “…” signs?

  6. Avatar

    Denis.Zhdanov says:

    October 3, 2011

    Please submit corresponding feature request to the tracker.

  7. Avatar

    Aardwolf says:

    October 4, 2011

    I’d actually like to have, instead, a menu option there which does not make you type numbers to adjust a range or so, but instead opens a dialog with a scrollbar with the whole array in it (if needed capped at 10000 or so values with a “more” button at the bottom). I think it’s much easier to debug your problem if you can have a nice visual representation of the whole thing in one self contained dialog, than if you need to twiddle with numbers in popup menu options and collapsible tree controls!

    But it sure is a step forward!

  8. Avatar

    Denis.Zhdanov says:

    October 4, 2011

    @Aardwolf: I’d say that it’s a slightly different use-case because the blogged facility allows not only show values beyond the default limits but hide non-interesting values as well.

    However, I agree that ‘more’ control would be handy during debugging. Can I ask you to create corresponding ticket request?

  9. Avatar

    Geoffrey De Smet says:

    October 10, 2011

    Nice, this paper cut has bothered me a lot in the past. Ironically, I always needed to see the 101th element it seems…

  10. Avatar

    ammar bozorgvar says:

    September 30, 2014

    thank you

  11. Avatar

    Lenny Miller says:

    April 19, 2016

    This is helpful – thx! However, the vertical list of values leaves most of the Variables debug window with white-space. Being able to view more data on a single (and scroll-able) screen would be helpful when scanning large arrays for a pattern. Is there a way to change the layout (of the “adjusted” variable values) to a multi-row (array) format (like the Unix od command)? I’d be happy to create a ticket if it’s not available, and you think it makes sense. Thx.

  12. Avatar

    MilanG says:

    February 25, 2018

    Would be useful to watch array of arrays as table.

Discover more