Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334253 - [navigation] "Open Declaration" (F3) does not work for labels
Summary: [navigation] "Open Declaration" (F3) does not work for labels
Status: CLOSED DUPLICATE of bug 269112
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-13 07:42 EST by Missing name Mising name CLA
Modified: 2011-01-21 01:41 EST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Missing name Mising name CLA 2011-01-13 07:42:00 EST
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".
Comment 1 Ayushman Jain CLA 2011-01-13 08:38:55 EST
(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.
Comment 2 Srikanth Sankaran CLA 2011-01-16 23:44:11 EST
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")
Comment 3 Olivier Thomann CLA 2011-01-20 11:11:29 EST
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 ?
Comment 4 Markus Keller CLA 2011-01-20 20:07:48 EST
(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).
Comment 5 Dani Megert CLA 2011-01-21 01:40:16 EST

*** This bug has been marked as a duplicate of bug 222368 ***
Comment 6 Dani Megert CLA 2011-01-21 01:41:45 EST

*** This bug has been marked as a duplicate of bug 269112 ***