Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to tell IntelliJ IDEA to automatically invoke toString() on the objects inspected in watches, variables, tool tip windows?

Tags:

In Eclipse, when a variable is inspected and Eclipse is able to show its value, it does so by calling toString().

IntelliJ IDEA does not do it. Can it be told to?

Thanks.

like image 217
mark Avatar asked Jun 25 '12 12:06

mark


People also ask

How do I inspect an object in IntelliJ?

IntelliJ IDEA allows you to inspect variables in a dedicated dialog. This is useful when you need to keep track of some variable (or the object whose reference it holds) and at the same time be able to navigate between frames and threads. Right-click a variable on the Variables tab and select Inspect.

How do I disable toString in IntelliJ?

The solution was simply to uncheck "Enable 'toString()' object view" -> Apply -> re-enable the same option -> apply and they're back!


2 Answers

Settings | Debugger | Data Views:

Enable toString()

like image 81
CrazyCoder Avatar answered Sep 30 '22 04:09

CrazyCoder


Using IDEA 13.1:

Preferences -> Debugger -> Data Type Renderers

  • +(add) new renderer, give it a name

  • On 'When rendering the node' select option 'Use following expression', type in 'toString()'.

This seems to give me Eclipse-like behaviour.

I'd paste a picture... but don't have enough points. :P

like image 42
kva1966 Avatar answered Sep 30 '22 03:09

kva1966