Java Eclipse 评估表达式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23487906/
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
Java Eclipse evaluate expression
提问by Rory Lester
Is it possible to evaluate a expression in Eclipse similar to IntelliJ. Where you can dynamically type code and the result will be displayed during debug?. I know it does something similar "Display" but you need to highlight code that has been written (so you cant write any new code unless you re-compile).
是否可以在 Eclipse 中评估类似于 IntelliJ 的表达式。在哪里可以动态键入代码并在调试期间显示结果?。我知道它执行类似“显示”的操作,但您需要突出显示已编写的代码(因此除非重新编译,否则您无法编写任何新代码)。
Perhaps there are plugins that i could use?. I have just started using eclipse
也许有我可以使用的插件?我刚开始使用 eclipse
采纳答案by Sleeper9
There is a Displayview as well that can do exactly what you want. Go to Window > Show view > Display
(or Other... if the Display viewis not there. In the Display view, you can type any code you want during debug (content assist is available). The current objects and variables are also available to use. After you wrote your code, you have to highlight it, right click and select Execute
or hit CTRL-U
. You may play around with the other possible actions as well.
还有一个显示视图,可以完全满足您的要求。转到Window > Show view > Display
(或其他...如果显示视图不存在。在显示视图中,您可以在调试期间键入您想要的任何代码(内容辅助可用)。当前对象和变量也可以使用。在您之后写了你的代码,你必须突出显示它,右键单击并选择Execute
或点击CTRL-U
。你也可以尝试其他可能的操作。
Besides that, you can also write in the source code during debug and evaluate it using Displayas you mentioned, if you have the source for the class you are debugging.
除此之外,如果您有正在调试的类的源代码,您还可以在调试期间编写源代码并使用您提到的Display对其进行评估。
回答by Kyle Anderson
You can change variable values on the fly using the Debug perspective. The top right corner of Eclipse should have the variables view from which you can select a variable name and change its value. You can also set conditional breakpoints by selecting the breakpoints view in the top right corner of Eclipse. Right-click on the breakpoint and select breakpoint properties. Check the conditional checkbox and write an expression that only when it evaluates as true does the program suspend during Debugging.
您可以使用 Debug 透视图动态更改变量值。Eclipse 的右上角应该有变量视图,您可以从中选择变量名称并更改其值。您还可以通过选择 Eclipse 右上角的断点视图来设置条件断点。右键单击断点并选择断点属性。选中条件复选框并编写一个表达式,只有当它评估为真时,程序才会在调试期间挂起。
回答by fishinear
Select any expression in your code. Then right-click and select "Display" (or press the associated key-combination).
选择代码中的任何表达式。然后右键单击并选择“显示”(或按相关的组合键)。
For completely new expressions, use the Display view. It's like a scrapbook for expressions. If the Display view is not visible, select Window > Show view > Display
to add it. Then type any expression in the view, and do the same thing as for expressions in your code: select the expression, right-click and select "Display".
对于全新的表达式,请使用显示视图。它就像一个表达的剪贴簿。如果“显示”视图不可见,请选择Window > Show view > Display
添加它。然后在视图中键入任何表达式,并执行与代码中表达式相同的操作:选择表达式,右键单击并选择“显示”。
For expressions that you want to always see the value of, every time execution is halted, use the Expressions view instead.
对于您希望始终查看其值的表达式,每次执行停止时,请改用“表达式”视图。