From 079040cffd83afc3821d5b82997268a9feedd9cf Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sun, 29 Jan 2006 22:47:34 +0000 Subject: [PATCH] suppress "variable not initialized" error for break statements. In switch-case statements it is recommended to have a break statement in each case (even after return), so you don't get different code, if you later remove the return statement. --- .../phpdt/internal/compiler/parser/Parser.java | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index a9fdbb2..d82979c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -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) -- 1.7.1