In Intellij Idea, I\'m looking for a way to evaluate many expressions in debug mode with one command.
Normally I can evaluate single command with Right Click →
well i was also struggling a lot with this, until i figured out that in the code it needs fully qualified paths for classes (for classes outside of java.*)
for example in this code below , i needed to find out , xml string representation from the document object (doc is my document object)
so i had to put this code into evaluate tab , which you can open from run window -after putting in below expression and clicking on evaluate - my xml string was printed in console
javax.xml.transform.TransformerFactory tf = javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = tf.newTransformer();
java.io.StringWriter writer = new java.io.StringWriter();
transformer.transform(new javax.xml.transform.dom.DOMSource(doc), new javax.xml.transform.stream.StreamResult(writer));
System.out.println(writer.getBuffer().toString());
You can evaluate such expressions in Evaluate window
System.out.println(myVar1);
System.out.println(myVar2);
The only thing here is that your whole result (not last) will appear not in the same window but in a console.
You have to click "Code fragment mode" in the evaluate expression dialog (Alt+F8) and you can enter as many lines as you want instead of single line - which is default - "Expression mode".
Then you can switch back anytime using "Expression mode" button.
You can either click the small fullscreen arrows button to the right of the Expression box, or press shift
+enter
.
If you want to edit a multi-line expression or a code fragment, click Expand in the Expression field or press ⇧⏎ to switch to the multi-line Code fragment view and back.
https://www.jetbrains.com/help/idea/evaluating-expressions.html