Project: JDT
Bug 196510 [quick fix] No quickfix for warning "Statement unnecessarily nested within else clause." when if statement is the action statement of a while statement
Reported: 2007-07-13 17:35:57 | Status: resolved fixed

Build ID: I20070625-1500 Steps To Reproduce: In a method like this: boolean foo (int i) { while (i < 100) if (i == 42) return true; else i = i + 3; return false; } ...Eclipse 3.3 displays a warning on the line "i = i + 3;", saying "Statement unnecessarily nested within else clause. The corresponding then clause does not complete normally" and shows a Quick Fix icon - but does not offer a quick fix. More information: When the if statement is nested inside another control statement, it is not possible to turn the else part into a separate statement, unless you introduce a block around the if statement. I cannot find an option in Preferences to suppress this warning. So, a couple of bugs: 1) Warning on a reasonable and common construct 2) Quick fix icon with no quick fix 3) No way to suppress warning

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java