Java IntelliJ 的“立即”窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3112363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Immediate' window for IntelliJ
提问by Jon Onstott
I'm using IntelliJ 9 and I'm curious if there is any IntelliJ equivalent of the Visual Studio 'immediate' debug window. There is selecting the desired expression in the editor, then ALT-F8to evaluate the expression, but I'd like to be able to write code in a window that interacts with what I am currently debugging (if that's even possible).
我正在使用 IntelliJ 9,我很好奇是否有任何与 Visual Studio“立即”调试窗口等效的 IntelliJ。在编辑器中选择所需的表达式,然后ALT-F8评估表达式,但我希望能够在与我当前调试的内容交互的窗口中编写代码(如果可能的话)。
Having breakpoints that log messages to the console is helpful, but I'd like to do more than that if I can.
将消息记录到控制台的断点很有帮助,但如果可以的话,我想做更多的事情。
采纳答案by Noel Ang
Intellij IDEA's Expression Evaluation dialog has a button to enable Code Fragment Mode, which permits multi-statement evaluations. (I'm using version 9.0.2 of the Ultimate Edition.)
Intellij IDEA 的 Expression Evaluation 对话框有一个按钮来启用Code Fragment Mode,它允许多语句评估。(我使用的是终极版 9.0.2 版。)
回答by bwawok
You can write code in alt-f8.. but you have to do it only 1 line at a time. If you do a return, your code will return when you hit next (I think). It isn't ideal though...
您可以在 alt-f8 中编写代码 .. 但一次只能写 1 行。如果您返回,您的代码将在您点击下一个时返回(我认为)。虽然并不理想...
回答by om-nom-nom
Same as @Noel answer, but some more details. First of all, Expression Evaluation(ALT+ F8) can be enabled only in debug mode.
与@Noel 的回答相同,但有更多细节。首先,表达式求值( ALT+ F8)只能在调试模式下启用。
回答by ROMANIA_engineer
IntelliJ IDEA 13Community Edition, Windows:
IntelliJ IDEA 13社区版,Windows:
- Go to Debug modeand run the application
Go to Evaluate Expression:
or right click in the editor area:
Go to Code Fragment Mode
Type your statements and click on Evaluate
- 进入调试模式并运行应用程序
转到评估表达式:
或右键单击编辑器区域:
进入代码片段模式
输入您的陈述并点击评估
回答by AzzamAziz
FYI for anyone looking for this in 2019: I tried to do this in IntelliJ IDEA 2019.1 (Ultimate Edition) but couldn't find Code Fragment Mode button in the Expression Evaluation Dialog.
对于在 2019 年寻找此内容的任何人,仅供参考:我尝试在 IntelliJ IDEA 2019.1(终极版)中执行此操作,但在表达式评估对话框中找不到代码片段模式按钮。
As documented here: It is now the tiny two arrows pointing away from each other diagonally at the end of the expression box.
如此处所述:现在是表达式框末端对角线相互远离的两个微小箭头。