Vscode-java-debug: Show toString() values in variables windows

Created on 21 Jun 2018  路  8Comments  路  Source: microsoft/vscode-java-debug

[Both in local variables and watch window, the debugger view shows the type of the complex object. It'll be really useful to show both type and toString() of the object]

Steps To Reproduce
  1. put the following code in a test class
public void testComplexTypeVariables() {
        String hello = "How are you.";
        Date now = new Date();
        assertNotEquals("not expected to be the same.", hello, now);
    }
  1. set break point on the assert line and start the debugger
  2. look at the variables window

image

Current Result

Showing Type only for complex object

Expected Result

to show both Type and toString() of the object. In the example, I expect to see ((now "2018-06-21 20:00:00.0" Date)) for the now variable.

Most helpful comment

Actually, I don't think #236 and this are duplicated. What I'm after is simply displaying whatever the toString() in the view of variables, while #236 is about user provides a custom format then showing it in the view.

All 8 comments

Dup as Issue 236 should have a user setting by enable toString display

Actually, I don't think #236 and this are duplicated. What I'm after is simply displaying whatever the toString() in the view of variables, while #236 is about user provides a custom format then showing it in the view.

+1

Add a user setting java.debug.settings.showToString to control whether to show toString value, default to true.

Below is the scenario to show additional detail string:

  • For the classes that override 'toString' method, show toString() details.
  • For Collection and Map classes, show an additional size=x details.
  • For Entry, show key:value details.

image

0.19.0 is released. could you have a try?

// @ivenxu @ryno1234

0.19.0 is released. could you have a try?

// @ivenxu @ryno1234

Just tested, it works for me. Thank you guys a lot!

@testforstephen seems there is now a side effect that if an object like StringBuffer or String is very large the variables display crashes or timeouts, and no variables are displayed at all. Maybe you could show some meaningful error notification in this case. Otherwise it was difficult for me to figure out that the reason my list of local variables was empty was because of a large string in the variables and the showToString setting.

@lastant nice catch, will take a look at this edge case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manastalukdar picture manastalukdar  路  7Comments

bsaby picture bsaby  路  8Comments

AlexMAS picture AlexMAS  路  5Comments

khe817 picture khe817  路  4Comments

James-Oswald picture James-Oswald  路  3Comments