Community
Participate
Working Groups
Eclipse beeps and gives the message "Selection does not contain a field" if you try to add a breakpoint on a line with a variable declaration. The message could be made much clearer. -- Configuration Details -- Product: Eclipse 1.3.2.20110218-0812 (org.eclipse.epp.package.java.product) Installed Features: org.eclipse.jdt 3.6.2.r362_v20101117-0800-7z8XFW6FLFlmjJcvz03jyeFBLS_F
I mean a line like: int x;
You only get that vague error when we fail to resolve the field you are trying to set the watchpoint on in the backing AST. Joshua can you attach the snippet that causes the exception to be shown? I suppose at the very minimum we could include the text of the selection in the error message - something like "'String foo' does not contain a valid field name"
Any local variable definition seems to give the message. Part of the problem is that I was trying to set a breakpoint, not a watchpoint. (I'd simply maant to break "around here" in a method, not thinking about whether the line was declaration vs. statement.) Now that you've put the watchpoint/breakpoint distinction in my head, I think I have a solution: the message should say (assuming this is always true in eclipse) "Watchpoints cannot be set on local variables." (I don't think adding the '"String foo" does not contain' would have helped me by the way.)
(In reply to comment #3) > Any local variable definition seems to give the message. > > Part of the problem is that I was trying to set a breakpoint, not a watchpoint. > (I'd simply maant to break "around here" in a method, not thinking about > whether the line was declaration vs. statement.) > How are you trying to set the breakpoint? No matter how I try to set a breakpoint on fields (local or otherwise / line bp or watchpoint) it works as expected - I do not see the message. > Now that you've put the watchpoint/breakpoint distinction in my head, I think I > have a solution: the message should say (assuming this is always true in > eclipse) "Watchpoints cannot be set on local variables." Would it be possible for you to run your test case on a newer version of Eclipse (3.8/4.2)? We have made a few changes since 3.6 to how we toggle breakpoints.
I see it whether I double-click the sidebar or use the Shift-Cmd-B keyboard shortcut. It may be some time before I'm able to upgrade to a newer eclipse I'm afraid. I'll see what I can do.
(In reply to comment #5) > I see it whether I double-click the sidebar or use the Shift-Cmd-B keyboard > shortcut. > > It may be some time before I'm able to upgrade to a newer eclipse I'm afraid. > I'll see what I can do. In the meantime then, since we both agree an update to the message will not be sufficient and I cannot reproduce, I will close as WORKSFORME and we can reopen once you get a chance to test a newer version of Eclipse (if needed).
That's fine.
When I double-click the annotation ruler or use Run > Toggle Breakpoint on a line that just declares a local variable, the breakpoint is not accepted. However, when I try to do the same on a line before, then it works (toggles the line breakpoint on the next applicable line). Snippet: void foo() { System.out.println(1); // can toggle breakpoint on these empty lines => jumps to "index = 2" int index; // cannot set a breakpoint index = 2; System.out.println(index); } If you use the command or double-click in the vertical ruler, you can see an error message in the status bar, saying "Selection does not contain a field". (Caveat: If you double-click the line number/change ruler, the message quickly disappears. That's bug 483747). The message "Selection does not contain a field" doesn't make sense and should not be generated for local variable without an initializer. Toggling a breakpoint on that line should work the same as on the empty lines before. I guess the problem is that the local variable declaration is wrongly considered to be a field declaration.
*** Bug 333600 has been marked as a duplicate of this bug. ***
Thanks Markus, I am able reproduce it with the attached snippet.
The current error message is: > This operation is unavailable on the current selection. Please select or place the cursor on a field. Test code: int global = 0; int main() { int local = 0; local = 1; global = 1; } To reproduce, select the declaration of "local", and do "Run -> Toggle watchpoint". See also: https://stackoverflow.com/questions/45774814/how-to-create-a-watchpoint-for-a-local-variable-in-eclipse-cdt
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Still an issue.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.