Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 339176

Summary: [navigation] Ctrl+click on continue must jump to the label
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: TextAssignee: Raksha Vasisht <raksha.vasisht>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P2 CC: daniel_megert, markus.kell.r
Version: 3.7   
Target Milestone: 3.7 M7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Part 2 of fix none

Description Deepak Azad CLA 2011-03-08 03:43:56 EST
----------------------------------------------------------------------
package snippet;
public class Snippet {
	 public static void main(String[] args) {
	        aaa: for (int i= 0; i < args.length; i++) {
	            String string= args[i];
	            bbb: for (int j= 0; j < string.length(); j++) {
	                char ch= string.charAt(j);
	                switch (ch) {
	                    case 'a':
	                        continue bbb;           //1
	                    case 'b':
	                        break bbb;
	                    case 'c':
	                        continue;		//2
	                    case 'd':
	                        break;
	                }
	                if (ch == 0) {
	                    System.out.println(ch);
	                    break;
	                }
	            }
	        }
	    }
}
---------------------------------------------------------------------
- Ctrl+click 'continue' at 2 => it jumps to 'for' labelled 'bbb'
- Ctrl+click 'continue' at 1 => it jumps to label 'bbb' 
Expected: Jump to the for statement labelled 'bbb'. This would be similar to how Ctrl+click on 'break' works.
Comment 1 Markus Keller CLA 2011-03-09 13:17:15 EST
> - Ctrl+click 'continue' at 1 => it jumps to label 'bbb' 
> Expected: Jump to the for statement labelled 'bbb'. This would be similar to
> how Ctrl+click on 'break' works.

Yes, but it would not match the Mark Occurrences target. That one also marks the label, and I actually like that behavior (since it really continues at the label, and if you have complicated code with many labels, the label is more interesting than the 'for').

Selecting 'for' is just a fallback if the ContinueStatement misses a label.

For ultimate consistency, I would rather change //2 to highlight and jump to the label as well.
Comment 2 Dani Megert CLA 2011-03-16 08:04:41 EDT
> For ultimate consistency, I would rather change //2 to highlight and jump to
> the label as well.
+1. Raksha, please fix Ctrl+click and the semantic highlighting.
Comment 3 Raksha Vasisht CLA 2011-04-14 04:58:28 EDT
(In reply to comment #2)
> > For ultimate consistency, I would rather change //2 to highlight and jump to
> > the label as well.
> +1. Raksha, please fix Ctrl+click and the semantic highlighting.

Fixed in org.eclipse.jdt.internal.ui.search.BreakContinueTargetFinder.java
Comment 4 Dani Megert CLA 2011-04-21 08:20:09 EDT
The fix is good but it missed to update the highlighting/finding in case of 'break': it should also highlight the label and not the statement - like in the (fixed) 'continue' case.

Also, no tests were added.

I've fixed both issues in HEAD.
Available in builds >= I20110421-1300.
Comment 5 Dani Megert CLA 2011-04-21 08:21:08 EDT
Created attachment 193809 [details]
Part 2 of fix
Comment 6 Dani Megert CLA 2011-04-26 10:41:49 EDT
Verified in I20110425-1800.