Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse debugging HashMap: Logical Structure using Key and Value's toString() method

Tags:

I have recently started to use Eclipse after using IntelliJ for a few years. When debugging Map using IntelliJ, if the key or object implements toString(), a nice list of string representation of key-value is displayed.

In Eclipse, when I select Show Logical Structure, I see something like the following:

enter image description here

The problem with this view is that you will need to expand each entry to see the actual key and value. If you need to find something in a map of more than 10 elements, it becomes very tedious.

I understand that you can make custom Logical Structure and the default for Map look the this:

return entrySet().toArray();

Is there any way, either through custom Logical Structure or plugin to view Map Entries more useful than

ConcurrentHashMap$WriteThroughEntry (id=193)
like image 587
ltfishie Avatar asked Sep 01 '11 19:09

ltfishie


1 Answers

You need to create a detail formatter on top of the logical structure. In the example screenshot you provided, your logical structure is ConcurrentHashMap$WriteThroughEntry. You can add the detail formatter by right clicking on a row containing a ConcurrentHashMap$WriteThroughEntry and selecting 'add detail formatter'.

I just knocked up this example using HashMap.

enter image description here

java.util.HashMap$Entry //  key + " - " + value

For a

HashMap<Integer,String> map;

.. I quickly populated with rubbish, I now see:

enter image description here

like image 54
horbags Avatar answered Sep 21 '22 10:09

horbags