IntelliJ IDEA 14.0.0 Web Help

Evaluating Expressions

IntelliJ IDEA enables you to evaluate an arbitrary expression in the context of a stack frame currently selected in the Frames pane of the Debug window. The following modes are available:

  • Expression Mode for evaluating single-line expressions.
  • Code Fragment Mode for evaluating short code portions introducing them in the Statements to evaluate text field. Supported constructs are declarations, assignments, loops andif/else.

Besides that, IntelliJ IDEA provides a way to quickly evaluate an expression in the editor at caret or a selection.

To evaluate an arbitrary expression

  1. In the Frames pane, select the thread where you want an expression to be evaluated.
  2. Invoke the Evaluate Expression in one of the following ways:
    • On the main menu, choose Run | Evaluate Expression
    • On the context menu of the editor, choose Evaluate Expression
    • Press Alt+F8
    • Click variables_evaluate_expr on the stepping toolbar of the Debug tool window.
  3. Select the desired mode of evaluation. If you want to evaluate a code fragment, click the Code Fragment Mode button.
  4. Depending on the mode selected, type the expression or statements to evaluate in the text field.
  5. Click Evaluate. If the specified expression cannot be evaluated, the possible reason will be briefly described in the Result pane of the dialog box.

To quickly evaluate an expression in the editor

See Also

Last modified: 12 November 2014
comments powered by Disqus