Skip to content

Commit

Permalink
Merge commit '4e46b78c91fee91dba084d8c4326c47c2d26be52' into BETA_JAVA22
Browse files Browse the repository at this point in the history
# Conflicts:
#	org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java
#	org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
#	org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
#	org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
#	org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java

Change-Id: I00ac431c664e8789cbfa8d4d6e4fcb083fcca31d
  • Loading branch information
jarthana committed Mar 7, 2024
2 parents 60ad932 + 4e46b78 commit a5c1a0d
Show file tree
Hide file tree
Showing 70 changed files with 4,984 additions and 2,182 deletions.
10 changes: 3 additions & 7 deletions org.eclipse.jdt.core.compiler.batch/grammar/java.g
Original file line number Diff line number Diff line change
Expand Up @@ -1251,21 +1251,18 @@ InstanceofExpression ::= InstanceofExpression InstanceofRHS

InstanceofRHS -> InstanceofClassic
InstanceofRHS -> InstanceofPattern
/.$putCase consumeInstanceOfRHS(); $break ./
/:$readableName Expression:/
/:$readableName InstanceofRHS:/

InstanceofClassic ::= 'instanceof' Modifiersopt Type
/.$putCase consumeInstanceOfClassic(); $break ./
/:$readableName InstanceofClassic:/

InstanceofPattern ::= 'instanceof' Pattern
/.$putCase consumeInstanceofPattern(); $break ./
InstanceofPattern -> 'instanceof' Pattern
/:$readableName InstanceofPattern:/


Pattern -> TypePattern
Pattern -> RecordPattern
/.$putCase consumePattern(); $break ./
/:$readableName Pattern:/

TypePattern ::= Modifiersopt Type 'Identifier'
Expand Down Expand Up @@ -1623,8 +1620,7 @@ CaseLabelElement ::= CaseLabelElementPattern Guard
/.$putCase consumeCaseLabelElement(CaseLabelKind.CASE_PATTERN); $break ./
/:$readableName CaseLabelElement:/

CaseLabelElementPattern ::= BeginCaseElement Pattern
/.$putCase consumeCaseLabelElementPattern(); $break ./
CaseLabelElementPattern -> BeginCaseElement Pattern
/:$readableName CaseLabelElementPattern:/

Guard ::= RestrictedIdentifierWhen Expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void main(String[] args) throws IOException, InterruptedException
File javasymFile = new File(grammarDir, "javasym.java");
File terminalTokensFile = new File(parserDir, "TerminalTokens.java");
String javasymText = new String(Files.readAllBytes(javasymFile.toPath())).replace("\r\n", "\n");
String terminalTokensText = new String(Files.readAllBytes(terminalTokensFile.toPath()));
String terminalTokensText = new String(Files.readAllBytes(terminalTokensFile.toPath())).replace("\r\n", "\n");
{
String startTag = "// BEGIN_AUTOGENERATED_REGION\n";
int start = terminalTokensText.indexOf(startTag);
Expand All @@ -89,7 +89,7 @@ public static void main(String[] args) throws IOException, InterruptedException
File javadefFile = new File(grammarDir, "javadef.java");
File parserBasicInformationFile = new File(parserDir, "ParserBasicInformation.java");
String javadefText = new String(Files.readAllBytes(javadefFile.toPath())).replace("\r\n", "\n");
String parserBasicInformationText = new String(Files.readAllBytes(parserBasicInformationFile.toPath()));
String parserBasicInformationText = new String(Files.readAllBytes(parserBasicInformationFile.toPath())).replace("\r\n", "\n");
{
String startTag = "// BEGIN_AUTOGENERATED_REGION";
int start = parserBasicInformationText.indexOf(startTag);
Expand All @@ -112,7 +112,7 @@ public static void main(String[] args) throws IOException, InterruptedException

// Update method consumeRule in Parser.java
File parserFile = new File(parserDir, "Parser.java");
String parserText = new String(Files.readAllBytes(parserFile.toPath()));
String parserText = new String(Files.readAllBytes(parserFile.toPath())).replace("\r\n", "\n");
File javaActionFile = new File(grammarDir, "JavaAction.java");
String javaActionText = new String(Files.readAllBytes(javaActionFile.toPath()))
.replace("\r\n", "\n").replace(" \n", "\n").replace(" \n", "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,11 @@ public interface IProblem {
*/
int IllegalRecordPattern = TypeRelated + 1941;

/**
* @since 3.37
*/
int NamedPatternVariablesDisallowedHere = Internal + 1942;

/**
* @since 3.37
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean
}
if (this.rightInitStateIndex != -1) {
codeStream.addDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
}
if (rightIsConst) {
this.right.generateCode(currentScope, codeStream, false);
Expand Down Expand Up @@ -230,8 +231,8 @@ public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStr
break generateOperands; // no need to generate right operand
}
if (this.rightInitStateIndex != -1) {
codeStream
.addDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
codeStream.addDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
}
this.right.generateOptimizedBoolean(currentScope, codeStream, trueLabel, null,
valueRequired && !rightIsConst);
Expand All @@ -255,8 +256,8 @@ public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStr
break generateOperands; // no need to generate right operand
}
if (this.rightInitStateIndex != -1) {
codeStream
.addDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
codeStream.addDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.rightInitStateIndex);
}
this.right.generateOptimizedBoolean(currentScope, codeStream, null, falseLabel, valueRequired && !rightIsConst);
if (valueRequired && rightIsConst && !rightIsTrue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public void setFieldIndex(int depth) {
* @param scope used to determine source level
*/
public boolean isUnnamed(BlockScope scope) {
return this.name.length == 1 && this.name[0] == '_'
&& JavaFeature.UNNAMMED_PATTERNS_AND_VARS.isSupported(scope.compilerOptions());
return this.name.length == 1 && this.name[0] == '_' && JavaFeature.UNNAMMED_PATTERNS_AND_VARS.isSupported(scope.compilerOptions().sourceLevel, scope.compilerOptions().enablePreviewFeatures);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1825,15 +1825,6 @@ public StringBuilder printExpressionNoParenthesis(int indent, StringBuilder outp
return this.right.printExpression(0, output);
}

@Override
public void addPatternVariables(BlockScope scope, CodeStream codeStream) {
this.left.addPatternVariables(scope, codeStream); // Srikanth
this.right.addPatternVariables(scope, codeStream);
}
@Override
public boolean containsPatternVariable() {
return this.left.containsPatternVariable() || this.right.containsPatternVariable();
}
@Override
public TypeBinding resolveType(BlockScope scope) {
// keep implementation in sync with CombinedBinaryExpression#resolveType
Expand Down

0 comments on commit a5c1a0d

Please sign in to comment.