Community
Participate
Working Groups
Build Identifier: 20100617-1415 In a Java source code, the user selects a label of a break or continue statement, and clicks F3. There appears the message "Current text selection cannot be opened in an editor". Instead, the editor should highlight the label being referred to, and position it in the visible part of the source code window if necessary. Reproducible: Always Steps to Reproduce: 1. Create a class in the default package with the following five lines of code: public class X {{ Lb: for(;;) { break Lb; } }} 2. Click between the two letters "Lb" in the break statement. 3. Hit the F3 key or select the context menu command "Open Declaration".
(In reply to comment #0) The open declaration, as the name suggests is really meant for browsing to the declaration of the selected elements. This is to give the user convenience to directly go to the file and line no. where the actual definition takes place. Labels have no declaration per se. Also, they are not really used across files, so its anyways not hard to find them. Using CTRL+K (or find) should get you to the label. I intend to close this as INVALID.
I have attempted to "use" this non-existent feature many times. So also with find references. I think while browsing code, it would/could be useful. The problem with ctrl-K is that it does textual search and may put you in non declarations or worse wrong declarations. Attempting to find references to a label issues an error message that offers a clue on the internal implementation constraints: ( "please select a valid java element")
F3 works for java element. Since labels don't have a corresponding java element, I think it is working as expected. Markus, do you think the F3 feature should be extended to support labels ?
(In reply to comment #3) > Markus, do you think the F3 feature should be extended to support labels ? Yes, but I wouldn't add labels to the Java model now. If we implement this, we would best do it in JDT/Text (in OpenAction and JavaElementHyperlinkDetector, using the shared AST). Workaround for now is Ctrl+Shift+U, Enter (Search > Occurrences in File). Note that 'Occurrences in File' had a nasty focus issue, but I've just fixed that in HEAD (bug 334966).
*** This bug has been marked as a duplicate of bug 222368 ***
*** This bug has been marked as a duplicate of bug 269112 ***