View of watches configurable?

Back in the old days when I was working with Visual C++, someone showed me an little-(if-at-all-)documented feature which allowed you to configure the way objects of certain classes were displayed in the watches window during debugging; this was very convenient especially for "record" classes which merely acted as data holders, e.g. as in

When watching a variable or member of type Money, the watch window would by default display that expression the way you would expect, but if you edited a certain config file correctly, then it would display something like "15.99 USD" in one line instead.

So this was something that resembled the "Alternate view for collections classes" or "View toString()" features in IDEA, but even went beyond that.

Now, is there any way in IDEA (possibly via the OpenAPI) to achieve that same functionality? Otherwise I would consider it worth a feature request.

Regards,
Jens

6 comments
Comment actions Permalink

Just implement toString() so that it returns the representatin you'd like to see in debugging mode open the "Frame"-tab, right-click into it and from the context menu choose "View toString" and you'll get what you want without changing any mysterious config files.

0
Comment actions Permalink

I was a bit fast here. This option only exists in the "Frame"-view but not in the "Watches"-view.

0
Comment actions Permalink

I have added a request to the tracker to get this "View toString()" functionality for the Watches, too. You can vote for it at http://www.intellij.net/tracker/idea/viewSCR?publicId=12415

0
Comment actions Permalink

Just implement toString() so that it returns the
representatin you'd like to see in debugging mode
open the "Frame"-tab, right-click into it and from
the context menu choose "View toString" and you'll
get what you want without changing any mysterious
config files.


This is not a satisfactory solutions, for (at least) three reasons:

1. The way a variable is displayed in a window of an IDE should not depend on a part of the class. After all, the toString() method generally serves a purpose, and just viewing instances in an IDE does not justify modifying that method.
2. For classes for which I don't have the source, I have no way of customizing the toString() method in the first place.
3. Currently, every time the value of the member changes (e.g. between two breaks in debug mode), the view on that member is reset to "normal" (as opposed to) "toString()" mode. It is very tedious to click the view back every time the debugger halts.

An alternative workaround would be to create static classes which transform instances of the respective classes to an appropriate string and then set up corresponding watches, but what I don't like about this solution is that
1. this would only apply to the "Watches" window and not the "Frame" window,
2. I would still have to write Java code for a very simple task for which a configurability could easily be set up.

I have created an own tracker entry (http://www.intellij.net/forums/thread.jsp?forum=15&thread=30233) for this request.

Regards,
Jens

0
Comment actions Permalink

But it does exist for watches as well - if the watch is evaluated to an object, then the option is available.

--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"

"Robert F. Beeger" <jiveadmin@jetbrains.com> wrote in message news:29387373.1053421718083.JavaMail.jrun@is.intellij.net...

I was a bit fast here. This option only exists in the "Frame"-view but not in the "Watches"-view.



0
Comment actions Permalink

3. Currently, every time the value of the member changes (e.g. between two breaks in debug mode), the view on that member is reset

to "normal" (as opposed to) "toString()" mode. It is very tedious to click the view back every time the debugger halts.

You can configure data types that are automatically displayed as "toString()" in File | Project Properties | Debugger


--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"


0

Please sign in to leave a comment.