Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging expression evaluation

I'm using IntelliJ idea Community edition (with Scala) and I'm trying to evaluate an expression. I hit Alt-F8 to open it in debug mode and then switch to 'Code Fragment Mode'. However, I'm allowed to only evaluate variables that already exist in memory, and am not allowed to declare new. When I do so, I get- 'Evaluation of variables is not supported'. Is there a plugin that I can use in debug mode to evaluate arbitrary code?

EDIT: So that it's clear, no worksheets are not what I'm looking for. I want to evaluate expressions using variables existing at runtime.

like image 666
0fnt Avatar asked Jul 16 '14 09:07

0fnt


People also ask

How do you evaluate an expression while debugging in Intellij?

Evaluate a complex expression in the editorClick Run | Debugging Actions | Quick Evaluate Expression Ctrl+Alt+F8 . Alternatively, hold Alt and click the selection.

How do you evaluate expressions in Intellij?

Evaluate an arbitrary expression If you want to start with some expression or a variable, select it in the editor or in any view in the Debug window. Open the Evaluate dialog in one of the following ways: Press Shift+F9 . Select Evaluate Expression from the context menu.

How do you evaluate expressions?

To evaluate an algebraic expression means to find the value of the expression when the variable is replaced by a given number. To evaluate an expression, we substitute the given number for the variable in the expression and then simplify the expression using the order of operations.


2 Answers

Have you considered using a Scala Worksheet, which is a kind of editor supported REPL. You can create one in your project, import code from your project, execute it and see the results instantly. It wont let you debug to a piece of code though, if that is your primary intention.

like image 154
Markus Avatar answered Oct 04 '22 08:10

Markus


It's an old question, but for now there is a good answer:

https://www.jetbrains.com/help/idea/2016.1/evaluating-expressions.html

TL;DR: During debugging, click on a stack frame, and you'll be able to evaluate expressions in the context of that frame: Run|Evaluate Expression, and you can click "Code Fragment Mode" to enter multi-line stuff. IntelliJ autocomplete features would work properly too!

like image 23
morfizm Avatar answered Oct 04 '22 10:10

morfizm