Eclipse:改进调试并在 mouseOver 上显示变量值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1363584/
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
Eclipse: Improve debugging and display variable values on mouseOver
提问by Soni Ali
Is it possible to view variable values in Eclipse when debugging? Right now when I "mouse over" a variable all I get is the definition. e.g. for [int mLastView] I get [com.company.samples.MyClass.mLastView] instead of 1. The value that was assigned to it.
调试时是否可以在 Eclipse 中查看变量值?现在,当我“将鼠标悬停在”一个变量上时,我得到的只是定义。例如对于 [int mLastView] 我得到 [com.company.samples.MyClass.mLastView] 而不是1。分配给它的值。
Also, is there anyway to improve debugging in Eclipse?
另外,有没有办法改进 Eclipse 中的调试?
For starter: making the breakpoints visible as in VS (see below)?
对于初学者:使断点在 VS 中可见(见下文)?
Eclipse Break Point
Eclipse 断点
Visual Studio Break Point
Visual Studio 断点
回答by afwerwerw
I posted this over at Stack Overflow and one of the suggestions was to go into Window -> Preferences -> Java -> Editor -> Hovers and select the Variable Values option and assign a modifier.
我在 Stack Overflow 上发布了这个,其中一个建议是进入 Window -> Preferences -> Java -> Editor -> Hovers 并选择 Variable Values 选项并分配一个修饰符。
When I was first trying to resolve this issue, this was one of the options I looked at, but oddly enough, there was no Variable Values preference available, it was missing. Once my “fix” above was applied, it magically appeared:
当我第一次尝试解决这个问题时,这是我查看的选项之一,但奇怪的是,没有可用的变量值首选项,它丢失了。一旦应用了我上面的“修复”,它就神奇地出现了:
回答by VonC
Actually, since eclipse3.4, not only do you see the value of a variable when you pass the mouse over it, you can actually inspect it:
实际上,从eclipse3.4 开始,您不仅可以在将鼠标悬停在变量上时看到它的值,还可以实际检查它:
When debugging, hovers for variables have been enhanced to display an object inspector. The inspector will display logical structures according to the toggle setting in the visible Variables or Expressions view.
调试时,变量悬停已得到增强以显示对象检查器。检查器将根据可见变量或表达式视图中的切换设置显示逻辑结构。
回答by Wayne Beaton
If you hit the breakpoint while you are debugging, you do see the value of the variable when you mouse over. You can also select an expression, and inspect the value of it's evaluation using the "Inspect" menu option. You can also use the "Variables" view to see the current value of all in-scope variables.
如果在调试时遇到断点,鼠标悬停时会看到变量的值。您还可以选择一个表达式,并使用“检查”菜单选项检查它的评估值。您还可以使用“变量”视图查看所有范围内变量的当前值。
回答by virgo47
About breakpoint visibility:
关于断点可见性:
Right-click on the right outline of the editor, you'll see some Preferences, and there in Annotations you can select Breakpoints. I personally added Text as Highlighted and some pinky colour. Shame that the highlighting is really buggy, sticks here and there, breaks between lines, etc. But it somehow works for most cases.
右键单击编辑器的右侧轮廓,您将看到一些 Preferences,然后在 Annotations 中您可以选择 Breakpoints。我个人将文本添加为突出显示和一些粉红色。遗憾的是,突出显示真的有问题,到处都是,在行之间断线等等。但它以某种方式适用于大多数情况。
(Another shame is that breakpoint bullet is often hidden behind some suggestion icon or what - why they can't make the gutter wider like Idea does, I don't know.)
(另一个耻辱是断点项目符号通常隐藏在一些建议图标或什么后面 - 为什么他们不能像 Idea 那样使排水沟更宽,我不知道。)
回答by tommy le
I got similar but a little different problem with the thread-starter. Sometimes during debugging, I mouse over a variable, I see it current value. Sometimes it's just the definition, like in coding mode. So what caused the first case, what the second?
我在线程启动器上遇到了类似但有点不同的问题。有时在调试过程中,我将鼠标悬停在一个变量上,我看到它是当前值。有时它只是定义,就像在编码模式中一样。那么是什么导致了第一种情况,第二种情况呢?
PS: Of course I can always choose to view Variables (Alt+Shift+Q,V) but it's faster if you have mouse over value instantly. Thanks
PS:当然我总是可以选择查看变量(Alt+Shift+Q,V)但是如果您立即将鼠标悬停在值上会更快。谢谢