diff --git a/org.eclipse.jdt.core.compiler.batch/grammar/java.g b/org.eclipse.jdt.core.compiler.batch/grammar/java.g index dcd8957191a..dfc86bb8a97 100644 --- a/org.eclipse.jdt.core.compiler.batch/grammar/java.g +++ b/org.eclipse.jdt.core.compiler.batch/grammar/java.g @@ -235,7 +235,7 @@ Goal ::= '->' SwitchLabelCaseLhs Goal ::= RestrictedIdentifiersealed Modifiersopt Goal ::= RestrictedIdentifierpermits PermittedSubclasses -- jsr 427 -- -Goal ::= BeginCaseElement Pattern +Goal ::= CaseLabelPatternElements Goal ::= RestrictedIdentifierWhen Expression /:$readableName Goal:/ @@ -1598,34 +1598,41 @@ SwitchLabelCaseLhs ::= 'case' CaseLabelElements -- END SwitchExpression (JEP 325) -- -CaseLabelElements -> CaseLabelElement -CaseLabelElements ::= CaseLabelElements ',' CaseLabelElement +CaseLabelElements -> CaseLabelConstantElements +CaseLabelElements -> CaseLabelPatternElements + +CaseLabelConstantElements ::= CaseLabelConstantElement +CaseLabelConstantElements ::= CaseLabelConstantElements ',' CaseLabelConstantElement /.$putCase consumeCaseLabelElements(); $break ./ -/:$readableName CaseLabelElements:/ +/:$readableName CaseLabelConstantElements:/ -- Production name hardcoded in parser. Must be ::= and not -> (need to hook at cCLE) -CaseLabelElement ::= ConstantExpression +CaseLabelConstantElement ::= ConstantExpression /.$putCase consumeCaseLabelElement(CaseLabelKind.CASE_EXPRESSION); $break ./ /:$readableName CaseLabelElement:/ -- following 'null' in CASE_EXPRESSION - passes through existing grammar -- CaseLabelElement -> 'null' -CaseLabelElement ::= 'default' +CaseLabelConstantElement ::= 'default' /.$putCase consumeCaseLabelElement(CaseLabelKind.CASE_DEFAULT); $break ./ /:$readableName CaseLabelElement:/ -CaseLabelElement ::= CaseLabelElementPattern -/.$putCase consumeCaseLabelElement(CaseLabelKind.CASE_PATTERN); $break ./ +CaseLabelPatternElements ::= CaseLabelPatternElementsInternal /:$readableName CaseLabelElement:/ -CaseLabelElement ::= CaseLabelElementPattern Guard -/.$putCase consumeCaseLabelElement(CaseLabelKind.CASE_PATTERN); $break ./ -/:$readableName CaseLabelElement:/ +CaseLabelPatternElementsInternal ::= BeginCaseElement CasePatternList +CaseLabelPatternElementsInternal ::= BeginCaseElement CasePatternList Guard -CaseLabelElementPattern ::= BeginCaseElement Pattern -/.$putCase consumeCaseLabelElementPattern(); $break ./ -/:$readableName CaseLabelElementPattern:/ +CasePatternList ::= CasePattern +/:$readableName CasePatternList :/ +CasePatternList ::= CasePatternList ',' CasePattern +/.$putCase consumeCaseLabelElements(); $break ./ +/:$readableName CasePatternList :/ + +CasePattern ::= Pattern +/.$putCase consumeCaseLabelElement(CaseLabelKind.CASE_PATTERN); $break ./ +/:$readableName CasePattern:/ Guard ::= RestrictedIdentifierWhen Expression /.$putCase consumeGuard(); $break ./ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java index 6f36cbb4911..a4239589720 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java @@ -2576,6 +2576,10 @@ public interface IProblem { */ int IllegalRecordPattern = TypeRelated + 1941; + /** + * @since 3.37 + */ + int CaseLabelWithPatternMustHaveExactlyOnePattern = Internal + 1942; /** * @since 3.35 diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java index ddd700a7007..50f8e1a793d 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java @@ -156,4 +156,5 @@ public boolean isUnnamed(BlockScope scope) { && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK21 && scope.compilerOptions().enablePreviewFeatures; } + } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java index 7fd247f97d5..01df029ef18 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java @@ -81,7 +81,8 @@ public FlowInfo analyseCode( local.useFlag = LocalVariableBinding.USED; // these are structurally required even if not touched } nullPatternCount += e instanceof NullLiteral ? 1 : 0; - if (i > 0 && (e instanceof Pattern)) { + if (i > 0 && (e instanceof Pattern) + && (currentScope.compilerOptions().sourceLevel < ClassFileConstants.JDK21 || !currentScope.compilerOptions().enablePreviewFeatures)) { if (!(i == nullPatternCount && e instanceof TypePattern)) currentScope.problemReporter().IllegalFallThroughToPattern(e); } @@ -172,14 +173,28 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) { private void casePatternExpressionGenerateCode(BlockScope currentScope, CodeStream codeStream) { if (this.patternIndex != -1) { - Pattern pattern = ((Pattern) this.constantExpressions[this.patternIndex]); - if (containsPatternVariable()) { + BranchLabel thenTarget = new BranchLabel(codeStream); + for (int i = 0; i < this.constantExpressions.length - 1; i++) { + Pattern pattern = ((Pattern)this.constantExpressions[i]); + pattern.thenTarget = thenTarget; LocalVariableBinding local = currentScope.findVariable(SwitchStatement.SecretPatternVariableName, null); codeStream.load(local); pattern.generateCode(currentScope, codeStream); + pattern.fullWrapupGeneration(codeStream); + codeStream.goto_(pattern.thenTarget); + pattern.elseTarget.place(); + } + Pattern pattern = ((Pattern)this.constantExpressions[this.constantExpressions.length - 1]); + pattern.thenTarget = thenTarget; + LocalVariableBinding local = currentScope.findVariable(SwitchStatement.SecretPatternVariableName, null); + codeStream.load(local); + pattern.generateCode(currentScope, codeStream); + if (pattern.countNamedVariables(currentScope) > 0) { + pattern.wrapupGeneration(codeStream); } else { - pattern.setTargets(codeStream); + pattern.fullWrapupGeneration(codeStream); } + pattern.setTargets(codeStream); if (!(pattern instanceof GuardedPattern)) codeStream.goto_(pattern.thenTarget); @@ -260,10 +275,16 @@ private Expression getFirstValidExpression(BlockScope scope, SwitchStatement swi if (e instanceof Pattern) { scope.problemReporter().validateJavaFeatureSupport(JavaFeature.PATTERN_MATCHING_IN_SWITCH, e.sourceStart, e.sourceEnd); - if (this.constantExpressions.length > 1) { - scope.problemReporter().illegalCaseConstantCombination(e); - return e; + if (this.constantExpressions.length > 1 || e instanceof GuardedPattern gp && gp.patterns.length > 1) { + int count = 0; + for (Expression expr : this.constantExpressions) { + count += ((Pattern)expr).countNamedVariables(scope); + } + if (count > 0) { + scope.problemReporter().illegalCaseLabelWithMultiplePatterns(this); + } } + return e; } else if (e instanceof NullLiteral) { scope.problemReporter().validateJavaFeatureSupport(JavaFeature.PATTERN_MATCHING_IN_SWITCH, e.sourceStart, e.sourceEnd); diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java index bfd62b1168b..b17f28ddf67 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java @@ -27,34 +27,49 @@ public class GuardedPattern extends Pattern { - public Pattern primaryPattern; + public Pattern[] patterns; public Expression condition; int thenInitStateIndex1 = -1; int thenInitStateIndex2 = -1; public int restrictedIdentifierStart = -1; // used only for 'when' restricted keyword. - public GuardedPattern(Pattern primaryPattern, Expression conditionalAndExpression) { - this.primaryPattern = primaryPattern; + public GuardedPattern(Pattern patterns[], Expression conditionalAndExpression) { + this.patterns = patterns; this.condition = conditionalAndExpression; - this.sourceStart = primaryPattern.sourceStart; + if (patterns.length > 0) { + this.sourceStart = this.patterns[0].sourceStart; + } else { + this.sourceStart = conditionalAndExpression.sourceStart; + } this.sourceEnd = conditionalAndExpression.sourceEnd; } @Override public LocalDeclaration getPatternVariable() { - return this.primaryPattern.getPatternVariable(); + if (this.patterns.length == 1) { + return this.patterns[0].getPatternVariable(); + } + return null; } @Override public LocalVariableBinding[] bindingsWhenTrue() { - return LocalVariableBinding.merge(this.primaryPattern.bindingsWhenTrue(), - this.condition.bindingsWhenTrue()); + LocalVariableBinding[] patternsBindings = new LocalVariableBinding[] {}; + for (Pattern pattern : this.patterns) { + patternsBindings = LocalVariableBinding.merge(patternsBindings, pattern.bindingsWhenTrue()); + } + return LocalVariableBinding.merge(patternsBindings, this.condition.bindingsWhenTrue()); } @Override public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { - flowInfo = this.primaryPattern.analyseCode(currentScope, flowContext, flowInfo); - this.thenInitStateIndex1 = currentScope.methodScope().recordInitializationStates(flowInfo); + if (this.patterns.length >= 1) { + flowInfo = this.patterns[0].analyseCode(currentScope, flowContext, flowInfo); + this.thenInitStateIndex1 = currentScope.methodScope().recordInitializationStates(flowInfo); + } + for (int i = 1; i < this.patterns.length; i++) { + flowInfo = this.patterns[i].analyseCode(currentScope, flowContext, flowInfo); + } FlowInfo mergedFlow = this.condition.analyseCode(currentScope, flowContext, flowInfo); mergedFlow = mergedFlow.safeInitsWhenTrue(); this.thenInitStateIndex2 = currentScope.methodScope().recordInitializationStates(mergedFlow); @@ -65,7 +80,29 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStream, BranchLabel trueLabel, BranchLabel falseLabel) { this.thenTarget = new BranchLabel(codeStream); this.elseTarget = new BranchLabel(codeStream); - this.primaryPattern.generateOptimizedBoolean(currentScope, codeStream, this.thenTarget, this.elseTarget); + + LocalVariableBinding local = currentScope.findVariable(SwitchStatement.SecretPatternVariableName, null); + BranchLabel toGuard = new BranchLabel(codeStream); + + for (int i = 0; i < this.patterns.length - 1; i++) { + Pattern pattern = this.patterns[i]; + pattern.thenTarget = toGuard; + pattern.generateCode(currentScope, codeStream); + pattern.fullWrapupGeneration(codeStream); + codeStream.goto_(pattern.thenTarget); + pattern.elseTarget.place(); + codeStream.load(local); + } + Pattern pattern = this.patterns[this.patterns.length - 1]; + pattern.thenTarget = toGuard; + pattern.elseTarget = this.elseTarget; + pattern.generateCode(currentScope, codeStream); + if (pattern.countNamedVariables(currentScope) > 0) { + pattern.wrapupGeneration(codeStream); + } else { + pattern.fullWrapupGeneration(codeStream); + } + toGuard.place(); Constant cst = this.condition.optimizedBooleanConstant(); setGuardedElseTarget(currentScope, this.elseTarget); @@ -75,6 +112,9 @@ public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStr this.thenTarget, null, cst == Constant.NotAConstant); + if (cst != Constant.NotAConstant) { + codeStream.goto_(this.thenTarget); + } if (this.thenInitStateIndex2 != -1) { codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.thenInitStateIndex2); codeStream.addDefinitelyAssignedVariables(currentScope, this.thenInitStateIndex2); @@ -104,25 +144,42 @@ public boolean isAlwaysTrue() { } @Override public boolean coversType(TypeBinding type) { - return this.primaryPattern.coversType(type) && isAlwaysTrue(); + if (!isAlwaysTrue()) { + return false; + } + for (Pattern pattern : this.patterns) { + if (pattern.coversType(type)) { + return true; + } + } + return false; } @Override public boolean dominates(Pattern p) { - if (isAlwaysTrue()) - return this.primaryPattern.dominates(p); + if (isAlwaysTrue()) { + for (Pattern pattern : this. patterns) { + if (pattern.dominates(p)) { + return true; + } + } + } return false; } @Override public TypeBinding resolveType(BlockScope scope) { - if (this.resolvedType != null || this.primaryPattern == null) + if (this.resolvedType != null || this.patterns[0] == null) return this.resolvedType; - this.resolvedType = this.primaryPattern.resolveType(scope); + this.resolvedType = this.patterns[0].resolveType(scope); // The following call (as opposed to resolveType() ensures that // the implicitConversion code is set properly and thus the correct // unboxing calls are generated. - this.condition.resolveTypeExpectingWithBindings(this.primaryPattern.bindingsWhenTrue(), scope, TypeBinding.BOOLEAN); + LocalVariableBinding[] patternsBindings = new LocalVariableBinding[] {}; + for (Pattern pattern: this.patterns) { + patternsBindings = LocalVariableBinding.merge(patternsBindings, pattern.bindingsWhenTrue()); + } + this.condition.resolveTypeExpectingWithBindings(patternsBindings, scope, TypeBinding.BOOLEAN); Constant cst = this.condition.optimizedBooleanConstant(); if (cst.typeID() == TypeIds.T_boolean && cst.booleanValue() == false) { scope.problemReporter().falseLiteralInGuard(this.condition); @@ -148,20 +205,27 @@ public boolean visit( return false; } }, scope); - return this.resolvedType = this.primaryPattern.resolvedType; + return this.resolvedType = this.patterns[0].resolvedType; } @Override public StringBuilder printExpression(int indent, StringBuilder output) { - this.primaryPattern.print(indent, output).append(" when "); //$NON-NLS-1$ + for (int i = 0; i < this.patterns.length; i++) { + this.patterns[i].print(indent, output); + if (i < this.patterns.length - 1) { + output.append(", "); //$NON-NLS-1$ + } + } + output.append(" when "); //$NON-NLS-1$ return this.condition.print(indent, output); } @Override public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { - if (this.primaryPattern != null) - this.primaryPattern.traverse(visitor, scope); + for (Pattern pattern : this.patterns) { + pattern.traverse(visitor, scope); + } if (this.condition != null) this.condition.traverse(visitor, scope); } @@ -170,24 +234,32 @@ public void traverse(ASTVisitor visitor, BlockScope scope) { @Override public void suspendVariables(CodeStream codeStream, BlockScope scope) { codeStream.removeNotDefinitelyAssignedVariables(scope, this.thenInitStateIndex1); - this.primaryPattern.suspendVariables(codeStream, scope); + if (this.patterns[0] != null) { + this.patterns[0].suspendVariables(codeStream, scope); + } } @Override public void resumeVariables(CodeStream codeStream, BlockScope scope) { codeStream.addDefinitelyAssignedVariables(scope, this.thenInitStateIndex2); - this.primaryPattern.resumeVariables(codeStream, scope); + if (this.patterns[0] != null) { + this.patterns[0].resumeVariables(codeStream, scope); + } } @Override protected boolean isPatternTypeCompatible(TypeBinding other, BlockScope scope) { - return this.primaryPattern.isPatternTypeCompatible(other, scope); + return this.patterns[0].isPatternTypeCompatible(other, scope); } @Override public void wrapupGeneration(CodeStream codeStream) { - this.primaryPattern.wrapupGeneration(codeStream); + this.patterns[0].wrapupGeneration(codeStream); + } + @Override + public void fullWrapupGeneration(CodeStream codeStream) { + this.patterns[0].fullWrapupGeneration(codeStream); } @Override protected void generatePatternVariable(BlockScope currentScope, CodeStream codeStream, BranchLabel trueLabel, BranchLabel falseLabel) { - this.primaryPattern.generatePatternVariable(currentScope, codeStream, trueLabel, falseLabel); + this.patterns[0].generatePatternVariable(currentScope, codeStream, trueLabel, falseLabel); } } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java index 305ffd14e1c..42e9c47f116 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java @@ -117,7 +117,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean int pc = codeStream.position; - if (this.elementVariable != null) { + if (this.elementVariable != null || this.pattern != null) { addAssignment(currentScope, codeStream, this.secretInstanceOfPatternExpressionValue); codeStream.load(this.secretInstanceOfPatternExpressionValue); } else { @@ -125,7 +125,22 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean } codeStream.instance_of(this.type, this.type.resolvedType); - if (this.elementVariable != null) { + if (this.pattern != null) { + BranchLabel trueLabel = new BranchLabel(codeStream); + BranchLabel falseLabel = new BranchLabel(codeStream); + BranchLabel continueLabel = new BranchLabel(codeStream); + codeStream.ifeq(falseLabel); + codeStream.load(this.secretInstanceOfPatternExpressionValue); + this.pattern.generateOptimizedBoolean(currentScope, codeStream, trueLabel, falseLabel); + this.pattern.fullWrapupGeneration(codeStream); + codeStream.removeVariable(this.secretInstanceOfPatternExpressionValue); + trueLabel.place(); + codeStream.iconst_1(); + codeStream.goto_(continueLabel); + falseLabel.place(); + codeStream.iconst_0(); + continueLabel.place(); + } else if (this.elementVariable != null) { BranchLabel actionLabel = new BranchLabel(codeStream); codeStream.dup(); codeStream.ifeq(actionLabel); diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java index 77fc1ebc3cf..f7def6bbcac 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java @@ -103,6 +103,11 @@ public void resumeVariables(CodeStream codeStream, BlockScope scope) { protected abstract void generatePatternVariable(BlockScope currentScope, CodeStream codeStream, BranchLabel trueLabel, BranchLabel falseLabel); protected abstract void wrapupGeneration(CodeStream codeStream); + /** + * Clean up all variables (actual and secret) used in this pattern and child patterns. + */ + protected abstract void fullWrapupGeneration(CodeStream codeStream); + public TypeReference getType() { return null; } @@ -111,8 +116,36 @@ public TypeReference getType() { public abstract boolean dominates(Pattern p); + public int countNamedVariables(BlockScope scope) { + var pvc = new PatternVariableCounter(); + this.traverse(pvc, scope); + return pvc.numVars; + } + @Override public StringBuilder print(int indent, StringBuilder output) { return this.printExpression(indent, output); } + + private class PatternVariableCounter extends ASTVisitor { + + public int numVars = 0; + + @Override + public boolean visit(TypePattern pattern, BlockScope scope) { + if (pattern.local != null && (pattern.local.name.length != 1 || pattern.local.name[0] != '_')) { + this.numVars++; + } + return true; + } + + @Override + public boolean visit(RecordPattern pattern, BlockScope scope) { + if (pattern.local != null && (pattern.local.name.length != 1 || pattern.local.name[0] != '_')) { + this.numVars++; + } + return true; + } + + } } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java index 34a4687d7d8..8e3d2b86dcb 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java @@ -214,6 +214,12 @@ public boolean dominates(Pattern p) { return false; } } + } else if (p instanceof GuardedPattern gp) { + for (Pattern gpChild : gp.patterns) { + if (!this.dominates(gpChild)) { + return false; + } + } } return true; } @@ -354,6 +360,13 @@ public void wrapupGeneration(CodeStream codeStream) { super.wrapupGeneration(codeStream); } @Override + public void fullWrapupGeneration(CodeStream codeStream) { + for (Pattern p : this.patterns) { + p.fullWrapupGeneration(codeStream); + } + super.fullWrapupGeneration(codeStream); + } + @Override public void suspendVariables(CodeStream codeStream, BlockScope scope) { codeStream.removeNotDefinitelyAssignedVariables(scope, this.thenInitStateIndex1); } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java index f62efa17002..4433f70b377 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java @@ -983,15 +983,13 @@ private void generateCodePatternCaseEpilogue(CodeStream codeStream, int caseInde if (this.switchPatternRestartTarget != null && caseStatement != null && caseStatement.patternIndex != -1 // for null ) { - Pattern pattern = (Pattern) caseStatement.constantExpressions[caseStatement.patternIndex]; - pattern.elseTarget.place(); + Pattern pattern = (Pattern) caseStatement.constantExpressions[caseStatement.constantExpressions.length - 1]; pattern.suspendVariables(codeStream, this.scope); + pattern.elseTarget.place(); caseIndex = this.nullProcessed ? caseIndex - 1 : caseIndex; - if (!pattern.isAlwaysTrue()) { - codeStream.loadInt(caseIndex); - codeStream.store(this.restartIndexLocal, false); - codeStream.goto_(this.switchPatternRestartTarget); - } + codeStream.loadInt(caseIndex); + codeStream.store(this.restartIndexLocal, false); + codeStream.goto_(this.switchPatternRestartTarget); pattern.thenTarget.place(); pattern.resumeVariables(codeStream, this.scope); } else if (this.containsNull && caseStatement != null) { diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java index dc5bd0f36d3..189340ba6df 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java @@ -109,6 +109,13 @@ public void wrapupGeneration(CodeStream codeStream) { codeStream.removeVariable(this.secretPatternVariable); } @Override + public void fullWrapupGeneration(CodeStream codeStream) { + this.wrapupGeneration(codeStream); + if (this.local != null) { + codeStream.removeVariable(this.local.binding); + } + } + @Override public LocalDeclaration getPatternVariable() { return this.local; } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java index 98013026c74..bbc1b308901 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java @@ -7476,1018 +7476,1015 @@ protected void consumeRule(int act) { case 479 : if (DEBUG) { System.out.println("SwitchLabelCaseLhs ::= case CaseLabelElements"); } //$NON-NLS-1$ consumeSwitchLabelCaseLhs(); break; - case 481 : if (DEBUG) { System.out.println("CaseLabelElements ::= CaseLabelElements COMMA..."); } //$NON-NLS-1$ + case 483 : if (DEBUG) { System.out.println("CaseLabelConstantElements ::= CaseLabelConstantElements"); } //$NON-NLS-1$ consumeCaseLabelElements(); break; - case 482 : if (DEBUG) { System.out.println("CaseLabelElement ::= ConstantExpression"); } //$NON-NLS-1$ + case 484 : if (DEBUG) { System.out.println("CaseLabelConstantElement ::= ConstantExpression"); } //$NON-NLS-1$ consumeCaseLabelElement(CaseLabelKind.CASE_EXPRESSION); break; - case 483 : if (DEBUG) { System.out.println("CaseLabelElement ::= default"); } //$NON-NLS-1$ + case 485 : if (DEBUG) { System.out.println("CaseLabelConstantElement ::= default"); } //$NON-NLS-1$ consumeCaseLabelElement(CaseLabelKind.CASE_DEFAULT); break; - case 484 : if (DEBUG) { System.out.println("CaseLabelElement ::= CaseLabelElementPattern"); } //$NON-NLS-1$ - consumeCaseLabelElement(CaseLabelKind.CASE_PATTERN); break; + case 490 : if (DEBUG) { System.out.println("CasePatternList ::= CasePatternList COMMA CasePattern"); } //$NON-NLS-1$ + consumeCaseLabelElements(); break; - case 485 : if (DEBUG) { System.out.println("CaseLabelElement ::= CaseLabelElementPattern Guard"); } //$NON-NLS-1$ + case 491 : if (DEBUG) { System.out.println("CasePattern ::= Pattern"); } //$NON-NLS-1$ consumeCaseLabelElement(CaseLabelKind.CASE_PATTERN); break; - case 486 : if (DEBUG) { System.out.println("CaseLabelElementPattern ::= BeginCaseElement Pattern"); } //$NON-NLS-1$ - consumeCaseLabelElementPattern(); break; - - case 487 : if (DEBUG) { System.out.println("Guard ::= RestrictedIdentifierWhen Expression"); } //$NON-NLS-1$ + case 492 : if (DEBUG) { System.out.println("Guard ::= RestrictedIdentifierWhen Expression"); } //$NON-NLS-1$ consumeGuard(); break; - case 488 : if (DEBUG) { System.out.println("YieldStatement ::= RestrictedIdentifierYield Expression"); } //$NON-NLS-1$ + case 493 : if (DEBUG) { System.out.println("YieldStatement ::= RestrictedIdentifierYield Expression"); } //$NON-NLS-1$ consumeStatementYield() ; break; - case 489 : if (DEBUG) { System.out.println("WhileStatement ::= while LPAREN Expression RPAREN..."); } //$NON-NLS-1$ + case 494 : if (DEBUG) { System.out.println("WhileStatement ::= while LPAREN Expression RPAREN..."); } //$NON-NLS-1$ consumeStatementWhile() ; break; - case 490 : if (DEBUG) { System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression..."); } //$NON-NLS-1$ + case 495 : if (DEBUG) { System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression..."); } //$NON-NLS-1$ consumeStatementWhile() ; break; - case 491 : if (DEBUG) { System.out.println("DoStatement ::= do Statement while LPAREN Expression..."); } //$NON-NLS-1$ + case 496 : if (DEBUG) { System.out.println("DoStatement ::= do Statement while LPAREN Expression..."); } //$NON-NLS-1$ consumeStatementDo() ; break; - case 492 : if (DEBUG) { System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON..."); } //$NON-NLS-1$ + case 497 : if (DEBUG) { System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON..."); } //$NON-NLS-1$ consumeStatementFor() ; break; - case 493 : if (DEBUG) { System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt..."); } //$NON-NLS-1$ + case 498 : if (DEBUG) { System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt..."); } //$NON-NLS-1$ consumeStatementFor() ; break; - case 494 : if (DEBUG) { System.out.println("ForInit ::= StatementExpressionList"); } //$NON-NLS-1$ + case 499 : if (DEBUG) { System.out.println("ForInit ::= StatementExpressionList"); } //$NON-NLS-1$ consumeForInit() ; break; - case 498 : if (DEBUG) { System.out.println("StatementExpressionList ::= StatementExpressionList..."); } //$NON-NLS-1$ + case 503 : if (DEBUG) { System.out.println("StatementExpressionList ::= StatementExpressionList..."); } //$NON-NLS-1$ consumeStatementExpressionList() ; break; - case 499 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression SEMICOLON"); } //$NON-NLS-1$ + case 504 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression SEMICOLON"); } //$NON-NLS-1$ consumeSimpleAssertStatement() ; break; - case 500 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression COLON Expression"); } //$NON-NLS-1$ + case 505 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression COLON Expression"); } //$NON-NLS-1$ consumeAssertStatement() ; break; - case 501 : if (DEBUG) { System.out.println("BreakStatement ::= break SEMICOLON"); } //$NON-NLS-1$ + case 506 : if (DEBUG) { System.out.println("BreakStatement ::= break SEMICOLON"); } //$NON-NLS-1$ consumeStatementBreak() ; break; - case 502 : if (DEBUG) { System.out.println("BreakStatement ::= break Identifier SEMICOLON"); } //$NON-NLS-1$ + case 507 : if (DEBUG) { System.out.println("BreakStatement ::= break Identifier SEMICOLON"); } //$NON-NLS-1$ consumeStatementBreakWithLabel() ; break; - case 503 : if (DEBUG) { System.out.println("ContinueStatement ::= continue SEMICOLON"); } //$NON-NLS-1$ + case 508 : if (DEBUG) { System.out.println("ContinueStatement ::= continue SEMICOLON"); } //$NON-NLS-1$ consumeStatementContinue() ; break; - case 504 : if (DEBUG) { System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); } //$NON-NLS-1$ + case 509 : if (DEBUG) { System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); } //$NON-NLS-1$ consumeStatementContinueWithLabel() ; break; - case 505 : if (DEBUG) { System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); } //$NON-NLS-1$ + case 510 : if (DEBUG) { System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); } //$NON-NLS-1$ consumeStatementReturn() ; break; - case 506 : if (DEBUG) { System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); } //$NON-NLS-1$ + case 511 : if (DEBUG) { System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); } //$NON-NLS-1$ consumeStatementThrow(); break; - case 507 : if (DEBUG) { System.out.println("ThrowExpression ::= throw Expression"); } //$NON-NLS-1$ + case 512 : if (DEBUG) { System.out.println("ThrowExpression ::= throw Expression"); } //$NON-NLS-1$ consumeThrowExpression() ; break; - case 508 : if (DEBUG) { System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN..."); } //$NON-NLS-1$ + case 513 : if (DEBUG) { System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN..."); } //$NON-NLS-1$ consumeStatementSynchronized(); break; - case 509 : if (DEBUG) { System.out.println("OnlySynchronized ::= synchronized"); } //$NON-NLS-1$ + case 514 : if (DEBUG) { System.out.println("OnlySynchronized ::= synchronized"); } //$NON-NLS-1$ consumeOnlySynchronized(); break; - case 510 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); } //$NON-NLS-1$ + case 515 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); } //$NON-NLS-1$ consumeStatementTry(false, false); break; - case 511 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); } //$NON-NLS-1$ + case 516 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); } //$NON-NLS-1$ consumeStatementTry(true, false); break; - case 512 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$ + case 517 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$ consumeStatementTry(false, true); break; - case 513 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$ + case 518 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); } //$NON-NLS-1$ consumeStatementTry(true, true); break; - case 514 : if (DEBUG) { System.out.println("ResourceSpecification ::= LPAREN Resources ;opt RPAREN"); } //$NON-NLS-1$ + case 519 : if (DEBUG) { System.out.println("ResourceSpecification ::= LPAREN Resources ;opt RPAREN"); } //$NON-NLS-1$ consumeResourceSpecification(); break; - case 515 : if (DEBUG) { System.out.println(";opt ::="); } //$NON-NLS-1$ + case 520 : if (DEBUG) { System.out.println(";opt ::="); } //$NON-NLS-1$ consumeResourceOptionalTrailingSemiColon(false); break; - case 516 : if (DEBUG) { System.out.println(";opt ::= SEMICOLON"); } //$NON-NLS-1$ + case 521 : if (DEBUG) { System.out.println(";opt ::= SEMICOLON"); } //$NON-NLS-1$ consumeResourceOptionalTrailingSemiColon(true); break; - case 517 : if (DEBUG) { System.out.println("Resources ::= Resource"); } //$NON-NLS-1$ + case 522 : if (DEBUG) { System.out.println("Resources ::= Resource"); } //$NON-NLS-1$ consumeSingleResource(); break; - case 518 : if (DEBUG) { System.out.println("Resources ::= Resources TrailingSemiColon Resource"); } //$NON-NLS-1$ + case 523 : if (DEBUG) { System.out.println("Resources ::= Resources TrailingSemiColon Resource"); } //$NON-NLS-1$ consumeMultipleResources(); break; - case 519 : if (DEBUG) { System.out.println("TrailingSemiColon ::= SEMICOLON"); } //$NON-NLS-1$ + case 524 : if (DEBUG) { System.out.println("TrailingSemiColon ::= SEMICOLON"); } //$NON-NLS-1$ consumeResourceOptionalTrailingSemiColon(true); break; - case 520 : if (DEBUG) { System.out.println("Resource ::= Type PushModifiers VariableDeclaratorId..."); } //$NON-NLS-1$ + case 525 : if (DEBUG) { System.out.println("Resource ::= Type PushModifiers VariableDeclaratorId..."); } //$NON-NLS-1$ consumeResourceAsLocalVariableDeclaration(); break; - case 521 : if (DEBUG) { System.out.println("Resource ::= Modifiers Type PushRealModifiers..."); } //$NON-NLS-1$ + case 526 : if (DEBUG) { System.out.println("Resource ::= Modifiers Type PushRealModifiers..."); } //$NON-NLS-1$ consumeResourceAsLocalVariableDeclaration(); break; - case 522 : if (DEBUG) { System.out.println("Resource ::= Name"); } //$NON-NLS-1$ + case 527 : if (DEBUG) { System.out.println("Resource ::= Name"); } //$NON-NLS-1$ consumeResourceAsLocalVariable(); break; - case 523 : if (DEBUG) { System.out.println("Resource ::= this"); } //$NON-NLS-1$ + case 528 : if (DEBUG) { System.out.println("Resource ::= this"); } //$NON-NLS-1$ consumeResourceAsThis(); break; - case 524 : if (DEBUG) { System.out.println("Resource ::= FieldAccess"); } //$NON-NLS-1$ + case 529 : if (DEBUG) { System.out.println("Resource ::= FieldAccess"); } //$NON-NLS-1$ consumeResourceAsFieldAccess(); break; - case 526 : if (DEBUG) { System.out.println("ExitTryBlock ::="); } //$NON-NLS-1$ + case 531 : if (DEBUG) { System.out.println("ExitTryBlock ::="); } //$NON-NLS-1$ consumeExitTryBlock(); break; - case 528 : if (DEBUG) { System.out.println("Catches ::= Catches CatchClause"); } //$NON-NLS-1$ + case 533 : if (DEBUG) { System.out.println("Catches ::= Catches CatchClause"); } //$NON-NLS-1$ consumeCatches(); break; - case 529 : if (DEBUG) { System.out.println("CatchClause ::= catch LPAREN CatchFormalParameter RPAREN"); } //$NON-NLS-1$ + case 534 : if (DEBUG) { System.out.println("CatchClause ::= catch LPAREN CatchFormalParameter RPAREN"); } //$NON-NLS-1$ consumeStatementCatch() ; break; - case 531 : if (DEBUG) { System.out.println("PushLPAREN ::= LPAREN"); } //$NON-NLS-1$ + case 536 : if (DEBUG) { System.out.println("PushLPAREN ::= LPAREN"); } //$NON-NLS-1$ consumeLeftParen(); break; - case 532 : if (DEBUG) { System.out.println("PushRPAREN ::= RPAREN"); } //$NON-NLS-1$ + case 537 : if (DEBUG) { System.out.println("PushRPAREN ::= RPAREN"); } //$NON-NLS-1$ consumeRightParen(); break; - case 537 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= this"); } //$NON-NLS-1$ + case 542 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= this"); } //$NON-NLS-1$ consumePrimaryNoNewArrayThis(); break; - case 538 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression_NotName..."); } //$NON-NLS-1$ + case 543 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression_NotName..."); } //$NON-NLS-1$ consumePrimaryNoNewArray(); break; - case 539 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Name PushRPAREN"); } //$NON-NLS-1$ + case 544 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Name PushRPAREN"); } //$NON-NLS-1$ consumePrimaryNoNewArrayWithName(); break; - case 542 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT this"); } //$NON-NLS-1$ + case 547 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT this"); } //$NON-NLS-1$ consumePrimaryNoNewArrayNameThis(); break; - case 543 : if (DEBUG) { System.out.println("QualifiedSuperReceiver ::= Name DOT super"); } //$NON-NLS-1$ + case 548 : if (DEBUG) { System.out.println("QualifiedSuperReceiver ::= Name DOT super"); } //$NON-NLS-1$ consumeQualifiedSuperReceiver(); break; - case 544 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT class"); } //$NON-NLS-1$ + case 549 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT class"); } //$NON-NLS-1$ consumePrimaryNoNewArrayName(); break; - case 545 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name Dims DOT class"); } //$NON-NLS-1$ + case 550 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name Dims DOT class"); } //$NON-NLS-1$ consumePrimaryNoNewArrayArrayType(); break; - case 546 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType Dims DOT class"); } //$NON-NLS-1$ + case 551 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType Dims DOT class"); } //$NON-NLS-1$ consumePrimaryNoNewArrayPrimitiveArrayType(); break; - case 547 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); } //$NON-NLS-1$ + case 552 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); } //$NON-NLS-1$ consumePrimaryNoNewArrayPrimitiveType(); break; - case 553 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$ + case 558 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$ consumeReferenceExpressionTypeArgumentsAndTrunk(false); break; - case 554 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$ + case 559 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); } //$NON-NLS-1$ consumeReferenceExpressionTypeArgumentsAndTrunk(true); break; - case 555 : if (DEBUG) { System.out.println("ReferenceExpression ::= PrimitiveType Dims COLON_COLON"); } //$NON-NLS-1$ + case 560 : if (DEBUG) { System.out.println("ReferenceExpression ::= PrimitiveType Dims COLON_COLON"); } //$NON-NLS-1$ consumeReferenceExpressionTypeForm(true); break; - case 556 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name Dimsopt COLON_COLON..."); } //$NON-NLS-1$ + case 561 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name Dimsopt COLON_COLON..."); } //$NON-NLS-1$ consumeReferenceExpressionTypeForm(false); break; - case 557 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name BeginTypeArguments..."); } //$NON-NLS-1$ + case 562 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name BeginTypeArguments..."); } //$NON-NLS-1$ consumeReferenceExpressionGenericTypeForm(); break; - case 558 : if (DEBUG) { System.out.println("ReferenceExpression ::= Primary COLON_COLON..."); } //$NON-NLS-1$ + case 563 : if (DEBUG) { System.out.println("ReferenceExpression ::= Primary COLON_COLON..."); } //$NON-NLS-1$ consumeReferenceExpressionPrimaryForm(); break; - case 559 : if (DEBUG) { System.out.println("ReferenceExpression ::= QualifiedSuperReceiver..."); } //$NON-NLS-1$ + case 564 : if (DEBUG) { System.out.println("ReferenceExpression ::= QualifiedSuperReceiver..."); } //$NON-NLS-1$ consumeReferenceExpressionPrimaryForm(); break; - case 560 : if (DEBUG) { System.out.println("ReferenceExpression ::= super COLON_COLON..."); } //$NON-NLS-1$ + case 565 : if (DEBUG) { System.out.println("ReferenceExpression ::= super COLON_COLON..."); } //$NON-NLS-1$ consumeReferenceExpressionSuperForm(); break; - case 561 : if (DEBUG) { System.out.println("NonWildTypeArgumentsopt ::="); } //$NON-NLS-1$ + case 566 : if (DEBUG) { System.out.println("NonWildTypeArgumentsopt ::="); } //$NON-NLS-1$ consumeEmptyTypeArguments(); break; - case 563 : if (DEBUG) { System.out.println("IdentifierOrNew ::= Identifier"); } //$NON-NLS-1$ + case 568 : if (DEBUG) { System.out.println("IdentifierOrNew ::= Identifier"); } //$NON-NLS-1$ consumeIdentifierOrNew(false); break; - case 564 : if (DEBUG) { System.out.println("IdentifierOrNew ::= new"); } //$NON-NLS-1$ + case 569 : if (DEBUG) { System.out.println("IdentifierOrNew ::= new"); } //$NON-NLS-1$ consumeIdentifierOrNew(true); break; - case 565 : if (DEBUG) { System.out.println("LambdaExpression ::= LambdaParameters ARROW LambdaBody"); } //$NON-NLS-1$ + case 570 : if (DEBUG) { System.out.println("LambdaExpression ::= LambdaParameters ARROW LambdaBody"); } //$NON-NLS-1$ consumeLambdaExpression(); break; - case 566 : if (DEBUG) { System.out.println("NestedLambda ::="); } //$NON-NLS-1$ + case 571 : if (DEBUG) { System.out.println("NestedLambda ::="); } //$NON-NLS-1$ consumeNestedLambda(); break; - case 567 : if (DEBUG) { System.out.println("LambdaParameters ::= UNDERSCORE NestedLambda"); } //$NON-NLS-1$ + case 572 : if (DEBUG) { System.out.println("LambdaParameters ::= UNDERSCORE NestedLambda"); } //$NON-NLS-1$ consumeTypeElidedLambdaParameter(false); break; - case 568 : if (DEBUG) { System.out.println("LambdaParameters ::= Identifier NestedLambda"); } //$NON-NLS-1$ + case 573 : if (DEBUG) { System.out.println("LambdaParameters ::= Identifier NestedLambda"); } //$NON-NLS-1$ consumeTypeElidedLambdaParameter(false); break; - case 574 : if (DEBUG) { System.out.println("TypeElidedFormalParameterList ::=..."); } //$NON-NLS-1$ + case 579 : if (DEBUG) { System.out.println("TypeElidedFormalParameterList ::=..."); } //$NON-NLS-1$ consumeFormalParameterList(); break; - case 575 : if (DEBUG) { System.out.println("TypeElidedFormalParameter ::= Modifiersopt Identifier"); } //$NON-NLS-1$ + case 580 : if (DEBUG) { System.out.println("TypeElidedFormalParameter ::= Modifiersopt Identifier"); } //$NON-NLS-1$ consumeTypeElidedLambdaParameter(true); break; - case 576 : if (DEBUG) { System.out.println("TypeElidedFormalParameter ::= UNDERSCORE"); } //$NON-NLS-1$ + case 581 : if (DEBUG) { System.out.println("TypeElidedFormalParameter ::= UNDERSCORE"); } //$NON-NLS-1$ consumeBracketedTypeElidedUnderscoreLambdaParameter(); break; - case 579 : if (DEBUG) { System.out.println("ElidedLeftBraceAndReturn ::="); } //$NON-NLS-1$ + case 584 : if (DEBUG) { System.out.println("ElidedLeftBraceAndReturn ::="); } //$NON-NLS-1$ consumeElidedLeftBraceAndReturn(); break; - case 580 : if (DEBUG) { System.out.println("AllocationHeader ::= new ClassType LPAREN..."); } //$NON-NLS-1$ + case 585 : if (DEBUG) { System.out.println("AllocationHeader ::= new ClassType LPAREN..."); } //$NON-NLS-1$ consumeAllocationHeader(); break; - case 581 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new..."); } //$NON-NLS-1$ + case 586 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new..."); } //$NON-NLS-1$ consumeClassInstanceCreationExpressionWithTypeArguments(); break; - case 582 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new ClassType..."); } //$NON-NLS-1$ + case 587 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new ClassType..."); } //$NON-NLS-1$ consumeClassInstanceCreationExpression(); break; - case 583 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$ + case 588 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$ consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ; break; - case 584 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$ + case 589 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$ consumeClassInstanceCreationExpressionQualified() ; break; - case 585 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$ + case 590 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$ consumeClassInstanceCreationExpressionQualified() ; break; - case 586 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$ + case 591 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$ consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ; break; - case 587 : if (DEBUG) { System.out.println("EnterInstanceCreationArgumentList ::="); } //$NON-NLS-1$ + case 592 : if (DEBUG) { System.out.println("EnterInstanceCreationArgumentList ::="); } //$NON-NLS-1$ consumeEnterInstanceCreationArgumentList(); break; - case 588 : if (DEBUG) { System.out.println("ClassInstanceCreationExpressionName ::= Name DOT new"); } //$NON-NLS-1$ + case 593 : if (DEBUG) { System.out.println("ClassInstanceCreationExpressionName ::= Name DOT new"); } //$NON-NLS-1$ consumeClassInstanceCreationExpressionName() ; break; - case 589 : if (DEBUG) { System.out.println("UnqualifiedClassBodyopt ::="); } //$NON-NLS-1$ + case 594 : if (DEBUG) { System.out.println("UnqualifiedClassBodyopt ::="); } //$NON-NLS-1$ consumeClassBodyopt(); break; - case 591 : if (DEBUG) { System.out.println("UnqualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$ + case 596 : if (DEBUG) { System.out.println("UnqualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$ consumeEnterAnonymousClassBody(false); break; - case 592 : if (DEBUG) { System.out.println("QualifiedClassBodyopt ::="); } //$NON-NLS-1$ + case 597 : if (DEBUG) { System.out.println("QualifiedClassBodyopt ::="); } //$NON-NLS-1$ consumeClassBodyopt(); break; - case 594 : if (DEBUG) { System.out.println("QualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$ + case 599 : if (DEBUG) { System.out.println("QualifiedEnterAnonymousClassBody ::="); } //$NON-NLS-1$ consumeEnterAnonymousClassBody(true); break; - case 596 : if (DEBUG) { System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); } //$NON-NLS-1$ + case 601 : if (DEBUG) { System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); } //$NON-NLS-1$ consumeArgumentList(); break; - case 597 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new PrimitiveType..."); } //$NON-NLS-1$ + case 602 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new PrimitiveType..."); } //$NON-NLS-1$ consumeArrayCreationHeader(); break; - case 598 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new ClassOrInterfaceType..."); } //$NON-NLS-1$ + case 603 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new ClassOrInterfaceType..."); } //$NON-NLS-1$ consumeArrayCreationHeader(); break; - case 599 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$ + case 604 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$ consumeArrayCreationExpressionWithoutInitializer(); break; - case 600 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType"); } //$NON-NLS-1$ + case 605 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType"); } //$NON-NLS-1$ consumeArrayCreationExpressionWithInitializer(); break; - case 601 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$ + case 606 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$ consumeArrayCreationExpressionWithoutInitializer(); break; - case 602 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new..."); } //$NON-NLS-1$ + case 607 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new..."); } //$NON-NLS-1$ consumeArrayCreationExpressionWithInitializer(); break; - case 604 : if (DEBUG) { System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs..."); } //$NON-NLS-1$ + case 609 : if (DEBUG) { System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs..."); } //$NON-NLS-1$ consumeDimWithOrWithOutExprs(); break; - case 606 : if (DEBUG) { System.out.println("DimWithOrWithOutExpr ::= TypeAnnotationsopt LBRACKET..."); } //$NON-NLS-1$ + case 611 : if (DEBUG) { System.out.println("DimWithOrWithOutExpr ::= TypeAnnotationsopt LBRACKET..."); } //$NON-NLS-1$ consumeDimWithOrWithOutExpr(); break; - case 607 : if (DEBUG) { System.out.println("Dims ::= DimsLoop"); } //$NON-NLS-1$ + case 612 : if (DEBUG) { System.out.println("Dims ::= DimsLoop"); } //$NON-NLS-1$ consumeDims(); break; - case 610 : if (DEBUG) { System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); } //$NON-NLS-1$ + case 615 : if (DEBUG) { System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); } //$NON-NLS-1$ consumeOneDimLoop(false); break; - case 611 : if (DEBUG) { System.out.println("OneDimLoop ::= TypeAnnotations LBRACKET RBRACKET"); } //$NON-NLS-1$ + case 616 : if (DEBUG) { System.out.println("OneDimLoop ::= TypeAnnotations LBRACKET RBRACKET"); } //$NON-NLS-1$ consumeOneDimLoop(true); break; - case 612 : if (DEBUG) { System.out.println("FieldAccess ::= Primary DOT Identifier"); } //$NON-NLS-1$ + case 617 : if (DEBUG) { System.out.println("FieldAccess ::= Primary DOT Identifier"); } //$NON-NLS-1$ consumeFieldAccess(false); break; - case 613 : if (DEBUG) { System.out.println("FieldAccess ::= super DOT Identifier"); } //$NON-NLS-1$ + case 618 : if (DEBUG) { System.out.println("FieldAccess ::= super DOT Identifier"); } //$NON-NLS-1$ consumeFieldAccess(true); break; - case 614 : if (DEBUG) { System.out.println("FieldAccess ::= QualifiedSuperReceiver DOT Identifier"); } //$NON-NLS-1$ + case 619 : if (DEBUG) { System.out.println("FieldAccess ::= QualifiedSuperReceiver DOT Identifier"); } //$NON-NLS-1$ consumeFieldAccess(false); break; - case 615 : if (DEBUG) { System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$ + case 620 : if (DEBUG) { System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$ consumeMethodInvocationName(); break; - case 616 : if (DEBUG) { System.out.println("MethodInvocation ::= Name DOT OnlyTypeArguments..."); } //$NON-NLS-1$ + case 621 : if (DEBUG) { System.out.println("MethodInvocation ::= Name DOT OnlyTypeArguments..."); } //$NON-NLS-1$ consumeMethodInvocationNameWithTypeArguments(); break; - case 617 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT OnlyTypeArguments..."); } //$NON-NLS-1$ + case 622 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT OnlyTypeArguments..."); } //$NON-NLS-1$ consumeMethodInvocationPrimaryWithTypeArguments(); break; - case 618 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN..."); } //$NON-NLS-1$ + case 623 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN..."); } //$NON-NLS-1$ consumeMethodInvocationPrimary(); break; - case 619 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$ + case 624 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$ consumeMethodInvocationPrimary(); break; - case 620 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$ + case 625 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); } //$NON-NLS-1$ consumeMethodInvocationPrimaryWithTypeArguments(); break; - case 621 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT OnlyTypeArguments..."); } //$NON-NLS-1$ + case 626 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT OnlyTypeArguments..."); } //$NON-NLS-1$ consumeMethodInvocationSuperWithTypeArguments(); break; - case 622 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT Identifier LPAREN..."); } //$NON-NLS-1$ + case 627 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT Identifier LPAREN..."); } //$NON-NLS-1$ consumeMethodInvocationSuper(); break; - case 623 : if (DEBUG) { System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); } //$NON-NLS-1$ + case 628 : if (DEBUG) { System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); } //$NON-NLS-1$ consumeArrayAccess(true); break; - case 624 : if (DEBUG) { System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression..."); } //$NON-NLS-1$ + case 629 : if (DEBUG) { System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression..."); } //$NON-NLS-1$ consumeArrayAccess(false); break; - case 625 : if (DEBUG) { System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer..."); } //$NON-NLS-1$ + case 630 : if (DEBUG) { System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer..."); } //$NON-NLS-1$ consumeArrayAccess(false); break; - case 627 : if (DEBUG) { System.out.println("PostfixExpression ::= Name"); } //$NON-NLS-1$ + case 632 : if (DEBUG) { System.out.println("PostfixExpression ::= Name"); } //$NON-NLS-1$ consumePostfixExpression(); break; - case 630 : if (DEBUG) { System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); } //$NON-NLS-1$ + case 635 : if (DEBUG) { System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.PLUS,true); break; - case 631 : if (DEBUG) { System.out.println("PostDecrementExpression ::= PostfixExpression..."); } //$NON-NLS-1$ + case 636 : if (DEBUG) { System.out.println("PostDecrementExpression ::= PostfixExpression..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.MINUS,true); break; - case 632 : if (DEBUG) { System.out.println("PushPosition ::="); } //$NON-NLS-1$ + case 637 : if (DEBUG) { System.out.println("PushPosition ::="); } //$NON-NLS-1$ consumePushPosition(); break; - case 635 : if (DEBUG) { System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); } //$NON-NLS-1$ + case 640 : if (DEBUG) { System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.PLUS); break; - case 636 : if (DEBUG) { System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); } //$NON-NLS-1$ + case 641 : if (DEBUG) { System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.MINUS); break; - case 638 : if (DEBUG) { System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition..."); } //$NON-NLS-1$ + case 643 : if (DEBUG) { System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.PLUS,false); break; - case 639 : if (DEBUG) { System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition..."); } //$NON-NLS-1$ + case 644 : if (DEBUG) { System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.MINUS,false); break; - case 641 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition..."); } //$NON-NLS-1$ + case 646 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.TWIDDLE); break; - case 642 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition..."); } //$NON-NLS-1$ + case 647 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.NOT); break; - case 644 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt..."); } //$NON-NLS-1$ + case 649 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt..."); } //$NON-NLS-1$ consumeCastExpressionWithPrimitiveType(); break; - case 645 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$ + case 650 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$ consumeCastExpressionWithGenericsArray(); break; - case 646 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$ + case 651 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$ consumeCastExpressionWithQualifiedGenericsArray(); break; - case 647 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name PushRPAREN..."); } //$NON-NLS-1$ + case 652 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name PushRPAREN..."); } //$NON-NLS-1$ consumeCastExpressionLL1(); break; - case 648 : if (DEBUG) { System.out.println("CastExpression ::= BeginIntersectionCast PushLPAREN..."); } //$NON-NLS-1$ + case 653 : if (DEBUG) { System.out.println("CastExpression ::= BeginIntersectionCast PushLPAREN..."); } //$NON-NLS-1$ consumeCastExpressionLL1WithBounds(); break; - case 649 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name Dims..."); } //$NON-NLS-1$ + case 654 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name Dims..."); } //$NON-NLS-1$ consumeCastExpressionWithNameArray(); break; - case 650 : if (DEBUG) { System.out.println("AdditionalBoundsListOpt ::="); } //$NON-NLS-1$ + case 655 : if (DEBUG) { System.out.println("AdditionalBoundsListOpt ::="); } //$NON-NLS-1$ consumeZeroAdditionalBounds(); break; - case 654 : if (DEBUG) { System.out.println("OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments"); } //$NON-NLS-1$ + case 659 : if (DEBUG) { System.out.println("OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments"); } //$NON-NLS-1$ consumeOnlyTypeArgumentsForCastExpression(); break; - case 655 : if (DEBUG) { System.out.println("InsideCastExpression ::="); } //$NON-NLS-1$ + case 660 : if (DEBUG) { System.out.println("InsideCastExpression ::="); } //$NON-NLS-1$ consumeInsideCastExpression(); break; - case 656 : if (DEBUG) { System.out.println("InsideCastExpressionLL1 ::="); } //$NON-NLS-1$ + case 661 : if (DEBUG) { System.out.println("InsideCastExpressionLL1 ::="); } //$NON-NLS-1$ consumeInsideCastExpressionLL1(); break; - case 657 : if (DEBUG) { System.out.println("InsideCastExpressionLL1WithBounds ::="); } //$NON-NLS-1$ + case 662 : if (DEBUG) { System.out.println("InsideCastExpressionLL1WithBounds ::="); } //$NON-NLS-1$ consumeInsideCastExpressionLL1WithBounds (); break; - case 658 : if (DEBUG) { System.out.println("InsideCastExpressionWithQualifiedGenerics ::="); } //$NON-NLS-1$ + case 663 : if (DEBUG) { System.out.println("InsideCastExpressionWithQualifiedGenerics ::="); } //$NON-NLS-1$ consumeInsideCastExpressionWithQualifiedGenerics(); break; - case 660 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$ + case 665 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.MULTIPLY); break; - case 661 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$ + case 666 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.DIVIDE); break; - case 662 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$ + case 667 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.REMAINDER); break; - case 664 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression PLUS..."); } //$NON-NLS-1$ + case 669 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression PLUS..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.PLUS); break; - case 665 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression MINUS..."); } //$NON-NLS-1$ + case 670 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression MINUS..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.MINUS); break; - case 667 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT..."); } //$NON-NLS-1$ + case 672 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.LEFT_SHIFT); break; - case 668 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT..."); } //$NON-NLS-1$ + case 673 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.RIGHT_SHIFT); break; - case 669 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$ + case 674 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT); break; - case 671 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS..."); } //$NON-NLS-1$ + case 676 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.LESS); break; - case 672 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression GREATER..."); } //$NON-NLS-1$ + case 677 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression GREATER..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.GREATER); break; - case 673 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL"); } //$NON-NLS-1$ + case 678 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL"); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.LESS_EQUAL); break; - case 674 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression..."); } //$NON-NLS-1$ + case 679 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.GREATER_EQUAL); break; - case 676 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL..."); } //$NON-NLS-1$ + case 681 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL..."); } //$NON-NLS-1$ consumeEqualityExpression(OperatorIds.EQUAL_EQUAL); break; - case 677 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL..."); } //$NON-NLS-1$ + case 682 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL..."); } //$NON-NLS-1$ consumeEqualityExpression(OperatorIds.NOT_EQUAL); break; - case 679 : if (DEBUG) { System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); } //$NON-NLS-1$ + case 684 : if (DEBUG) { System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.AND); break; - case 681 : if (DEBUG) { System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR..."); } //$NON-NLS-1$ + case 686 : if (DEBUG) { System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.XOR); break; - case 683 : if (DEBUG) { System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR..."); } //$NON-NLS-1$ + case 688 : if (DEBUG) { System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.OR); break; - case 685 : if (DEBUG) { System.out.println("ConditionalAndExpression ::= ConditionalAndExpression..."); } //$NON-NLS-1$ + case 690 : if (DEBUG) { System.out.println("ConditionalAndExpression ::= ConditionalAndExpression..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.AND_AND); break; - case 687 : if (DEBUG) { System.out.println("ConditionalOrExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$ + case 692 : if (DEBUG) { System.out.println("ConditionalOrExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.OR_OR); break; - case 689 : if (DEBUG) { System.out.println("ConditionalExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$ + case 694 : if (DEBUG) { System.out.println("ConditionalExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$ consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ; break; - case 692 : if (DEBUG) { System.out.println("Assignment ::= PostfixExpression AssignmentOperator..."); } //$NON-NLS-1$ + case 697 : if (DEBUG) { System.out.println("Assignment ::= PostfixExpression AssignmentOperator..."); } //$NON-NLS-1$ consumeAssignment(); break; - case 694 : if (DEBUG) { System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); } //$NON-NLS-1$ + case 699 : if (DEBUG) { System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); } //$NON-NLS-1$ ignoreExpressionAssignment(); break; - case 695 : if (DEBUG) { System.out.println("AssignmentOperator ::= EQUAL"); } //$NON-NLS-1$ + case 700 : if (DEBUG) { System.out.println("AssignmentOperator ::= EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(EQUAL); break; - case 696 : if (DEBUG) { System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); } //$NON-NLS-1$ + case 701 : if (DEBUG) { System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(MULTIPLY); break; - case 697 : if (DEBUG) { System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); } //$NON-NLS-1$ + case 702 : if (DEBUG) { System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(DIVIDE); break; - case 698 : if (DEBUG) { System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); } //$NON-NLS-1$ + case 703 : if (DEBUG) { System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(REMAINDER); break; - case 699 : if (DEBUG) { System.out.println("AssignmentOperator ::= PLUS_EQUAL"); } //$NON-NLS-1$ + case 704 : if (DEBUG) { System.out.println("AssignmentOperator ::= PLUS_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(PLUS); break; - case 700 : if (DEBUG) { System.out.println("AssignmentOperator ::= MINUS_EQUAL"); } //$NON-NLS-1$ + case 705 : if (DEBUG) { System.out.println("AssignmentOperator ::= MINUS_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(MINUS); break; - case 701 : if (DEBUG) { System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); } //$NON-NLS-1$ + case 706 : if (DEBUG) { System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(LEFT_SHIFT); break; - case 702 : if (DEBUG) { System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$ + case 707 : if (DEBUG) { System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(RIGHT_SHIFT); break; - case 703 : if (DEBUG) { System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$ + case 708 : if (DEBUG) { System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); break; - case 704 : if (DEBUG) { System.out.println("AssignmentOperator ::= AND_EQUAL"); } //$NON-NLS-1$ + case 709 : if (DEBUG) { System.out.println("AssignmentOperator ::= AND_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(AND); break; - case 705 : if (DEBUG) { System.out.println("AssignmentOperator ::= XOR_EQUAL"); } //$NON-NLS-1$ + case 710 : if (DEBUG) { System.out.println("AssignmentOperator ::= XOR_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(XOR); break; - case 706 : if (DEBUG) { System.out.println("AssignmentOperator ::= OR_EQUAL"); } //$NON-NLS-1$ + case 711 : if (DEBUG) { System.out.println("AssignmentOperator ::= OR_EQUAL"); } //$NON-NLS-1$ consumeAssignmentOperator(OR); break; - case 707 : if (DEBUG) { System.out.println("Expression ::= AssignmentExpression"); } //$NON-NLS-1$ + case 712 : if (DEBUG) { System.out.println("Expression ::= AssignmentExpression"); } //$NON-NLS-1$ consumeExpression(); break; - case 710 : if (DEBUG) { System.out.println("Expressionopt ::="); } //$NON-NLS-1$ + case 715 : if (DEBUG) { System.out.println("Expressionopt ::="); } //$NON-NLS-1$ consumeEmptyExpression(); break; - case 715 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::="); } //$NON-NLS-1$ + case 720 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::="); } //$NON-NLS-1$ consumeEmptyClassBodyDeclarationsopt(); break; - case 716 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$ + case 721 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$ consumeClassBodyDeclarationsopt(); break; - case 717 : if (DEBUG) { System.out.println("Modifiersopt ::="); } //$NON-NLS-1$ + case 722 : if (DEBUG) { System.out.println("Modifiersopt ::="); } //$NON-NLS-1$ consumeDefaultModifiers(); break; - case 718 : if (DEBUG) { System.out.println("Modifiersopt ::= Modifiers"); } //$NON-NLS-1$ + case 723 : if (DEBUG) { System.out.println("Modifiersopt ::= Modifiers"); } //$NON-NLS-1$ consumeModifiers(); break; - case 719 : if (DEBUG) { System.out.println("BlockStatementsopt ::="); } //$NON-NLS-1$ + case 724 : if (DEBUG) { System.out.println("BlockStatementsopt ::="); } //$NON-NLS-1$ consumeEmptyBlockStatementsopt(); break; - case 721 : if (DEBUG) { System.out.println("Dimsopt ::="); } //$NON-NLS-1$ + case 726 : if (DEBUG) { System.out.println("Dimsopt ::="); } //$NON-NLS-1$ consumeEmptyDimsopt(); break; - case 723 : if (DEBUG) { System.out.println("ArgumentListopt ::="); } //$NON-NLS-1$ + case 728 : if (DEBUG) { System.out.println("ArgumentListopt ::="); } //$NON-NLS-1$ consumeEmptyArgumentListopt(); break; - case 727 : if (DEBUG) { System.out.println("FormalParameterListopt ::="); } //$NON-NLS-1$ + case 732 : if (DEBUG) { System.out.println("FormalParameterListopt ::="); } //$NON-NLS-1$ consumeFormalParameterListopt(); break; - case 734 : if (DEBUG) { System.out.println("ClassHeaderPermittedSubclasses ::=..."); } //$NON-NLS-1$ + case 739 : if (DEBUG) { System.out.println("ClassHeaderPermittedSubclasses ::=..."); } //$NON-NLS-1$ consumeClassHeaderPermittedSubclasses(); break; - case 737 : if (DEBUG) { System.out.println("InterfaceHeaderPermittedSubClassesAndSubInterfaces ::="); } //$NON-NLS-1$ + case 742 : if (DEBUG) { System.out.println("InterfaceHeaderPermittedSubClassesAndSubInterfaces ::="); } //$NON-NLS-1$ consumeInterfaceHeaderPermittedSubClassesAndSubInterfaces(); break; - case 738 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::="); } //$NON-NLS-1$ + case 743 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::="); } //$NON-NLS-1$ consumeEmptyInterfaceMemberDeclarationsopt(); break; - case 739 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$ + case 744 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$ consumeInterfaceMemberDeclarationsopt(); break; - case 740 : if (DEBUG) { System.out.println("NestedType ::="); } //$NON-NLS-1$ + case 745 : if (DEBUG) { System.out.println("NestedType ::="); } //$NON-NLS-1$ consumeNestedType(); break; - case 741 : if (DEBUG) { System.out.println("ForInitopt ::="); } //$NON-NLS-1$ + case 746 : if (DEBUG) { System.out.println("ForInitopt ::="); } //$NON-NLS-1$ consumeEmptyForInitopt(); break; - case 743 : if (DEBUG) { System.out.println("ForUpdateopt ::="); } //$NON-NLS-1$ + case 748 : if (DEBUG) { System.out.println("ForUpdateopt ::="); } //$NON-NLS-1$ consumeEmptyForUpdateopt(); break; - case 747 : if (DEBUG) { System.out.println("Catchesopt ::="); } //$NON-NLS-1$ + case 752 : if (DEBUG) { System.out.println("Catchesopt ::="); } //$NON-NLS-1$ consumeEmptyCatchesopt(); break; - case 749 : if (DEBUG) { System.out.println("EnumDeclaration ::= EnumHeader EnumBody"); } //$NON-NLS-1$ + case 754 : if (DEBUG) { System.out.println("EnumDeclaration ::= EnumHeader EnumBody"); } //$NON-NLS-1$ consumeEnumDeclaration(); break; - case 750 : if (DEBUG) { System.out.println("EnumHeader ::= EnumHeaderName ClassHeaderImplementsopt"); } //$NON-NLS-1$ + case 755 : if (DEBUG) { System.out.println("EnumHeader ::= EnumHeaderName ClassHeaderImplementsopt"); } //$NON-NLS-1$ consumeEnumHeader(); break; - case 751 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier"); } //$NON-NLS-1$ + case 756 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier"); } //$NON-NLS-1$ consumeEnumHeaderName(); break; - case 752 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier..."); } //$NON-NLS-1$ + case 757 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier..."); } //$NON-NLS-1$ consumeEnumHeaderNameWithTypeParameters(); break; - case 753 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumBodyDeclarationsopt RBRACE"); } //$NON-NLS-1$ + case 758 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumBodyDeclarationsopt RBRACE"); } //$NON-NLS-1$ consumeEnumBodyNoConstants(); break; - case 754 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE COMMA EnumBodyDeclarationsopt..."); } //$NON-NLS-1$ + case 759 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE COMMA EnumBodyDeclarationsopt..."); } //$NON-NLS-1$ consumeEnumBodyNoConstants(); break; - case 755 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants COMMA..."); } //$NON-NLS-1$ + case 760 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants COMMA..."); } //$NON-NLS-1$ consumeEnumBodyWithConstants(); break; - case 756 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants..."); } //$NON-NLS-1$ + case 761 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants..."); } //$NON-NLS-1$ consumeEnumBodyWithConstants(); break; - case 758 : if (DEBUG) { System.out.println("EnumConstants ::= EnumConstants COMMA EnumConstant"); } //$NON-NLS-1$ + case 763 : if (DEBUG) { System.out.println("EnumConstants ::= EnumConstants COMMA EnumConstant"); } //$NON-NLS-1$ consumeEnumConstants(); break; - case 759 : if (DEBUG) { System.out.println("EnumConstantHeaderName ::= Modifiersopt Identifier"); } //$NON-NLS-1$ + case 764 : if (DEBUG) { System.out.println("EnumConstantHeaderName ::= Modifiersopt Identifier"); } //$NON-NLS-1$ consumeEnumConstantHeaderName(); break; - case 760 : if (DEBUG) { System.out.println("EnumConstantHeader ::= EnumConstantHeaderName..."); } //$NON-NLS-1$ + case 765 : if (DEBUG) { System.out.println("EnumConstantHeader ::= EnumConstantHeaderName..."); } //$NON-NLS-1$ consumeEnumConstantHeader(); break; - case 761 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader ForceNoDiet..."); } //$NON-NLS-1$ + case 766 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader ForceNoDiet..."); } //$NON-NLS-1$ consumeEnumConstantWithClassBody(); break; - case 762 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader"); } //$NON-NLS-1$ + case 767 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader"); } //$NON-NLS-1$ consumeEnumConstantNoClassBody(); break; - case 763 : if (DEBUG) { System.out.println("Arguments ::= LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$ + case 768 : if (DEBUG) { System.out.println("Arguments ::= LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$ consumeArguments(); break; - case 764 : if (DEBUG) { System.out.println("Argumentsopt ::="); } //$NON-NLS-1$ + case 769 : if (DEBUG) { System.out.println("Argumentsopt ::="); } //$NON-NLS-1$ consumeEmptyArguments(); break; - case 766 : if (DEBUG) { System.out.println("EnumDeclarations ::= SEMICOLON ClassBodyDeclarationsopt"); } //$NON-NLS-1$ + case 771 : if (DEBUG) { System.out.println("EnumDeclarations ::= SEMICOLON ClassBodyDeclarationsopt"); } //$NON-NLS-1$ consumeEnumDeclarations(); break; - case 767 : if (DEBUG) { System.out.println("EnumBodyDeclarationsopt ::="); } //$NON-NLS-1$ + case 772 : if (DEBUG) { System.out.println("EnumBodyDeclarationsopt ::="); } //$NON-NLS-1$ consumeEmptyEnumDeclarations(); break; - case 769 : if (DEBUG) { System.out.println("EnhancedForStatement ::= EnhancedForStatementHeader..."); } //$NON-NLS-1$ + case 774 : if (DEBUG) { System.out.println("EnhancedForStatement ::= EnhancedForStatementHeader..."); } //$NON-NLS-1$ consumeEnhancedForStatement(); break; - case 770 : if (DEBUG) { System.out.println("EnhancedForStatementNoShortIf ::=..."); } //$NON-NLS-1$ + case 775 : if (DEBUG) { System.out.println("EnhancedForStatementNoShortIf ::=..."); } //$NON-NLS-1$ consumeEnhancedForStatement(); break; - case 771 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Type..."); } //$NON-NLS-1$ + case 776 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Type..."); } //$NON-NLS-1$ consumeEnhancedForStatementHeaderInit(false); break; - case 772 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Modifiers"); } //$NON-NLS-1$ + case 777 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Modifiers"); } //$NON-NLS-1$ consumeEnhancedForStatementHeaderInit(true); break; - case 773 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::=..."); } //$NON-NLS-1$ + case 778 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::=..."); } //$NON-NLS-1$ consumeEnhancedForStatementHeader(); break; - case 774 : if (DEBUG) { System.out.println("SingleStaticImportDeclaration ::=..."); } //$NON-NLS-1$ + case 779 : if (DEBUG) { System.out.println("SingleStaticImportDeclaration ::=..."); } //$NON-NLS-1$ consumeImportDeclaration(); break; - case 775 : if (DEBUG) { System.out.println("SingleStaticImportDeclarationName ::= import static Name"); } //$NON-NLS-1$ + case 780 : if (DEBUG) { System.out.println("SingleStaticImportDeclarationName ::= import static Name"); } //$NON-NLS-1$ consumeSingleStaticImportDeclarationName(); break; - case 776 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$ + case 781 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$ consumeImportDeclaration(); break; - case 777 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclarationName ::= import static..."); } //$NON-NLS-1$ + case 782 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclarationName ::= import static..."); } //$NON-NLS-1$ consumeStaticImportOnDemandDeclarationName(); break; - case 778 : if (DEBUG) { System.out.println("TypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$ + case 783 : if (DEBUG) { System.out.println("TypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$ consumeTypeArguments(); break; - case 779 : if (DEBUG) { System.out.println("OnlyTypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$ + case 784 : if (DEBUG) { System.out.println("OnlyTypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$ consumeOnlyTypeArguments(); break; - case 781 : if (DEBUG) { System.out.println("TypeArgumentList1 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$ + case 786 : if (DEBUG) { System.out.println("TypeArgumentList1 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$ consumeTypeArgumentList1(); break; - case 783 : if (DEBUG) { System.out.println("TypeArgumentList ::= TypeArgumentList COMMA TypeArgument"); } //$NON-NLS-1$ + case 788 : if (DEBUG) { System.out.println("TypeArgumentList ::= TypeArgumentList COMMA TypeArgument"); } //$NON-NLS-1$ consumeTypeArgumentList(); break; - case 784 : if (DEBUG) { System.out.println("TypeArgument ::= ReferenceType"); } //$NON-NLS-1$ + case 789 : if (DEBUG) { System.out.println("TypeArgument ::= ReferenceType"); } //$NON-NLS-1$ consumeTypeArgument(); break; - case 788 : if (DEBUG) { System.out.println("ReferenceType1 ::= ReferenceType GREATER"); } //$NON-NLS-1$ + case 793 : if (DEBUG) { System.out.println("ReferenceType1 ::= ReferenceType GREATER"); } //$NON-NLS-1$ consumeReferenceType1(); break; - case 789 : if (DEBUG) { System.out.println("ReferenceType1 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$ + case 794 : if (DEBUG) { System.out.println("ReferenceType1 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$ consumeTypeArgumentReferenceType1(); break; - case 791 : if (DEBUG) { System.out.println("TypeArgumentList2 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$ + case 796 : if (DEBUG) { System.out.println("TypeArgumentList2 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$ consumeTypeArgumentList2(); break; - case 794 : if (DEBUG) { System.out.println("ReferenceType2 ::= ReferenceType RIGHT_SHIFT"); } //$NON-NLS-1$ + case 799 : if (DEBUG) { System.out.println("ReferenceType2 ::= ReferenceType RIGHT_SHIFT"); } //$NON-NLS-1$ consumeReferenceType2(); break; - case 795 : if (DEBUG) { System.out.println("ReferenceType2 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$ + case 800 : if (DEBUG) { System.out.println("ReferenceType2 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$ consumeTypeArgumentReferenceType2(); break; - case 797 : if (DEBUG) { System.out.println("TypeArgumentList3 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$ + case 802 : if (DEBUG) { System.out.println("TypeArgumentList3 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$ consumeTypeArgumentList3(); break; - case 800 : if (DEBUG) { System.out.println("ReferenceType3 ::= ReferenceType UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$ + case 805 : if (DEBUG) { System.out.println("ReferenceType3 ::= ReferenceType UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$ consumeReferenceType3(); break; - case 801 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION"); } //$NON-NLS-1$ + case 806 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION"); } //$NON-NLS-1$ consumeWildcard(); break; - case 802 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION WildcardBounds"); } //$NON-NLS-1$ + case 807 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION WildcardBounds"); } //$NON-NLS-1$ consumeWildcardWithBounds(); break; - case 803 : if (DEBUG) { System.out.println("WildcardBounds ::= extends ReferenceType"); } //$NON-NLS-1$ + case 808 : if (DEBUG) { System.out.println("WildcardBounds ::= extends ReferenceType"); } //$NON-NLS-1$ consumeWildcardBoundsExtends(); break; - case 804 : if (DEBUG) { System.out.println("WildcardBounds ::= super ReferenceType"); } //$NON-NLS-1$ + case 809 : if (DEBUG) { System.out.println("WildcardBounds ::= super ReferenceType"); } //$NON-NLS-1$ consumeWildcardBoundsSuper(); break; - case 805 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION GREATER"); } //$NON-NLS-1$ + case 810 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION GREATER"); } //$NON-NLS-1$ consumeWildcard1(); break; - case 806 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ + case 811 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ consumeWildcard1WithBounds(); break; - case 807 : if (DEBUG) { System.out.println("WildcardBounds1 ::= extends ReferenceType1"); } //$NON-NLS-1$ + case 812 : if (DEBUG) { System.out.println("WildcardBounds1 ::= extends ReferenceType1"); } //$NON-NLS-1$ consumeWildcardBounds1Extends(); break; - case 808 : if (DEBUG) { System.out.println("WildcardBounds1 ::= super ReferenceType1"); } //$NON-NLS-1$ + case 813 : if (DEBUG) { System.out.println("WildcardBounds1 ::= super ReferenceType1"); } //$NON-NLS-1$ consumeWildcardBounds1Super(); break; - case 809 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION RIGHT_SHIFT"); } //$NON-NLS-1$ + case 814 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION RIGHT_SHIFT"); } //$NON-NLS-1$ consumeWildcard2(); break; - case 810 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ + case 815 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ consumeWildcard2WithBounds(); break; - case 811 : if (DEBUG) { System.out.println("WildcardBounds2 ::= extends ReferenceType2"); } //$NON-NLS-1$ + case 816 : if (DEBUG) { System.out.println("WildcardBounds2 ::= extends ReferenceType2"); } //$NON-NLS-1$ consumeWildcardBounds2Extends(); break; - case 812 : if (DEBUG) { System.out.println("WildcardBounds2 ::= super ReferenceType2"); } //$NON-NLS-1$ + case 817 : if (DEBUG) { System.out.println("WildcardBounds2 ::= super ReferenceType2"); } //$NON-NLS-1$ consumeWildcardBounds2Super(); break; - case 813 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ + case 818 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ consumeWildcard3(); break; - case 814 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ + case 819 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); } //$NON-NLS-1$ consumeWildcard3WithBounds(); break; - case 815 : if (DEBUG) { System.out.println("WildcardBounds3 ::= extends ReferenceType3"); } //$NON-NLS-1$ + case 820 : if (DEBUG) { System.out.println("WildcardBounds3 ::= extends ReferenceType3"); } //$NON-NLS-1$ consumeWildcardBounds3Extends(); break; - case 816 : if (DEBUG) { System.out.println("WildcardBounds3 ::= super ReferenceType3"); } //$NON-NLS-1$ + case 821 : if (DEBUG) { System.out.println("WildcardBounds3 ::= super ReferenceType3"); } //$NON-NLS-1$ consumeWildcardBounds3Super(); break; - case 817 : if (DEBUG) { System.out.println("TypeParameterHeader ::= TypeAnnotationsopt Identifier"); } //$NON-NLS-1$ + case 822 : if (DEBUG) { System.out.println("TypeParameterHeader ::= TypeAnnotationsopt Identifier"); } //$NON-NLS-1$ consumeTypeParameterHeader(); break; - case 818 : if (DEBUG) { System.out.println("TypeParameters ::= LESS TypeParameterList1"); } //$NON-NLS-1$ + case 823 : if (DEBUG) { System.out.println("TypeParameters ::= LESS TypeParameterList1"); } //$NON-NLS-1$ consumeTypeParameters(); break; - case 820 : if (DEBUG) { System.out.println("TypeParameterList ::= TypeParameterList COMMA..."); } //$NON-NLS-1$ + case 825 : if (DEBUG) { System.out.println("TypeParameterList ::= TypeParameterList COMMA..."); } //$NON-NLS-1$ consumeTypeParameterList(); break; - case 822 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ + case 827 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ consumeTypeParameterWithExtends(); break; - case 823 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ + case 828 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ consumeTypeParameterWithExtendsAndBounds(); break; - case 825 : if (DEBUG) { System.out.println("AdditionalBoundList ::= AdditionalBoundList..."); } //$NON-NLS-1$ + case 830 : if (DEBUG) { System.out.println("AdditionalBoundList ::= AdditionalBoundList..."); } //$NON-NLS-1$ consumeAdditionalBoundList(); break; - case 826 : if (DEBUG) { System.out.println("AdditionalBound ::= AND ReferenceType"); } //$NON-NLS-1$ + case 831 : if (DEBUG) { System.out.println("AdditionalBound ::= AND ReferenceType"); } //$NON-NLS-1$ consumeAdditionalBound(); break; - case 828 : if (DEBUG) { System.out.println("TypeParameterList1 ::= TypeParameterList COMMA..."); } //$NON-NLS-1$ + case 833 : if (DEBUG) { System.out.println("TypeParameterList1 ::= TypeParameterList COMMA..."); } //$NON-NLS-1$ consumeTypeParameterList1(); break; - case 829 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader GREATER"); } //$NON-NLS-1$ + case 834 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader GREATER"); } //$NON-NLS-1$ consumeTypeParameter1(); break; - case 830 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ + case 835 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ consumeTypeParameter1WithExtends(); break; - case 831 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ + case 836 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$ consumeTypeParameter1WithExtendsAndBounds(); break; - case 833 : if (DEBUG) { System.out.println("AdditionalBoundList1 ::= AdditionalBoundList..."); } //$NON-NLS-1$ + case 838 : if (DEBUG) { System.out.println("AdditionalBoundList1 ::= AdditionalBoundList..."); } //$NON-NLS-1$ consumeAdditionalBoundList1(); break; - case 834 : if (DEBUG) { System.out.println("AdditionalBound1 ::= AND ReferenceType1"); } //$NON-NLS-1$ + case 839 : if (DEBUG) { System.out.println("AdditionalBound1 ::= AND ReferenceType1"); } //$NON-NLS-1$ consumeAdditionalBound1(); break; - case 840 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= PLUS PushPosition..."); } //$NON-NLS-1$ + case 845 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= PLUS PushPosition..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.PLUS); break; - case 841 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= MINUS PushPosition..."); } //$NON-NLS-1$ + case 846 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= MINUS PushPosition..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.MINUS); break; - case 844 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= TWIDDLE..."); } //$NON-NLS-1$ + case 849 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= TWIDDLE..."); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.TWIDDLE); break; - case 845 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= NOT PushPosition"); } //$NON-NLS-1$ + case 850 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= NOT PushPosition"); } //$NON-NLS-1$ consumeUnaryExpression(OperatorIds.NOT); break; - case 848 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$ + case 853 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.MULTIPLY); break; - case 849 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name MULTIPLY..."); } //$NON-NLS-1$ + case 854 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name MULTIPLY..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.MULTIPLY); break; - case 850 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$ + case 855 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.DIVIDE); break; - case 851 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name DIVIDE..."); } //$NON-NLS-1$ + case 856 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name DIVIDE..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.DIVIDE); break; - case 852 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$ + case 857 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.REMAINDER); break; - case 853 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name REMAINDER..."); } //$NON-NLS-1$ + case 858 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name REMAINDER..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.REMAINDER); break; - case 855 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$ + case 860 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.PLUS); break; - case 856 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name PLUS..."); } //$NON-NLS-1$ + case 861 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name PLUS..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.PLUS); break; - case 857 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$ + case 862 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.MINUS); break; - case 858 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name MINUS..."); } //$NON-NLS-1$ + case 863 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name MINUS..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.MINUS); break; - case 860 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$ + case 865 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.LEFT_SHIFT); break; - case 861 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name LEFT_SHIFT..."); } //$NON-NLS-1$ + case 866 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name LEFT_SHIFT..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.LEFT_SHIFT); break; - case 862 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$ + case 867 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.RIGHT_SHIFT); break; - case 863 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name RIGHT_SHIFT..."); } //$NON-NLS-1$ + case 868 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name RIGHT_SHIFT..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.RIGHT_SHIFT); break; - case 864 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$ + case 869 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT); break; - case 865 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name UNSIGNED_RIGHT_SHIFT..."); } //$NON-NLS-1$ + case 870 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name UNSIGNED_RIGHT_SHIFT..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.UNSIGNED_RIGHT_SHIFT); break; - case 867 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$ + case 872 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.LESS); break; - case 868 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS..."); } //$NON-NLS-1$ + case 873 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.LESS); break; - case 869 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$ + case 874 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.GREATER); break; - case 870 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER..."); } //$NON-NLS-1$ + case 875 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.GREATER); break; - case 871 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$ + case 876 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.LESS_EQUAL); break; - case 872 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS_EQUAL..."); } //$NON-NLS-1$ + case 877 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS_EQUAL..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.LESS_EQUAL); break; - case 873 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$ + case 878 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.GREATER_EQUAL); break; - case 874 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER_EQUAL..."); } //$NON-NLS-1$ + case 879 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER_EQUAL..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.GREATER_EQUAL); break; - case 876 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::= Name InstanceofRHS"); } //$NON-NLS-1$ + case 881 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::= Name InstanceofRHS"); } //$NON-NLS-1$ consumeInstanceOfExpressionWithName(); break; - case 877 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::=..."); } //$NON-NLS-1$ + case 882 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::=..."); } //$NON-NLS-1$ consumeInstanceOfExpression(); break; - case 879 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$ + case 884 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$ consumeEqualityExpression(OperatorIds.EQUAL_EQUAL); break; - case 880 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name EQUAL_EQUAL..."); } //$NON-NLS-1$ + case 885 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name EQUAL_EQUAL..."); } //$NON-NLS-1$ consumeEqualityExpressionWithName(OperatorIds.EQUAL_EQUAL); break; - case 881 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$ + case 886 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$ consumeEqualityExpression(OperatorIds.NOT_EQUAL); break; - case 882 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name NOT_EQUAL..."); } //$NON-NLS-1$ + case 887 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name NOT_EQUAL..."); } //$NON-NLS-1$ consumeEqualityExpressionWithName(OperatorIds.NOT_EQUAL); break; - case 884 : if (DEBUG) { System.out.println("AndExpression_NotName ::= AndExpression_NotName AND..."); } //$NON-NLS-1$ + case 889 : if (DEBUG) { System.out.println("AndExpression_NotName ::= AndExpression_NotName AND..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.AND); break; - case 885 : if (DEBUG) { System.out.println("AndExpression_NotName ::= Name AND EqualityExpression"); } //$NON-NLS-1$ + case 890 : if (DEBUG) { System.out.println("AndExpression_NotName ::= Name AND EqualityExpression"); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.AND); break; - case 887 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$ + case 892 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.XOR); break; - case 888 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::= Name XOR AndExpression"); } //$NON-NLS-1$ + case 893 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::= Name XOR AndExpression"); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.XOR); break; - case 890 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$ + case 895 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.OR); break; - case 891 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::= Name OR..."); } //$NON-NLS-1$ + case 896 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::= Name OR..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.OR); break; - case 893 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::=..."); } //$NON-NLS-1$ + case 898 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.AND_AND); break; - case 894 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::= Name AND_AND..."); } //$NON-NLS-1$ + case 899 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::= Name AND_AND..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.AND_AND); break; - case 896 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::=..."); } //$NON-NLS-1$ + case 901 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::=..."); } //$NON-NLS-1$ consumeBinaryExpression(OperatorIds.OR_OR); break; - case 897 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::= Name OR_OR..."); } //$NON-NLS-1$ + case 902 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::= Name OR_OR..."); } //$NON-NLS-1$ consumeBinaryExpressionWithName(OperatorIds.OR_OR); break; - case 899 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::=..."); } //$NON-NLS-1$ + case 904 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::=..."); } //$NON-NLS-1$ consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ; break; - case 900 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::= Name QUESTION..."); } //$NON-NLS-1$ + case 905 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::= Name QUESTION..."); } //$NON-NLS-1$ consumeConditionalExpressionWithName(OperatorIds.QUESTIONCOLON) ; break; - case 904 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$ + case 909 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$ consumeAnnotationTypeDeclarationHeaderName() ; break; - case 905 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$ + case 910 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$ consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters() ; break; - case 906 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$ + case 911 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$ consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters() ; break; - case 907 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$ + case 912 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$ consumeAnnotationTypeDeclarationHeaderName() ; break; - case 908 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeader ::=..."); } //$NON-NLS-1$ + case 913 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeader ::=..."); } //$NON-NLS-1$ consumeAnnotationTypeDeclarationHeader() ; break; - case 909 : if (DEBUG) { System.out.println("AnnotationTypeDeclaration ::=..."); } //$NON-NLS-1$ + case 914 : if (DEBUG) { System.out.println("AnnotationTypeDeclaration ::=..."); } //$NON-NLS-1$ consumeAnnotationTypeDeclaration() ; break; - case 911 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::="); } //$NON-NLS-1$ + case 916 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::="); } //$NON-NLS-1$ consumeEmptyAnnotationTypeMemberDeclarationsopt() ; break; - case 912 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$ + case 917 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$ consumeAnnotationTypeMemberDeclarationsopt() ; break; - case 914 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarations ::=..."); } //$NON-NLS-1$ + case 919 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarations ::=..."); } //$NON-NLS-1$ consumeAnnotationTypeMemberDeclarations() ; break; - case 915 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt..."); } //$NON-NLS-1$ + case 920 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt..."); } //$NON-NLS-1$ consumeMethodHeaderNameWithTypeParameters(true); break; - case 916 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$ + case 921 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$ consumeMethodHeaderName(true); break; - case 917 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::="); } //$NON-NLS-1$ + case 922 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::="); } //$NON-NLS-1$ consumeEmptyMethodHeaderDefaultValue() ; break; - case 918 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::= DefaultValue"); } //$NON-NLS-1$ + case 923 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::= DefaultValue"); } //$NON-NLS-1$ consumeMethodHeaderDefaultValue(); break; - case 919 : if (DEBUG) { System.out.println("AnnotationMethodHeader ::= AnnotationMethodHeaderName..."); } //$NON-NLS-1$ + case 924 : if (DEBUG) { System.out.println("AnnotationMethodHeader ::= AnnotationMethodHeaderName..."); } //$NON-NLS-1$ consumeMethodHeader(); break; - case 920 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclaration ::=..."); } //$NON-NLS-1$ + case 925 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclaration ::=..."); } //$NON-NLS-1$ consumeAnnotationTypeMemberDeclaration() ; break; - case 928 : if (DEBUG) { System.out.println("AnnotationName ::= AT UnannotatableName"); } //$NON-NLS-1$ + case 933 : if (DEBUG) { System.out.println("AnnotationName ::= AT UnannotatableName"); } //$NON-NLS-1$ consumeAnnotationName() ; break; - case 929 : if (DEBUG) { System.out.println("NormalAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$ + case 934 : if (DEBUG) { System.out.println("NormalAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$ consumeNormalAnnotation(false) ; break; - case 930 : if (DEBUG) { System.out.println("MemberValuePairsopt ::="); } //$NON-NLS-1$ + case 935 : if (DEBUG) { System.out.println("MemberValuePairsopt ::="); } //$NON-NLS-1$ consumeEmptyMemberValuePairsopt() ; break; - case 933 : if (DEBUG) { System.out.println("MemberValuePairs ::= MemberValuePairs COMMA..."); } //$NON-NLS-1$ + case 938 : if (DEBUG) { System.out.println("MemberValuePairs ::= MemberValuePairs COMMA..."); } //$NON-NLS-1$ consumeMemberValuePairs() ; break; - case 934 : if (DEBUG) { System.out.println("MemberValuePair ::= SimpleName EQUAL EnterMemberValue..."); } //$NON-NLS-1$ + case 939 : if (DEBUG) { System.out.println("MemberValuePair ::= SimpleName EQUAL EnterMemberValue..."); } //$NON-NLS-1$ consumeMemberValuePair() ; break; - case 935 : if (DEBUG) { System.out.println("EnterMemberValue ::="); } //$NON-NLS-1$ + case 940 : if (DEBUG) { System.out.println("EnterMemberValue ::="); } //$NON-NLS-1$ consumeEnterMemberValue() ; break; - case 936 : if (DEBUG) { System.out.println("ExitMemberValue ::="); } //$NON-NLS-1$ + case 941 : if (DEBUG) { System.out.println("ExitMemberValue ::="); } //$NON-NLS-1$ consumeExitMemberValue() ; break; - case 938 : if (DEBUG) { System.out.println("MemberValue ::= Name"); } //$NON-NLS-1$ + case 943 : if (DEBUG) { System.out.println("MemberValue ::= Name"); } //$NON-NLS-1$ consumeMemberValueAsName() ; break; - case 941 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ + case 946 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ consumeMemberValueArrayInitializer() ; break; - case 942 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ + case 947 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ consumeMemberValueArrayInitializer() ; break; - case 943 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ + case 948 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ consumeEmptyMemberValueArrayInitializer() ; break; - case 944 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ + case 949 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$ consumeEmptyMemberValueArrayInitializer() ; break; - case 945 : if (DEBUG) { System.out.println("EnterMemberValueArrayInitializer ::="); } //$NON-NLS-1$ + case 950 : if (DEBUG) { System.out.println("EnterMemberValueArrayInitializer ::="); } //$NON-NLS-1$ consumeEnterMemberValueArrayInitializer() ; break; - case 947 : if (DEBUG) { System.out.println("MemberValues ::= MemberValues COMMA MemberValue"); } //$NON-NLS-1$ + case 952 : if (DEBUG) { System.out.println("MemberValues ::= MemberValues COMMA MemberValue"); } //$NON-NLS-1$ consumeMemberValues() ; break; - case 948 : if (DEBUG) { System.out.println("MarkerAnnotation ::= AnnotationName"); } //$NON-NLS-1$ + case 953 : if (DEBUG) { System.out.println("MarkerAnnotation ::= AnnotationName"); } //$NON-NLS-1$ consumeMarkerAnnotation(false) ; break; - case 949 : if (DEBUG) { System.out.println("SingleMemberAnnotationMemberValue ::= MemberValue"); } //$NON-NLS-1$ + case 954 : if (DEBUG) { System.out.println("SingleMemberAnnotationMemberValue ::= MemberValue"); } //$NON-NLS-1$ consumeSingleMemberAnnotationMemberValue() ; break; - case 950 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$ + case 955 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$ consumeSingleMemberAnnotation(false) ; break; - case 951 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); } //$NON-NLS-1$ + case 956 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); } //$NON-NLS-1$ consumeRecoveryMethodHeaderNameWithTypeParameters(); break; - case 952 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$ + case 957 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$ consumeRecoveryMethodHeaderName(); break; - case 953 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault..."); } //$NON-NLS-1$ + case 958 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault..."); } //$NON-NLS-1$ consumeRecoveryMethodHeaderNameWithTypeParameters(); break; - case 954 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault Type"); } //$NON-NLS-1$ + case 959 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault Type"); } //$NON-NLS-1$ consumeRecoveryMethodHeaderName(); break; - case 955 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$ + case 960 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$ consumeMethodHeader(); break; - case 956 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$ + case 961 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$ consumeMethodHeader(); break; } @@ -10409,13 +10406,20 @@ protected void consumeTypeParameterWithExtendsAndBounds() { } } protected void consumeGuard() { - this.astLengthPtr--; - Pattern pattern = (Pattern) this.astStack[this.astPtr--]; - Expression expr = this.expressionStack[this.expressionPtr--]; + Expression guardExpr = this.expressionStack[this.expressionPtr--]; this.expressionLengthPtr--; - GuardedPattern gPattern = new GuardedPattern(pattern, expr); + int patternLength = this.expressionLengthStack[this.expressionLengthPtr--]; + Pattern[] patterns = new Pattern[patternLength]; + System.arraycopy( + this.expressionStack, + this.expressionPtr - patternLength + 1, + patterns, + 0, + patternLength); + this.expressionPtr -= patternLength; + GuardedPattern gPattern = new GuardedPattern(patterns, guardExpr); gPattern.restrictedIdentifierStart = this.intStack[this.intPtr--]; - pushOnAstStack(gPattern); + pushOnExpressionStack(gPattern); } protected void consumeTypePattern() { //name diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java index d9e5e94b301..3f44c72f34b 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java @@ -22,20 +22,20 @@ public interface ParserBasicInformation { ERROR_SYMBOL = 140, MAX_NAME_LENGTH = 53, - NUM_STATES = 1262, + NUM_STATES = 1263, NT_OFFSET = 140, - SCOPE_UBOUND = 321, - SCOPE_SIZE = 322, - LA_STATE_OFFSET = 18370, + SCOPE_UBOUND = 322, + SCOPE_SIZE = 323, + LA_STATE_OFFSET = 18530, MAX_LA = 1, - NUM_RULES = 956, + NUM_RULES = 961, NUM_TERMINALS = 140, - NUM_NON_TERMINALS = 440, - NUM_SYMBOLS = 580, - START_STATE = 1508, + NUM_NON_TERMINALS = 444, + NUM_SYMBOLS = 584, + START_STATE = 4726, EOFT_SYMBOL = 38, EOLT_SYMBOL = 38, - ACCEPT_ACTION = 18369, - ERROR_ACTION = 18370; + ACCEPT_ACTION = 18529, + ERROR_ACTION = 18530; } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java index d570c25f687..c10ecf1cc23 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java @@ -4618,29 +4618,27 @@ private static class Goal { static int SwitchLabelCaseLhsRule = 0; static int[] RestrictedIdentifierSealedRule; static int[] RestrictedIdentifierPermitsRule; - static int[] PatternRules; + static int PatternCaseRule = 0; static Goal LambdaParameterListGoal; static Goal IntersectionCastGoal; static Goal VarargTypeAnnotationGoal; static Goal ReferenceExpressionGoal; static Goal BlockStatementoptGoal; - static Goal YieldStatementGoal; static Goal SwitchLabelCaseLhsGoal; static Goal RestrictedIdentifierSealedGoal; static Goal RestrictedIdentifierPermitsGoal; - static Goal PatternGoal; + static Goal PatternCaseLabelGoal; static int[] RestrictedIdentifierSealedFollow = { TokenNameclass, TokenNameinterface, TokenNameenum, TokenNameRestrictedIdentifierrecord };// Note: enum/record allowed as error flagging rules. static int[] RestrictedIdentifierPermitsFollow = { TokenNameLBRACE }; - static int[] PatternCaseLabelFollow = {TokenNameCOLON, TokenNameARROW, TokenNameCOMMA, TokenNameBeginCaseExpr, TokenNameRestrictedIdentifierWhen}; + static int[] PatternCaseLabelFollow = { TokenNameCOLON, TokenNameBeginCaseExpr }; static { List ridSealed = new ArrayList<>(2); List ridPermits = new ArrayList<>(); - List patternStates = new ArrayList<>(); for (int i = 1; i <= ParserBasicInformation.NUM_RULES; i++) { // 0 == $acc // TODO: Change to switch if ("ParenthesizedLambdaParameterList".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ @@ -4670,32 +4668,21 @@ private static class Goal { if ("SwitchLabelCaseLhs".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ SwitchLabelCaseLhsRule = i; else - if ("TypePattern".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ - patternStates.add(i); - else - if ("Pattern".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ - patternStates.add(i); - else - if ("ParenthesizedPattern".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ - patternStates.add(i); - else - if ("RecordPattern".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ - patternStates.add(i); + if ("CaseLabelPatternElements".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ + PatternCaseRule = i; } RestrictedIdentifierSealedRule = ridSealed.stream().mapToInt(Integer :: intValue).toArray(); // overkill but future-proof RestrictedIdentifierPermitsRule = ridPermits.stream().mapToInt(Integer :: intValue).toArray(); - PatternRules = patternStates.stream().mapToInt(Integer :: intValue).toArray(); LambdaParameterListGoal = new Goal(TokenNameARROW, new int[] { TokenNameARROW }, LambdaParameterListRule); IntersectionCastGoal = new Goal(TokenNameLPAREN, followSetOfCast(), IntersectionCastRule); VarargTypeAnnotationGoal = new Goal(TokenNameAT, new int[] { TokenNameELLIPSIS }, VarargTypeAnnotationsRule); ReferenceExpressionGoal = new Goal(TokenNameLESS, new int[] { TokenNameCOLON_COLON }, ReferenceExpressionRule); BlockStatementoptGoal = new Goal(TokenNameLBRACE, new int [0], BlockStatementoptRule); - YieldStatementGoal = new Goal(TokenNameARROW, new int [0], YieldStatementRule); SwitchLabelCaseLhsGoal = new Goal(TokenNameARROW, new int [0], SwitchLabelCaseLhsRule); RestrictedIdentifierSealedGoal = new Goal(TokenNameRestrictedIdentifiersealed, RestrictedIdentifierSealedFollow, RestrictedIdentifierSealedRule); RestrictedIdentifierPermitsGoal = new Goal(TokenNameRestrictedIdentifierpermits, RestrictedIdentifierPermitsFollow, RestrictedIdentifierPermitsRule); - PatternGoal = new Goal(TokenNameBeginCaseElement, PatternCaseLabelFollow, PatternRules); + PatternCaseLabelGoal = new Goal(TokenNameBeginCaseElement, PatternCaseLabelFollow, PatternCaseRule); } @@ -4903,8 +4890,8 @@ private VanguardScanner getNewVanguardScanner() { return vs; } protected final boolean mayBeAtCasePattern(int token) { - return ((token == TokenNamecase || this.multiCaseLabelComma) - && JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(this.complianceLevel, this.previewEnabled)) + return token == TokenNamecase + && JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(this.complianceLevel, this.previewEnabled) && !isInModuleDeclaration(); } protected final boolean maybeAtLambdaOrCast() { // Could the '(' we saw just now herald a lambda parameter list or a cast expression ? (the possible locations for both are identical.) @@ -5337,11 +5324,12 @@ protected int disambiguateArrowWithCaseExpr(Scanner scanner, int retToken) { * Assumption: mayBeAtCasePattern(token) is true before calling this method. */ int disambiguateCasePattern(int token, Scanner scanner) { - int delta = token == TokenNamecase ? 4 : 0; // 4 for case. final VanguardParser parser = getNewVanguardParser(); - parser.scanner.resetTo(parser.scanner.currentPosition + delta, parser.scanner.eofPosition); + // skip over 'case' + parser.scanner.resetTo(parser.scanner.currentPosition + 4, parser.scanner.eofPosition); parser.scanner.caseStartPosition = this.caseStartPosition; - if (parser.parse(Goal.PatternGoal) == VanguardParser.SUCCESS) { + + if (parser.parse(Goal.PatternCaseLabelGoal) == VanguardParser.SUCCESS) { if (token == TokenNamecase) { scanner.nextToken = TokenNameBeginCaseElement; } else { @@ -5349,6 +5337,7 @@ int disambiguateCasePattern(int token, Scanner scanner) { token = TokenNameBeginCaseElement; } } + return token; } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java index dcc1f2bb6df..b892a357033 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java @@ -72,7 +72,7 @@ static int getRestrictedKeyword(String text) { // BEGIN_AUTOGENERATED_REGION int TokenNameIdentifier = 22, - TokenNameabstract = 44, + TokenNameabstract = 46, TokenNameassert = 82, TokenNameboolean = 106, TokenNamebreak = 83, @@ -90,7 +90,7 @@ static int getRestrictedKeyword(String text) { TokenNameenum = 75, TokenNameextends = 93, TokenNamefalse = 56, - TokenNamefinal = 45, + TokenNamefinal = 47, TokenNamefinally = 117, TokenNamefloat = 111, TokenNamefor = 86, @@ -102,29 +102,29 @@ static int getRestrictedKeyword(String text) { TokenNameint = 113, TokenNameinterface = 74, TokenNamelong = 114, - TokenNamenative = 46, - TokenNamenew = 40, - TokenNamenon_sealed = 47, + TokenNamenative = 48, + TokenNamenew = 39, + TokenNamenon_sealed = 49, TokenNamenull = 57, TokenNamepackage = 91, - TokenNameprivate = 48, - TokenNameprotected = 49, - TokenNamepublic = 50, + TokenNameprivate = 50, + TokenNameprotected = 51, + TokenNamepublic = 52, TokenNamereturn = 88, TokenNameshort = 115, - TokenNamestatic = 39, - TokenNamestrictfp = 51, - TokenNamesuper = 36, + TokenNamestatic = 40, + TokenNamestrictfp = 53, + TokenNamesuper = 35, TokenNameswitch = 65, TokenNamesynchronized = 41, - TokenNamethis = 37, + TokenNamethis = 36, TokenNamethrow = 79, TokenNamethrows = 118, - TokenNametransient = 52, + TokenNametransient = 54, TokenNametrue = 58, TokenNametry = 89, TokenNamevoid = 116, - TokenNamevolatile = 53, + TokenNamevolatile = 55, TokenNamewhile = 80, TokenNamemodule = 119, TokenNameopen = 124, @@ -141,8 +141,8 @@ static int getRestrictedKeyword(String text) { TokenNameFloatingPointLiteral = 61, TokenNameDoubleLiteral = 62, TokenNameCharacterLiteral = 63, - TokenNameStringLiteral = 54, - TokenNameTextBlock = 55, + TokenNameStringLiteral = 42, + TokenNameTextBlock = 43, TokenNameStringTemplate = 120, TokenNameTextBlockTemplate = 121, TokenNamePLUS_PLUS = 2, @@ -171,7 +171,7 @@ static int getRestrictedKeyword(String text) { TokenNameMINUS = 5, TokenNameNOT = 67, TokenNameREMAINDER = 9, - TokenNameXOR = 23, + TokenNameXOR = 24, TokenNameAND = 21, TokenNameMULTIPLY = 8, TokenNameOR = 27, @@ -179,24 +179,24 @@ static int getRestrictedKeyword(String text) { TokenNameDIVIDE = 10, TokenNameGREATER = 15, TokenNameLESS = 11, - TokenNameLPAREN = 24, + TokenNameLPAREN = 23, TokenNameRPAREN = 25, - TokenNameLBRACE = 42, + TokenNameLBRACE = 44, TokenNameRBRACE = 33, TokenNameLBRACKET = 6, - TokenNameRBRACKET = 69, + TokenNameRBRACKET = 70, TokenNameSEMICOLON = 26, TokenNameQUESTION = 29, TokenNameCOLON = 66, TokenNameCOMMA = 32, TokenNameDOT = 1, TokenNameEQUAL = 78, - TokenNameAT = 35, + TokenNameAT = 37, TokenNameELLIPSIS = 122, TokenNameARROW = 105, TokenNameCOLON_COLON = 7, TokenNameBeginLambda = 64, - TokenNameBeginIntersectionCast = 70, + TokenNameBeginIntersectionCast = 69, TokenNameBeginTypeArguments = 90, TokenNameElidedSemicolonAndRightBrace = 72, TokenNameAT308 = 28, @@ -204,7 +204,7 @@ static int getRestrictedKeyword(String text) { TokenNameBeginCaseExpr = 73, TokenNameRestrictedIdentifierYield = 81, TokenNameRestrictedIdentifierrecord = 76, - TokenNameRestrictedIdentifiersealed = 43, + TokenNameRestrictedIdentifiersealed = 45, TokenNameRestrictedIdentifierpermits = 130, TokenNameBeginCaseElement = 133, TokenNameRestrictedIdentifierWhen = 134, diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser1.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser1.rsc index 7edacef7f3d..93d9931b08e 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser1.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser1.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser10.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser10.rsc index 5622265ed46..04a6c117ad9 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser10.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser10.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser11.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser11.rsc index be811ebe84e..ce66387c5c3 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser11.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser11.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser12.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser12.rsc index 4b7c62bc163..3627c2b05cb 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser12.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser12.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser13.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser13.rsc index dc7ebd28260..ba710c56bdc 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser13.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser13.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser14.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser14.rsc index 9cf4ba8761a..49b429725b8 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser14.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser14.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser15.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser15.rsc index c8227d51044..a931aff18f3 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser15.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser15.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser16.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser16.rsc index 49226f40493..ac9841d8897 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser16.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser16.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser17.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser17.rsc index 3d536ebab6d..2d4ba0655ee 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser17.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser17.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser18.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser18.rsc index afbec6dabca..17a7e388956 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser18.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser18.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc index 423b9a7028d..1f8f6a559ba 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser2.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser2.rsc index 234922d14b0..808aa1420eb 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser2.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser2.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser20.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser20.rsc index 2b23f6fb36d..6fe810247e0 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser20.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser20.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser21.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser21.rsc index 02e398dcba0..a100450acad 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser21.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser21.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser22.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser22.rsc index 7c9e139b047..50ffafd4c5a 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser22.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser22.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser23.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser23.rsc index 84edd5a11b9..94978d7e632 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser23.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser23.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser24.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser24.rsc index 01b5963b7e2..ad0effba9dd 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser24.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser24.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser3.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser3.rsc index 49d66c6104f..6358d993567 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser3.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser3.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser4.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser4.rsc index 39a375e2bde..156ee770026 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser4.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser4.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser5.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser5.rsc index 86ce01ce095..a0f84f53b5b 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser5.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser5.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser6.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser6.rsc index 971db9ed734..2f9f20c719b 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser6.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser6.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser7.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser7.rsc index 1e62f1f1757..adcae168b40 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser7.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser7.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser8.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser8.rsc index 2ef5760473f..31546613b79 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser8.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser8.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser9.rsc b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser9.rsc index 57ba5865c2f..99865aff646 100644 Binary files a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser9.rsc and b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser9.rsc differ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/readableNames.props b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/readableNames.props index c01cc557b81..6ee268863b9 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/readableNames.props +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/readableNames.props @@ -47,9 +47,11 @@ BlockStatements=BlockStatements BlockStatementsopt=BlockStatements BooleanLiteral=BooleanLiteral BreakStatement=BreakStatement -CaseLabelElement=CaseLabelElement -CaseLabelElementPattern=CaseLabelElementPattern -CaseLabelElements=CaseLabelElements +CaseLabelConstantElement=CaseLabelElement +CaseLabelConstantElements=CaseLabelConstantElements +CaseLabelPatternElements=CaseLabelElement +CasePattern=CasePattern +CasePatternList=CasePatternList CastExpression=CastExpression CastNameAndBounds=CastNameAndBounds CatchClause=CatchClause diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index 71568d3e1be..5d581de0fe4 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -12418,6 +12418,14 @@ public void illegalFallthroughFromAPattern(Statement statement) { statement.sourceStart, statement.sourceEnd); } +public void illegalCaseLabelWithMultiplePatterns(Statement statement) { + this.handle( + IProblem.CaseLabelWithPatternMustHaveExactlyOnePattern, + NoArgument, + NoArgument, + statement.sourceStart, + statement.sourceEnd); + } public void illegalCaseConstantCombination(Expression element) { this.handle( IProblem.ConstantWithPatternIncompatible, diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties index 23a161d3a35..71cb6cb948f 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties @@ -1163,6 +1163,7 @@ 1916 = A case label guard cannot have a constant expression with value as 'false' 1940 = Cannot infer record pattern types for {0} 1941 = Syntax error, record patterns are not allowed here +1942 = Case labels with a named pattern variable must have only one pattern 1990 = Access to {1}({2}) from the type {0} is emulated by a synthetic accessor method diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java index 58ab0b43c9f..7c2e43905df 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java @@ -1338,6 +1338,7 @@ class ProblemAttributes { expectedProblemAttributes.put("JavadocInvalidModule", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); expectedProblemAttributes.put("UnderscoreCannotBeUsedHere", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED)); expectedProblemAttributes.put("UnnamedVariableMustHaveInitializer", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED)); + expectedProblemAttributes.put("CaseLabelWithPatternMustHaveExactlyOnePattern", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); StringBuilder failures = new StringBuilder(); StringBuilder correctResult = new StringBuilder(70000); Field[] fields = (iProblemClass = IProblem.class).getFields(); @@ -2449,6 +2450,7 @@ class ProblemAttributes { expectedProblemAttributes.put("JavadocInvalidModule", SKIP); expectedProblemAttributes.put("UnderscoreCannotBeUsedHere", SKIP); expectedProblemAttributes.put("UnnamedVariableMustHaveInitializer", SKIP); + expectedProblemAttributes.put("CaseLabelWithPatternMustHaveExactlyOnePattern", SKIP); Map constantNamesIndex = new HashMap(); Field[] fields = JavaCore.class.getFields(); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java index 00c54cdb8bc..360cb8000e9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java @@ -1711,12 +1711,29 @@ public void testRemoveNamedRecordPatterns_001() { "record Rectangle(int x, int y) {\n" + "}" }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Rectangle(int x, int y) r -> 1;\n" + - " ^\n" + - "Syntax error on token \"r\", delete this token\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Rectangle(int x, int y) r -> 1; + ^^^ + Syntax error on token "int", delete this token + ---------- + 2. ERROR in X.java (at line 4) + case Rectangle(int x, int y) r -> 1; + ^^^ + Syntax error on token "int", invalid ( + ---------- + 3. ERROR in X.java (at line 4) + case Rectangle(int x, int y) r -> 1; + ^ + Syntax error, insert ")" to complete MethodInvocation + ---------- + 4. ERROR in X.java (at line 4) + case Rectangle(int x, int y) r -> 1; + ^ + Syntax error, insert ":" to complete SwitchLabel + ---------- + """); } public void testRecordPatternTypeInference_001() { runNegativeTest(new String[] { @@ -3613,4 +3630,148 @@ public static void main(String[] args) { "s = switch on null\n" + "s = default threw exception"); } + public void testIssue1804_0() { + runConformTest(new String[] { "X.java", """ + public class X { + record Paper(int color) {} + record Box(T a) {} + public static void main(String[] args) { + Box b = new Box<>(null); + boolean res = b instanceof Box(Paper a); + if (res) { + System.out.println("res is true"); + } else { + System.out.println("res is false"); + } + } + } + """ }, "res is false"); + } + public void testIssue1804_1() { + runConformTest(new String[] { "X.java", """ + public class X { + record Paper(int color) {} + record Box(T a) {} + public static void main(String[] args) { + Box b = new Box<>(new Paper(0)); + boolean res = b instanceof Box(Paper a); + if (res) { + System.out.println("res is true"); + } else { + System.out.println("res is false"); + } + } + } + """ }, "res is true"); + } + public void testIssue1804_2() { + runConformTest(new String[] { "X.java", """ + public class X { + record Paper(int color) {} + record Box(T a) {} + public static void main(String[] args) { + Box b = new Box<>(new Paper(0)); + boolean res = b instanceof Box(Paper a) && a == null; + if (res) { + System.out.println("res is true"); + } else { + System.out.println("res is false"); + } + } + } + """ }, "res is false"); + } + public void testIssue1804_3() { + runConformTest(new String[] { "X.java", """ + public class X { + record Paper(int color) {} + record Box(T a) {} + public static void main(String[] args) { + Box b = new Box<>(null); + System.out.println(b instanceof Box(Paper a)); + System.out.println(b instanceof Box(Object a)); + } + } + """ }, "false\ntrue"); + } + public void testIssue1804_4() { + runConformTest(new String[] { "X.java", """ + public class X { + record Paper(int color) {} + record Box(T a) {} + public static void main(String argv[]) { + foo(null, null); + } + public static void foo(String abc, String def) { + Box p = new Box<>(new Paper(0)); + boolean b = false; + switch (p) { + case Box(Paper a) -> { + b = true; + break; + } + default -> { + b = false; + break; + } + } + System.out.println(b); + } + } + """ }, "true"); + } + public void testIssue1804_5() { + runConformTest(new String[] { "X.java", """ + public class X { + record Paper(int color) {} + record Box(T a) {} + public static void main(String argv[]) { + foo(null, null); + } + public static void foo(String abc, String def) { + Box p = new Box<>(null); + boolean b = false; + switch (p) { + case Box(Paper a) -> { + b = true; + break; + } + default -> { + b = false; + break; + } + } + System.out.println(b); + } + } + """ }, "false"); + } + public void testIssue1804_6() { + runConformTest(new String[] { "X.java", """ + public class X { + record Paper(int color) {} + record Box(T a, T b) {} + public static void main(String argv[]) { + foo(null, null); + } + public static void foo(String abc, String def) { + Box p = new Box<>(new Paper(0), new Paper(1)); + boolean c = false; + switch (p) { + case Box(Paper a, Paper b) -> { + System.out.println(a.color); + System.out.println(b.color); + c = true; + break; + } + default -> { + c = false; + break; + } + } + System.out.println(c); + } + } + """ }, "0\n1\ntrue"); + } } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java index 8afddd00062..6b103e56e55 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java @@ -252,17 +252,19 @@ public void testBug573516_005() { "}\n"+ "class Y {}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer t, String s, X x : System.out.println(\"Integer, String or X\");\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 10)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer t, String s, X x : System.out.println("Integer, String or X"); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Case labels with a named pattern variable must have only one pattern + ---------- + 2. ERROR in X.java (at line 10) + Zork(); + ^^^^ + The method Zork() is undefined for the type X + ---------- + """); } public void testBug573516_006() { runNegativeTest( @@ -282,22 +284,39 @@ public void testBug573516_006() { "}\n"+ "class Y {}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer t, String s when s.length > 0, X x when x.hashCode() > 10 : System.out.println(\"Integer, String or X\");\n" + - " ^^^^^^^^^\n" - + "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case Integer t, String s when s.length > 0, X x when x.hashCode() > 10 : System.out.println(\"Integer, String or X\");\n" + - " ^^^^^^\n" + - "length cannot be resolved or is not a field\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer t, String s when s.length > 0, X x when x.hashCode() > 10 : System.out.println("Integer, String or X"); + ^^^^ + Syntax error on token "case", BeginCaseElement expected after this token + ---------- + 2. ERROR in X.java (at line 4) + case Integer t, String s when s.length > 0, X x when x.hashCode() > 10 : System.out.println("Integer, String or X"); + ^^^^ + Syntax error on token "when", RestrictedIdentifierWhen expected + ---------- + 3. ERROR in X.java (at line 4) + case Integer t, String s when s.length > 0, X x when x.hashCode() > 10 : System.out.println("Integer, String or X"); + ^ + Syntax error on token ",", : expected + ---------- + 4. ERROR in X.java (at line 4) + case Integer t, String s when s.length > 0, X x when x.hashCode() > 10 : System.out.println("Integer, String or X"); + ^^^^ + Syntax error on token "when", = expected + ---------- + 5. ERROR in X.java (at line 4) + case Integer t, String s when s.length > 0, X x when x.hashCode() > 10 : System.out.println("Integer, String or X"); + ^ + Syntax error on token ":", ; expected + ---------- + 6. ERROR in X.java (at line 10) + Zork(); + ^^^^ + The method Zork() is undefined for the type X + ---------- + """); } public void testBug573516_007() { runNegativeTest( @@ -317,22 +336,19 @@ public void testBug573516_007() { "}\n"+ "class Y {}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer t, String : System.out.println(\"Error should be flagged for String\");\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case Integer t, String : System.out.println(\"Error should be flagged for String\");\n" + - " ^^^^^^\n" + - "String cannot be resolved to a variable\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer t, String : System.out.println("Error should be flagged for String"); + ^ + Syntax error on token "t", delete this token + ---------- + 2. ERROR in X.java (at line 10) + Zork(); + ^^^^ + The method Zork() is undefined for the type X + ---------- + """); } public void testBug573516_008() { runNegativeTest( @@ -352,27 +368,19 @@ public void testBug573516_008() { "}\n"+ "class Y {}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer t, String : System.out.println(\"Error should be flagged for Integer and String\");\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case Integer t, String : System.out.println(\"Error should be flagged for Integer and String\");\n" + - " ^^^^^^^^^\n" + - "Type mismatch: cannot convert from int to Integer\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " case Integer t, String : System.out.println(\"Error should be flagged for Integer and String\");\n" + - " ^^^^^^\n" + - "String cannot be resolved to a variable\n" + - "----------\n" + - "4. ERROR in X.java (at line 10)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer t, String : System.out.println("Error should be flagged for Integer and String"); + ^ + Syntax error on token "t", delete this token + ---------- + 2. ERROR in X.java (at line 10) + Zork(); + ^^^^ + The method Zork() is undefined for the type X + ---------- + """); } public void testBug573516_009() { runNegativeTest( @@ -427,22 +435,19 @@ public void testBug573516_010() { "}\n"+ "class Y {}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case String s, default : System.out.println(\"Error should be flagged for String and default\");\n" + - " ^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case String s, default : System.out.println(\"Error should be flagged for String and default\");\n" + - " ^^^^^^^^\n" + - "Type mismatch: cannot convert from int to String\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case String s, default : System.out.println("Error should be flagged for String and default"); + ^ + Syntax error on token "s", delete this token + ---------- + 2. ERROR in X.java (at line 10) + Zork(); + ^^^^ + The method Zork() is undefined for the type X + ---------- + """); } public void testBug573516_011() { runNegativeTest( @@ -1624,12 +1629,14 @@ public void testBug574559_001() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " case 1, Integer i -> System.out.println(o);\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 5) + case 1, Integer i -> System.out.println(o); + ^ + Syntax error on token "i", delete this token + ---------- + """); } public void testBug574559_002() { runNegativeTest( @@ -1644,17 +1651,14 @@ public void testBug574559_002() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " case Integer i, 30 -> System.out.println(o);\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " case Integer i, 30 -> System.out.println(o);\n" + - " ^^\n" + - "This case label is dominated by one of the preceding case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 5) + case Integer i, 30 -> System.out.println(o); + ^ + Syntax error on token "i", delete this token + ---------- + """); } // Test that fall-through to a pattern is not allowed (label statement group has one statement) public void testBug573940_1() { @@ -1852,27 +1856,29 @@ public void testBug574564_002() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " case var i, var j, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case var i, var j, var k -> System.out.println(0);\n" + - " ^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " case var i, var j, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n" + - "4. ERROR in X.java (at line 7)\n" + - " case var i, var j, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case var i, var j, var k -> System.out.println(0); + ^^^^^^^^^^^^^^^^^^^^^^^^ + Case labels with a named pattern variable must have only one pattern + ---------- + 2. ERROR in X.java (at line 7) + case var i, var j, var k -> System.out.println(0); + ^^^ + 'var' is not allowed here + ---------- + 3. ERROR in X.java (at line 7) + case var i, var j, var k -> System.out.println(0); + ^^^ + 'var' is not allowed here + ---------- + 4. ERROR in X.java (at line 7) + case var i, var j, var k -> System.out.println(0); + ^^^ + 'var' is not allowed here + ---------- + """); } public void testBug574564_003() { runNegativeTest( @@ -1890,17 +1896,14 @@ public void testBug574564_003() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " case var i, 10 -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case var i, 10 -> System.out.println(0);\n" + - " ^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case var i, 10 -> System.out.println(0); + ^ + Syntax error on token "i", delete this token + ---------- + """); } public void testBug574564_004() { runNegativeTest( @@ -1918,22 +1921,19 @@ public void testBug574564_004() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " case var i, 10, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case var i, 10, var k -> System.out.println(0);\n" + - " ^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " case var i, 10, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case var i, 10, var k -> System.out.println(0); + ^ + Syntax error on token "i", delete this token + ---------- + 2. ERROR in X.java (at line 7) + case var i, 10, var k -> System.out.println(0); + ^ + Syntax error on token "k", delete this token + ---------- + """); } public void testBug574564_005() { runNegativeTest( @@ -1951,17 +1951,14 @@ public void testBug574564_005() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " case 10, null, var k -> System.out.println(0);\n" + - " ^^^^\n" + - "A null case label has to be either the only expression in a case label or the first expression followed only by a default\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case 10, null, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case 10, null, var k -> System.out.println(0); + ^ + Syntax error on token "k", delete this token + ---------- + """); } public void testBug574564_006() { runNegativeTest( @@ -1979,27 +1976,14 @@ public void testBug574564_006() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " case default, var k -> System.out.println(0);\n" + - " ^^^^^^^\n" + - "A \'default\' can occur after \'case\' only as a second case label expression and that too only if \'null\' precedes in \'case null, default\' \n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case default, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " case default, var k -> System.out.println(0);\n" + - " ^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "4. ERROR in X.java (at line 8)\n" + - " default -> System.out.println(o);\n" + - " ^^^^^^^\n" + - "The default case is already defined\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case default, var k -> System.out.println(0); + ^ + Syntax error on token "k", delete this token + ---------- + """); } public void testBug574564_007() { runNegativeTest( @@ -2017,37 +2001,14 @@ public void testBug574564_007() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " case default, default, var k -> System.out.println(0);\n" + - " ^^^^^^^\n" + - "A \'default\' can occur after \'case\' only as a second case label expression and that too only if \'null\' precedes in \'case null, default\' \n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case default, default, var k -> System.out.println(0);\n" + - " ^^^^^^^\n" + - "The default case is already defined\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " case default, default, var k -> System.out.println(0);\n" + - " ^^^^^^^\n" + - "A \'default\' can occur after \'case\' only as a second case label expression and that too only if \'null\' precedes in \'case null, default\' \n" + - "----------\n" + - "4. ERROR in X.java (at line 7)\n" + - " case default, default, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n" + - "5. ERROR in X.java (at line 7)\n" + - " case default, default, var k -> System.out.println(0);\n" + - " ^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "6. ERROR in X.java (at line 8)\n" + - " default -> System.out.println(o);\n" + - " ^^^^^^^\n" + - "The default case is already defined\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case default, default, var k -> System.out.println(0); + ^ + Syntax error on token "k", delete this token + ---------- + """); } public void testBug574564_008() { runNegativeTest( @@ -2065,27 +2026,14 @@ public void testBug574564_008() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 7)\n" + - " case default, 1, var k -> System.out.println(0);\n" + - " ^^^^^^^\n" + - "A \'default\' can occur after \'case\' only as a second case label expression and that too only if \'null\' precedes in \'case null, default\' \n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case default, 1, var k -> System.out.println(0);\n" + - " ^^^\n" + - "\'var\' is not allowed here\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " case default, 1, var k -> System.out.println(0);\n" + - " ^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "4. ERROR in X.java (at line 8)\n" + - " default -> System.out.println(o);\n" + - " ^^^^^^^\n" + - "The default case is already defined\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case default, 1, var k -> System.out.println(0); + ^ + Syntax error on token "k", delete this token + ---------- + """); } public void testBug574564_009() { runNegativeTest( @@ -2099,17 +2047,19 @@ public void testBug574564_009() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " switch (o) {\n" + - " ^\n" + - "An enhanced switch statement should be exhaustive; a default label expected\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case String s, default, Integer i -> System.out.println(0);\n" + - " ^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case String s, default, Integer i -> System.out.println(0); + ^ + Syntax error on token "s", delete this token + ---------- + 2. ERROR in X.java (at line 4) + case String s, default, Integer i -> System.out.println(0); + ^ + Syntax error on token "i", delete this token + ---------- + """); } public void testBug574564_010() { Map options = getCompilerOptions(); @@ -2211,17 +2161,19 @@ public void testBug574563_002() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case null, Integer i -> System.out.println(0);\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 9)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case null, Integer i -> System.out.println(0); + ^ + Syntax error on token "i", delete this token + ---------- + 2. ERROR in X.java (at line 9) + Zork(); + ^^^^ + The method Zork() is undefined for the type X + ---------- + """); } public void testBug574563_003() { runNegativeTest( @@ -2237,17 +2189,14 @@ public void testBug574563_003() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer i, null -> System.out.println(0);\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer i, null -> System.out.println(0); + ^ + Syntax error on token "i", delete this token + ---------- + """); } public void testBug574563_004() { runNegativeTest( @@ -2263,17 +2212,34 @@ public void testBug574563_004() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case null, Integer i when i > 10 -> System.out.println(0);\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case null, Integer i when i > 10 -> System.out.println(0); + ^ + Syntax error on token "i", : expected + ---------- + 2. ERROR in X.java (at line 4) + case null, Integer i when i > 10 -> System.out.println(0); + ^^^^ + Syntax error on token "when", ( expected + ---------- + 3. ERROR in X.java (at line 4) + case null, Integer i when i > 10 -> System.out.println(0); + ^^^^^ + Syntax error on tokens, TypeElidedUnnamedFormalParameter expected instead + ---------- + 4. ERROR in X.java (at line 4) + case null, Integer i when i > 10 -> System.out.println(0); + ^ + Syntax error, insert ")" to complete Expression + ---------- + 5. ERROR in X.java (at line 4) + case null, Integer i when i > 10 -> System.out.println(0); + ^ + Syntax error, insert "AssignmentOperator Expression" to complete Expression + ---------- + """); } public void testBug574563_005() { runNegativeTest( @@ -2289,17 +2255,29 @@ public void testBug574563_005() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer i when i > 10, null -> System.out.println(0);\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " Zork();\n" + - " ^^^^\n" + - "The method Zork() is undefined for the type X\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer i when i > 10, null -> System.out.println(0); + ^ + Syntax error on token "i", : expected + ---------- + 2. ERROR in X.java (at line 4) + case Integer i when i > 10, null -> System.out.println(0); + ^^^^ + Syntax error on token "when", ( expected after this token + ---------- + 3. ERROR in X.java (at line 4) + case Integer i when i > 10, null -> System.out.println(0); + ^^^^^^^^ + Syntax error on tokens, TypeElidedUnnamedFormalParameter expected instead + ---------- + 4. ERROR in X.java (at line 4) + case Integer i when i > 10, null -> System.out.println(0); + ^ + Syntax error, insert ")" to complete Expression + ---------- + """); } public void testBug575030_01() { this.runConformTest( @@ -3463,17 +3441,14 @@ public void testBug575047_07() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer j, \"\":\n" + - " ^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case Integer j, \"\":\n" + - " ^^\n" + - "Type mismatch: cannot convert from String to Number\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer j, "": + ^ + Syntax error on token "j", delete this token + ---------- + """); } public void testBug575047_08() { runConformTest( @@ -3901,22 +3876,14 @@ public void testBug575687_1() { "}\n" + "enum Color { Blue, Red; }\n", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer i2, 4.5:\n" + - " ^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case Integer i2, 4.5:\n" + - " ^^^\n" + - "Type mismatch: cannot convert from double to Number\n" + - "----------\n" + - "3. ERROR in X.java (at line 5)\n" + - " case 4.3: System.out.println();\n" + - " ^^^\n" + - "Type mismatch: cannot convert from double to Number\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case Integer i2, 4.5: + ^^ + Syntax error on token "i2", delete this token + ---------- + """); } public void testBug575686_1() { runNegativeTest( @@ -3938,47 +3905,19 @@ public void testBug575686_1() { "}\n" + "enum Color { Blue, Red; }\n", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case Integer i1, String s1 ->\n" + - " ^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " case Number n, null ->\n" + - " ^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " case Number n, null ->\n" + - " ^^^^^^^^\n" + - "This case label is dominated by one of the preceding case labels\n" + - "----------\n" + - "4. ERROR in X.java (at line 7)\n" + - " case Number n, null ->\n" + - " ^^^^\n" + - "Duplicate case\n" + - "----------\n" + - "5. ERROR in X.java (at line 9)\n" + - " case null, Class c ->\n" + - " ^^^^\n" + - "Duplicate case\n" + - "----------\n" + - "6. WARNING in X.java (at line 9)\n" + - " case null, Class c ->\n" + - " ^^^^^\n" + - "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n" + - "7. ERROR in X.java (at line 9)\n" + - " case null, Class c ->\n" + - " ^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n" + - "8. ERROR in X.java (at line 9)\n" + - " case null, Class c ->\n" + - " ^^^^^^^\n" + - "This case label is dominated by one of the preceding case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 7) + case Number n, null -> + ^ + Syntax error on token "n", delete this token + ---------- + 2. ERROR in X.java (at line 9) + case null, Class c -> + ^ + Syntax error on token "c", delete this token + ---------- + """); } public void testBug575738_001() { runNegativeTest( @@ -4575,7 +4514,7 @@ public void testBug578553_2() { 5. ERROR in X.java (at line 6) case Long l1 when l1.toString().equals(l1.toString()) -> { ^^^^ - Syntax error on token "when", , expected + Syntax error on token "when", RestrictedIdentifierWhen expected ---------- """); } @@ -4624,7 +4563,7 @@ public void testBug578553_3() { 5. ERROR in X.java (at line 6) case Long l1 when l.toString().equals(l1.toString()) -> { ^^^^ - Syntax error on token "when", , expected + Syntax error on token "when", RestrictedIdentifierWhen expected ---------- """); } @@ -6712,12 +6651,34 @@ public void testIssue1351_7() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " case Byte p when p.equals(exp), (byte) 0 -> {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), (byte) 0 -> { + ^ + Syntax error on token "p", : expected + ---------- + 2. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), (byte) 0 -> { + ^^^^ + Syntax error on token "when", ( expected after this token + ---------- + 3. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), (byte) 0 -> { + ^^^^ + Syntax error on tokens, TypeElidedUnnamedFormalParameter expected instead + ---------- + 4. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ")" to complete MethodInvocation + ---------- + 5. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ";" to complete BlockStatements + ---------- + """); } public void testIssue1351_8() { runNegativeTest( @@ -6737,12 +6698,34 @@ public void testIssue1351_8() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " case (byte) 0, Byte p when p.equals(exp) -> {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 5) + case (byte) 0, Byte p when p.equals(exp) -> { + ^ + Syntax error on token "p", : expected + ---------- + 2. ERROR in X.java (at line 5) + case (byte) 0, Byte p when p.equals(exp) -> { + ^ + Syntax error on token ".", ; expected + ---------- + 3. ERROR in X.java (at line 5) + case (byte) 0, Byte p when p.equals(exp) -> { + ^^^^ + Syntax error on tokens, delete these tokens + ---------- + 4. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ")" to complete MethodInvocation + ---------- + 5. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ";" to complete Statement + ---------- + """); } public void testIssue1351_9() { runNegativeTest( @@ -6762,12 +6745,34 @@ public void testIssue1351_9() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " case (byte) 0, (byte) 10, Byte p when p.equals(exp) -> {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 5) + case (byte) 0, (byte) 10, Byte p when p.equals(exp) -> { + ^ + Syntax error on token "p", : expected + ---------- + 2. ERROR in X.java (at line 5) + case (byte) 0, (byte) 10, Byte p when p.equals(exp) -> { + ^ + Syntax error on token ".", ; expected + ---------- + 3. ERROR in X.java (at line 5) + case (byte) 0, (byte) 10, Byte p when p.equals(exp) -> { + ^^^^ + Syntax error on tokens, delete these tokens + ---------- + 4. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ")" to complete MethodInvocation + ---------- + 5. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ";" to complete Statement + ---------- + """); } public void testIssue1351_10() { runNegativeTest( @@ -6787,12 +6792,34 @@ public void testIssue1351_10() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " case Byte p when p.equals(exp), null -> {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), null -> { + ^ + Syntax error on token "p", : expected + ---------- + 2. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), null -> { + ^^^^ + Syntax error on token "when", ( expected after this token + ---------- + 3. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), null -> { + ^^^^^^^ + Syntax error on tokens, TypeElidedUnnamedFormalParameter expected instead + ---------- + 4. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ")" to complete MethodInvocation + ---------- + 5. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ";" to complete BlockStatements + ---------- + """); } public void testIssue1351_11() { runNegativeTest( @@ -6811,17 +6838,29 @@ public void testIssue1351_11() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " switch (exp) {\n" + - " ^^^\n" + - "An enhanced switch statement should be exhaustive; a default label expected\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " case Byte p when p.equals(exp), default -> {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Cannot mix pattern with other case labels\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), default -> { + ^ + Syntax error on token "p", : expected + ---------- + 2. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), default -> { + ^^^^ + Syntax error on token "when", case expected + ---------- + 3. ERROR in X.java (at line 5) + case Byte p when p.equals(exp), default -> { + ^^^^^^^^^^^^^^^^^^^^^^^^^ + Syntax error on tokens, TypeElidedUnnamedFormalParameter expected instead + ---------- + 4. ERROR in X.java (at line 8) + } + ^ + Syntax error, insert ":" to complete SwitchLabel + ---------- + """); } public void testDisambiguatedRestrictedIdentifierWhenAsFirstMethodInvokation() { @@ -7147,6 +7186,7 @@ public static void main(String[] args) { }, "Default"); } + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1856 // [switch][record patterns] NPE: Cannot invoke "org.eclipse.jdt.internal.compiler.lookup.MethodBinding.isStatic()" public void testGHI1856() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest21.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest21.java new file mode 100644 index 00000000000..1c1c2ad8889 --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest21.java @@ -0,0 +1,301 @@ +package org.eclipse.jdt.core.tests.compiler.regression; + +import java.util.Map; + +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +import junit.framework.Test; + +public class SwitchPatternTest21 extends AbstractBatchCompilerTest { + + private static String[] JAVAC_OPTIONS = new String[] { "--enable-preview" }; + + public static Test suite() { + return buildMinimalComplianceTestSuite(SwitchPatternTest21.class, F_21); + } + + public SwitchPatternTest21(String name) { + super(name); + } + + @Override + protected Map getCompilerOptions() { + CompilerOptions compilerOptions = new CompilerOptions(super.getCompilerOptions()); + if (compilerOptions.sourceLevel == ClassFileConstants.JDK21) { + compilerOptions.enablePreviewFeatures = true; + } + return compilerOptions.getMap(); + } + + public void runConformTest(String[] files, String expectedOutput) { + super.runConformTest(files, expectedOutput, null, JAVAC_OPTIONS); + } + + public void testListOfPatterns_000() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + Object o = new Pantaloon(new Melon(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) : System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "success"); + } + + public void testListOfPatterns_001() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + Object o = new Pantaloon(new Chartreuse(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) : System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "success"); + } + + public void testListOfPatterns_002() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + Object o = new Pantaloon(new Licorice(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) : System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "failure"); + } + + public void testListOfPatterns_003() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + Object o = new Pantaloon(new Melon(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) when 1 == 1 && 2 == 2: System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "success"); + } + + public void testListOfPatterns_004() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + Object o = new Pantaloon(new Chartreuse(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) when 1 == 1 && 2 == 2 : System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "success"); + } + + public void testListOfPatterns_005() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + Object o = new Pantaloon(new Licorice(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) when 1 == 1 && 2 == 2 : System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "failure"); + } + + // next three tests: beat the static analysis so that the `when` clause comparison isn't optimized away + + public void testListOfPatterns_006() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + String myString = "asdf"; + Object o = new Pantaloon(new Melon(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) when myString.length() == 4: System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "success"); + } + + public void testListOfPatterns_007() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + String myString = "asdf"; + Object o = new Pantaloon(new Chartreuse(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) when myString.length() == 4: System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "success"); + } + + public void testListOfPatterns_008() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + String myString = "asdf"; + Object o = new Pantaloon(new Licorice(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int _), Pantaloon(Melon _, int _) when myString.length() == 4: System.out.println("success"); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "failure"); + } + + public void testTwoCasesWithRecordPatternsShouldNotDominateRegression() { + this.runConformTest( + new String[] { "X.java", + """ + public class X { + + public static void main(String... args) { + Object o = new Pantaloon(new Chartreuse(), 12); + switch (o) { + case Pantaloon(Chartreuse _, int i) when true: System.out.println("success " + i); break; + case Pantaloon(Melon _, int i) when true : System.out.println("success " + i); break; + default: System.out.println("failure"); break; + } + } + + static sealed abstract class Flavour permits Chartreuse, Orange, Licorice, Melon { } + static final class Chartreuse extends Flavour {} + static final class Orange extends Flavour {} + static final class Licorice extends Flavour {} + static final class Melon extends Flavour {} + static record Pantaloon(Flavour flavour, int i) {} + + } + """, }, + "success 12"); + } + +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java index 53df77fa9e1..ade058228ed 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import junit.framework.Test; + import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.IWorkspaceRoot; @@ -50,6 +50,8 @@ import org.eclipse.jface.text.Region; import org.eclipse.text.edits.TextEdit; +import junit.framework.Test; + @SuppressWarnings({"rawtypes", "unchecked"}) public class FormatterRegressionTests extends AbstractJavaModelTests { @@ -15960,11 +15962,51 @@ public void testBug573949() { " }\n" + "}\n" + "}"; + formatSource(source, + "public class X {\n" + + " private static void foo(Object o) {\n" + + " switch (o) {\n" + + " case Integer t, String : System.out.println(\"Error should be flagged for Integer and String\");\n" + + " default : System.out.println(\"Object\");\n" + + " }\n" + + " }\n" + + "\n" + + " static void testTriangle(Shape s) {\n" + + " switch (s) {\n" + + " case Triangle t when t.calculateArea() > 100 -> System.out.println(\"Large triangle\");\n" + + " default -> System.out.println(\"A shape, possibly a small triangle\");\n" + + " }\n" + + " }\n" + + "}" + ); +} + +public void testBug573949_0() { + setComplianceLevel(CompilerOptions.VERSION_21); + this.formatterOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); + String source = + "public class X {\n" + + " private static void foo(Object o) {\n" + + " switch (o) {\n" + + " case Integer t, String s : System.out.println(\"Error should be flagged for Integer and String\");\n" + + " default : System.out.println(\"Object\");\n" + + " }\n" + + " }\n" + + "\n" + + "static void testTriangle(Shape s) {\n" + + " switch (s) {\n" + + " case Triangle t when t.calculateArea() > 100 ->\n" + + " System.out.println(\"Large triangle\");\n" + + " default ->\n" + + " System.out.println(\"A shape, possibly a small triangle\");\n" + + " }\n" + + "}\n" + + "}"; formatSource(source, "public class X {\n" + " private static void foo(Object o) {\n" + " switch (o) {\n" + - " case Integer t, String:\n" + + " case Integer t, String s:\n" + " System.out.println(\"Error should be flagged for Integer and String\");\n" + " default:\n" + " System.out.println(\"Object\");\n" + diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java index 72921c89f9e..8aa346ec010 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java @@ -52,7 +52,7 @@ public void test001() throws JavaModelException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case Rectangle(ColoredPoint(Point(int x, int y), Color c),\n" - + " ColoredPoint lr) r1 -> {\n" + + " ColoredPoint lr) -> {\n" + " yield 1; \n" + " } \n" + " default -> 0;\n" @@ -89,7 +89,7 @@ public void test002() throws JavaModelException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case /*here*/ Rectangl (ColoredPoint(Point(int x, int y), Color c),\n" - + " ColoredPoint lr) r1 -> {\n" + + " ColoredPoint lr) -> {\n" + " yield 1; \n" + " } \n" + " default -> 0;\n" @@ -111,7 +111,7 @@ public void test002() throws JavaModelException { String completeBehind = "/*here*/ Rectangl"; int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("Rectangle[TYPE_REF]{Rectangle, , LRectangle;, null, null, 52}", + assertResults("Rectangle[TYPE_REF]{Rectangle, , LRectangle;, null, null, 82}", requestor.getResults()); } @@ -125,7 +125,7 @@ public void test003() throws JavaModelException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case Rectangle(/*here*/ ColoredPoin(Point(int x, int y), Color c),\n" - + " ColoredPoint lr) r1 -> {\n" + + " ColoredPoint lr) -> {\n" + " yield 1; \n" + " } \n" + " default -> 0;\n" @@ -161,7 +161,7 @@ public void test004() throws JavaModelException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case Rectangle(ColoredPoint(/*here*/ Poin(int x, int y), Color c),\n" - + " ColoredPoint lr) r1 -> {\n" + + " ColoredPoint lr) -> {\n" + " yield 1; \n" + " } \n" + " default -> 0;\n" @@ -197,7 +197,7 @@ public void test005() throws JavaModelException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case Rectangle(ColoredPoint( Point(int x, int y), /*here*/ Colo c),\n" - + " ColoredPoint lr) r1 -> {\n" + + " ColoredPoint lr) -> {\n" + " yield 1; \n" + " } \n" + " default -> 0;\n" diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs19Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs19Tests.java index bfae6b3f338..efc3d22c43f 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs19Tests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs19Tests.java @@ -458,7 +458,7 @@ public void testIssue215_008() throws CoreException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case Rectangle(ColoredPoint(Point(int xyz, int y), Color c1),\n" - + " ColoredPoint lr) r11 -> {\n" + + " ColoredPoint lr) -> {\n" + " System.out.println(c1);\n" + " yield 1; \n" + " } \n" @@ -506,7 +506,7 @@ public void testIssue215_009() throws CoreException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case Rectangle(ColoredPoint(Point(int xyz, int y), Color c1),\n" - + " ColoredPoint lr) r11 -> {\n" + + " ColoredPoint lr) -> {\n" + " System.out.println(c1);\n" + " yield 1; \n" + " } \n" @@ -557,7 +557,7 @@ public void testIssue215_010() throws CoreException { + " public static void printLowerRight(Rectangle r) {\n" + " int res = switch(r) {\n" + " case Rectangle(ColoredPoint(Point(int xyz, int y), Color c1),\n" - + " ColoredPoint lr) r11 -> {\n" + + " ColoredPoint lr) -> {\n" + " System.out.println(c1);\n" + " yield 1; \n" + " } \n" diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs21Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs21Tests.java new file mode 100644 index 00000000000..4704f3745b4 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs21Tests.java @@ -0,0 +1,169 @@ +package org.eclipse.jdt.core.tests.model; + +import java.io.IOException; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.ILocalVariable; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.WorkingCopyOwner; +import org.eclipse.jdt.core.search.IJavaSearchScope; +import org.eclipse.jdt.core.search.ReferenceMatch; +import org.eclipse.jdt.core.search.SearchEngine; +import org.eclipse.jdt.core.search.SearchMatch; +import org.eclipse.jdt.core.search.TypeReferenceMatch; + +import junit.framework.Test; + +public class JavaSearchBugs21Tests extends AbstractJavaSearchTests { + + public JavaSearchBugs21Tests(String name) { + super(name); + this.endChar = ""; + } + + public static Test suite() { + return buildModelTestSuite(JavaSearchBugs21Tests.class, BYTECODE_DECLARATION_ORDER); + } + + class TestCollector extends JavaSearchResultCollector { + public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { + super.acceptSearchMatch(searchMatch); + } + } + + class ReferenceCollector extends JavaSearchResultCollector { + protected void writeLine() throws CoreException { + super.writeLine(); + ReferenceMatch refMatch = (ReferenceMatch) this.match; + IJavaElement localElement = refMatch.getLocalElement(); + if (localElement != null) { + this.line.append("+["); + if (localElement.getElementType() == IJavaElement.ANNOTATION) { + this.line.append('@'); + this.line.append(localElement.getElementName()); + this.line.append(" on "); + this.line.append(localElement.getParent().getElementName()); + } else { + this.line.append(localElement.getElementName()); + } + this.line.append(']'); + } + } + } + + class TypeReferenceCollector extends ReferenceCollector { + protected void writeLine() throws CoreException { + super.writeLine(); + TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) this.match; + IJavaElement[] others = typeRefMatch.getOtherElements(); + int length = others == null ? 0 : others.length; + if (length > 0) { + this.line.append("+["); + for (int i = 0; i < length; i++) { + IJavaElement other = others[i]; + if (i > 0) + this.line.append(','); + if (other.getElementType() == IJavaElement.ANNOTATION) { + this.line.append('@'); + this.line.append(other.getElementName()); + this.line.append(" on "); + this.line.append(other.getParent().getElementName()); + } else { + this.line.append(other.getElementName()); + } + } + this.line.append(']'); + } + } + } + + protected IJavaProject setUpJavaProject(final String projectName, String compliance, boolean useFullJCL) + throws CoreException, IOException { + // copy files in project from source workspace to target workspace + IJavaProject setUpJavaProject = super.setUpJavaProject(projectName, compliance, useFullJCL); + return setUpJavaProject; + } + + IJavaSearchScope getJavaSearchScope() { + return SearchEngine.createJavaSearchScope(new IJavaProject[] { getJavaProject("JavaSearchBugs") }); + } + + IJavaSearchScope getJavaSearchScopeBugs(String packageName, boolean addSubpackages) throws JavaModelException { + if (packageName == null) + return getJavaSearchScope(); + return getJavaSearchPackageScope("JavaSearchBugs", packageName, addSubpackages); + } + + public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException { + if (this.wcOwner == null) { + this.wcOwner = new WorkingCopyOwner() { + }; + } + return getWorkingCopy(path, source, this.wcOwner); + } + + @Override + public void setUpSuite() throws Exception { + super.setUpSuite(); + JAVA_PROJECT = setUpJavaProject("JavaSearchBugs", "21"); + } + + public void tearDownSuite() throws Exception { + deleteProject("JavaSearchBugs"); + super.tearDownSuite(); + } + + protected void setUp() throws Exception { + super.setUp(); + this.resultCollector = new TestCollector(); + this.resultCollector.showAccuracy(true); + } + + public void testListOfPatterns() throws CoreException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", + """ + public class X { + public void myMethod() { + MyTokenSearchRecord value = new MyTokenSearchRecord(1, new ClazzB()); + switch (value) { + case MyTokenSearchRecord(int num1, ClazzA aaa), MyTokenSearchRecord(int num2, ClazzB bbb) when 0 == 0 && /*here*/num1 < num2: + System.out.println("Hello, World"); + break; + default: + break; + } + } + } + + record MyTokenSearchRecord(int i, Clazz j) {} + abstract sealed class Clazz permits ClazzA, ClazzB, ClazzC {} + final class ClazzA extends Clazz {} + final class ClazzB extends Clazz {} + final class ClazzC extends Clazz {} + """ + ); + IJavaProject javaProject = this.workingCopies[0].getJavaProject(); // assuming single project for all + // working copies + String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true); + try { + javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.DISABLED); + String str = this.workingCopies[0].getSource(); + String selection = "/*here*/num1"; + int start = str.indexOf(selection); + int length = selection.length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); + assertEquals("incorrect no of elements", 1, elements.length); + assertTrue(elements[0] instanceof ILocalVariable); + search(elements[0], REFERENCES, EXACT_RULE); + assertSearchResults("src/X.java void X.myMethod() [num1] EXACT_MATCH"); + } finally { + javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old); + } + } + +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java index 88ee879ce6b..b5f92533646 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java @@ -13,9 +13,10 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.model; -import java.lang.reflect.*; -import java.util.*; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.List; import org.eclipse.jdt.core.tests.junit.extension.TestCase; @@ -71,6 +72,7 @@ public static Test suite() { allClasses.add(JavaSearchBugs16Tests.class); allClasses.add(JavaSearchBugs17Tests.class); allClasses.add(JavaSearchBugs19Tests.class); + allClasses.add(JavaSearchBugs21Tests.class); allClasses.add(JavaSearchMultipleProjectsTests.class); allClasses.add(SearchTests.class); allClasses.add(JavaSearchScopeTests.class); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchPatternTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchPatternTest.java index b2a1530b1ae..e80f905105a 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchPatternTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchPatternTest.java @@ -1126,7 +1126,7 @@ public void testNPEinASTRewriteFlattener() throws Exception { buf1.append("public class X {\n"); buf1.append( "void foo(Object o) {\n"); buf1.append( " switch (o) {\n"); - buf1.append( " case null when null:\n"); + buf1.append( " case when null:\n"); buf1.append( " System.out.println(\"Greater than 10\");\n"); buf1.append( " default : System.out.println(\"0\");\n"); buf1.append( " }\n"); diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java index 90c05de148a..4c6a50e388d 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java @@ -187,6 +187,9 @@ private void buildMoreCompletionContext(Expression expression) { Statement whileBody = null; + boolean hasGuard = false; + int guardPosition = -1; + int kind; for (int i = this.elementPtr; i > -1; i--) { @@ -206,13 +209,24 @@ private void buildMoreCompletionContext(Expression expression) { thenStat = elseStat = null; break; case K_BETWEEN_CASE_AND_COLONORARROW: + if (hasGuard) { + int patternListLength = 0; + this.expressionPtr = guardPosition; + while (this.expressionStack[this.expressionPtr] instanceof Pattern) { + patternListLength++; + this.expressionPtr--; + } + Pattern[] patterns = new Pattern[patternListLength]; + System.arraycopy(this.expressionStack, this.expressionPtr + 1, patterns, 0, patternListLength); + parentNode = orphan = new GuardedPattern(patterns, (Expression) orphan); + } parentNode = orphan = new CaseStatement((Expression) orphan, orphan.sourceStart, orphan.sourceEnd); break; case K_INSIDE_WHEN: - if (this.astPtr >=0 && this.astStack[this.astPtr] instanceof Pattern && orphan instanceof Expression) { - this.astLengthPtr--; - Pattern pattern = (Pattern) this.astStack[this.astPtr--]; - parentNode = orphan = new GuardedPattern(pattern, (Expression) orphan); + hasGuard = true; + guardPosition = this.expressionPtr; + while (guardPosition > 0 && !(this.expressionStack[guardPosition] instanceof Pattern)) { + guardPosition--; } break; case K_POST_WHILE_EXPRESSION: diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java index efdca085207..75babd4aba2 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java @@ -2343,7 +2343,9 @@ public Pattern convert(org.eclipse.jdt.internal.compiler.ast.GuardedPattern patt if (this.resolveBindings) { recordNodes(guardedPattern, pattern); } - guardedPattern.setPattern(convert(pattern.primaryPattern)); + for (org.eclipse.jdt.internal.compiler.ast.Pattern nestedPattern : pattern.patterns) { + guardedPattern.patterns().add(convert(nestedPattern)); + } guardedPattern.setExpression(convert(pattern.condition)); int startPosition = pattern.sourceStart; int sourceEnd = pattern.sourceEnd; diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java index 46afcaa8ab8..74acb58b8ab 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java @@ -42,7 +42,9 @@ public class GuardedPattern extends Pattern{ /** * The "pattern" structural property of this node type (child type: {@link Pattern}). (added in JEP 406). */ - public static final ChildPropertyDescriptor PATTERN_PROPERTY = internalPatternPropertyFactory(GuardedPattern.class); + public static final ChildPropertyDescriptor PATTERN_PROPERTY = internalPatternPropertyFactory(GuardedPattern.class); + + public static final ChildListPropertyDescriptor PATTERNS_PROPERTY = new ChildListPropertyDescriptor(GuardedPattern.class, "patterns", Pattern.class, CYCLE_RISK); //$NON-NLS-1$ /** * The "expression" structural property of this node type (child type: {@link Expression}). (added in JEP 406). @@ -64,23 +66,23 @@ public class GuardedPattern extends Pattern{ private static final List PROPERTY_DESCRIPTORS; static { - List propertyList = new ArrayList(3); + List propertyList = new ArrayList(4); createPropertyList(GuardedPattern.class, propertyList); - addProperty(PATTERN_PROPERTY, propertyList); + addProperty(PATTERNS_PROPERTY, propertyList); addProperty(EXPRESSION_PROPERTY, propertyList); PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); } /** - * The pattern; null for none + * The patterns */ - private Pattern pattern = null; + private final ASTNode.NodeList patterns = new ASTNode.NodeList(PATTERNS_PROPERTY); /** * The expression; null for none; lazily initialized (but * does not default to none). */ - private Expression conditonalExpression = null; + private Expression conditionalExpression = null; @@ -106,7 +108,7 @@ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, bool if (get) { return getPattern(); } else { - setPattern((Pattern)child); + setPattern((Pattern) child); return null; } } @@ -114,6 +116,15 @@ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, bool return super.internalGetSetChildProperty(property, get, child); } + @Override + final List internalGetChildListProperty(ChildListPropertyDescriptor property) { + if (property == PATTERNS_PROPERTY) { + return patterns(); + } + // allow default implementation to flag the error + return super.internalGetChildListProperty(property); + } + @Override int getNodeType0() { return GUARDED_PATTERN; @@ -128,7 +139,8 @@ boolean subtreeMatch0(ASTMatcher matcher, Object other) { ASTNode clone0(AST target) { GuardedPattern result = new GuardedPattern(target); result.setSourceRange(getStartPosition(), getLength()); - result.setPattern((Pattern) getPattern().clone(target)); + result.patterns.addAll( + ASTNode.copySubtrees(target, patterns())); result.setExpression((Expression) getExpression().clone(target)); result.setRestrictedIdentifierStartPosition(this.restrictedIdentifierStartPosition); return result; @@ -139,11 +151,10 @@ void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order - acceptChild(visitor, getPattern()); + acceptChildren(visitor, this.patterns); acceptChild(visitor, getExpression()); } visitor.endVisit(this); - } @Override @@ -153,10 +164,9 @@ int memSize() { @Override int treeSize() { - return - memSize() - + (this.pattern == null ? 0 : getPattern().treeSize()) - + (this.conditonalExpression == null ? 0 : getExpression().treeSize()); + return memSize() + + this.patterns.listSize() + + (this.conditionalExpression == null ? 0 : getExpression().treeSize()); } /** @@ -199,41 +209,49 @@ public static List propertyDescriptors(int apiLevel, boolean previewEnabled) { */ public Expression getExpression() { supportedOnlyIn21(); - if (this.conditonalExpression == null) { + if (this.conditionalExpression == null) { //lazy init must be thread-safe for readers synchronized (this) { - if (this.conditonalExpression == null) { + if (this.conditionalExpression == null) { preLazyInit(); - this.conditonalExpression = this.ast.newNullLiteral(); - postLazyInit(this.pattern, EXPRESSION_PROPERTY); + this.conditionalExpression = this.ast.newNullLiteral(); + postLazyInit(this.conditionalExpression, EXPRESSION_PROPERTY); } } } - return this.conditonalExpression; + return this.conditionalExpression; } /** - * Returns the pattern of this Guarded Pattern, or + * Returns the first pattern of this Guarded Pattern, or * empty if there is none. * @return the pattern node * (element type: {@link Pattern}) * @exception UnsupportedOperationException if this operation is used other than JLS18 * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false + * @deprecated use patterns() instead * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. */ public Pattern getPattern() { supportedOnlyIn21(); - if (this.pattern == null) { - // lazy init must be thread-safe for readers - synchronized (this) { - if (this.pattern == null) { - preLazyInit(); - this.pattern = this.ast.newNullPattern(); - postLazyInit(this.pattern, PATTERN_PROPERTY); - } - } + if (this.patterns.size() == 0) { + return null; } - return this.pattern; + return (Pattern) this.patterns.get(0); + } + + /** + * Returns the patterns of this Guarded Pattern. + * @return the pattern node + * (element type: {@link Pattern}) + * @exception UnsupportedOperationException if this operation is used other than JLS18 + * @exception UnsupportedOperationException if this expression is used with previewEnabled flag as false + * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. + * @since 3.37 + */ + public List patterns() { + supportedOnlyIn21(); + return this.patterns; } /** @@ -251,9 +269,9 @@ public Pattern getPattern() { */ public void setExpression(Expression expression) { supportedOnlyIn21(); - ASTNode oldChild = this.conditonalExpression; + ASTNode oldChild = this.conditionalExpression; preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); - this.conditonalExpression = expression; + this.conditionalExpression = expression; postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); } @@ -262,13 +280,15 @@ public void setExpression(Expression expression) { * @noreference This method is not intended to be referenced by clients. * @exception UnsupportedOperationException if this operation is used not for JLS18 * @exception UnsupportedOperationException if this operation is used without previewEnabled + * @deprecated use patterns() and mutate the list instead */ public void setPattern(Pattern pattern) { supportedOnlyIn21(); - ASTNode oldChild = this.pattern; - preReplaceChild(oldChild, pattern, PATTERN_PROPERTY); - this.pattern = pattern; - postReplaceChild(oldChild, pattern, PATTERN_PROPERTY); + if (this.patterns.size() > 0) { + this.patterns.set(0, pattern); + } else { + this.patterns.add(pattern); + } } /** diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java index 826a14d8572..28835f80e36 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java @@ -816,7 +816,9 @@ public boolean visit(ForStatement node) { @Override public boolean visit(GuardedPattern node) { if (DOMASTUtil.isPatternSupported(node.getAST())) { - node.getPattern().accept(this); + for (Object o : node.patterns()) { + ((Pattern)o).accept(this); + } this.buffer.append(" when ");//$NON-NLS-1$ node.getExpression().accept(this); } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java index f547672bf73..8e38950e1f5 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java @@ -2978,7 +2978,7 @@ public boolean visit(GuardedPattern node) { return doVisitUnchangedChildren(node); } - rewriteRequiredNode(node, GuardedPattern.PATTERN_PROPERTY); + rewriteRequiredNode(node, GuardedPattern.PATTERNS_PROPERTY); rewriteRequiredNode(node, GuardedPattern.EXPRESSION_PROPERTY); return false; diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java index 0a11cf2864c..3261b1d00b4 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java @@ -579,7 +579,9 @@ public boolean visit(ForStatement node) { @Override public boolean visit(GuardedPattern node) { if (DOMASTUtil.isPatternSupported(node.getAST())) { - node.getPattern().accept(this); + for (Object o : node.patterns()) { + ((Pattern)o).accept(this); + } this.result.append(" when ");//$NON-NLS-1$ node.getExpression().accept(this); }