suppress "variable not initialized" error for break statements. In switch-case statem...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index a9fdbb2..d82979c 100644 (file)
@@ -428,8 +428,13 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                if (branchStatement && statement != null) {
                                        // reportSyntaxError("Unreachable code", statement.sourceStart,
                                        // statement.sourceEnd);
-                                       problemReporter.unreachableCode(new String(scanner.getCurrentIdentifierSource()), statement.sourceStart,
+                                       if (! (statement instanceof BreakStatement)) {
+                                               /* don't give an error for break statement following return statement
+                                               Technically it's unreachable code, but in switch-case it's recommended to
+                                               avoid accidental fall-through later when editing the code */
+                                               problemReporter.unreachableCode(new String(scanner.getCurrentIdentifierSource()), statement.sourceStart,
                                                        statement.sourceEnd, referenceContext, compilationUnit.compilationResult);
+                                       }
                                }
                                if ((token == TokenNameRBRACE) || (token == TokenNamecase) || (token == TokenNamedefault) || (token == TokenNameelse)
                                                || (token == TokenNameelseif) || (token == TokenNameendif) || (token == TokenNameendfor)