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

Bug 307150

Summary: Enhanced For Loop cleanup causes compile errors
Product: [Eclipse Project] JDT Reporter: Jeramyn Feucht <jfeucht>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, Olivier_Thomann
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Save this file with enhanced for loop cleanup to demonstrate none

Description Jeramyn Feucht CLA 2010-03-25 19:27:59 EDT
Build Identifier: I20090611-1540

Also checked in  20100318-1801

The following code will break after a code cleanup for enhanced for loops, the cleanup should skip this code. 

private static void function1() {
	List<String> data=new ArrayList<String>();
	for (Iterator<String> iterator = data.iterator(); iterator.hasNext();) {
	    String row = iterator.next();
	    // Put a horizontal rule between each record
	    function2(iterator.hasNext());
	}
    }
    private static void function2(boolean b){
	//Do nothing
    }


Reproducible: Always

Steps to Reproduce:
1. Turn on the code clean-up "Convert for loops to enhanced for loops" on save.
2. Edit the code in the test case.
3. Save.
Comment 1 Jeramyn Feucht CLA 2010-03-25 19:30:05 EDT
Created attachment 163048 [details]
Save this file with enhanced for loop cleanup to demonstrate

Example java code that will trigger the bug in the cleanup.
Comment 2 Olivier Thomann CLA 2010-03-26 22:05:54 EDT
Moving to JDT/UI
Comment 3 Markus Keller CLA 2010-03-29 06:45:55 EDT

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