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

Bug 349782

Summary: [quick assist] "Convert to enhanced for loop" isn't available for loops over array with prefix increment
Product: [Eclipse Project] JDT Reporter: Dmitry Matveev <dmitriy.g.matveev>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: deepakazad
Version: 3.7   
Target Milestone: 3.8 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Dmitry Matveev CLA 2011-06-20 01:33:58 EDT
Build Identifier: M20110210-1200

    public static void main(String[] args)
    {
        for (int i = 0; i < args.length; ++i) { // "Convert to enhanced for loop" refactoring should be available on this line
            String arg = args[i];
            System.out.println(arg);
        }
        for (int i = 0; i < args.length; ++i) {
            String arg = args[i];
            System.out.println(arg);
        }
    }

Reproducible: Always

Steps to Reproduce:
1. Paste example function to some class.
2. Open suggestion window on for loop header (Ctrl-1).
3. Expected: "Convert to enhanced for loop" command is in list of suggestions, actual: It isn't.
Comment 1 Deepak Azad CLA 2011-06-20 01:44:55 EDT
Fix to go in org.eclipse.jdt.internal.corext.fix.ConvertForLoopOperation.validateUpdaters(ForStatement)
Comment 2 Deepak Azad CLA 2011-09-30 23:56:58 EDT
Fixed in HEAD. Commit - a5cb166bdf05e661f28b4234df6cdddde7912634