Add back tests that disappeared by mistake

This commit is contained in:
Clément Fournier committed 2022-03-10 21:09:54 +01:00
1 parent 07549b1283
commit e27e595e58
11 files changed
+1061 -7

No files matched your search

@@ -136,11 +136,11 @@ public class ParserCornersTest extends BaseJavaTreeDumpTest {
*/
@Test
public void testGenericsProblem() {
String code = "public class Test {\n" +
" public void test() {\n" +
" String o = super.<String> doStuff(\"\");\n" +
" }\n" +
"}";
String code = "public class Test {\n"
+ " public void test() {\n"
+ " String o = super.<String> doStuff(\"\");\n"
+ " }\n"
+ "}";
java5.parse(code);
java7.parse(code);
}
@@ -266,10 +266,10 @@ public class ParserCornersTest extends BaseJavaTreeDumpTest {
@Test
public void testMethodReferenceConfused() {
ASTCompilationUnit ast = java.parseResource("MethodReferenceConfused.java", "10");
ASTVariableDeclaratorId someVarNameSameAsMethodReference = AstTestUtil.varId(ast, "someVarNameSameAsMethodReference");
ASTVariableDeclaratorId varWithMethodName = AstTestUtil.varId(ast, "method");
ASTVariableDeclaratorId someObject = AstTestUtil.varId(ast, "someObject");
assertThat(someVarNameSameAsMethodReference.getLocalUsages(), empty());
assertThat(varWithMethodName.getLocalUsages(), empty());
assertThat(someObject.getLocalUsages(), hasSize(1));
ASTNamedReferenceExpr usage = someObject.getLocalUsages().get(0);
assertThat(usage.getParent(), instanceOf(ASTCastExpression.class));
@@ -0,0 +1,25 @@
/**
*
* @see <a href="https://openjdk.java.net/jeps/325">JEP 325: Switch Expressions (Preview)</a>
*/
public class MultipleCaseLabels {
private static final int MONDAY = 1;
private static final int TUESDAY = 2;
private static final int WEDNESDAY = 3;
private static final int THURSDAY = 4;
private static final int FRIDAY = 5;
private static final int SATURDAY = 6;
private static final int SUNDAY = 7;
public static void main(String[] args) {
int day = THURSDAY;
switch (day) {
case MONDAY, FRIDAY, SUNDAY: System.out.println(" 6"); break;
case TUESDAY : System.out.println(" 7"); break;
case THURSDAY, SATURDAY : System.out.println(" 8"); break;
case WEDNESDAY : System.out.println(" 9"); break;
}
}
}
@@ -0,0 +1,113 @@
+- CompilationUnit[@PackageName = ""]
+- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "MultipleCaseLabels", @CanonicalName = "MultipleCaseLabels", @EffectiveVisibility = "public", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "false", @Record = "false", @RegularClass = "true", @RegularInterface = "false", @SimpleName = "MultipleCaseLabels", @TopLevel = "true", @Visibility = "public"]
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
+- ClassOrInterfaceBody[@Empty = "false", @Size = "8"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "MONDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "MONDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "1", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "1.0", @ValueAsFloat = "1.0", @ValueAsInt = "1", @ValueAsLong = "1"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "TUESDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "TUESDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "WEDNESDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "WEDNESDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "3", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "3.0", @ValueAsFloat = "3.0", @ValueAsInt = "3", @ValueAsLong = "3"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "THURSDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "THURSDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "4", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "4.0", @ValueAsFloat = "4.0", @ValueAsInt = "4", @ValueAsLong = "4"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "FRIDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "FRIDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "5", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "5.0", @ValueAsFloat = "5.0", @ValueAsInt = "5", @ValueAsLong = "5"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "SATURDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "SATURDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "6", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "6.0", @ValueAsFloat = "6.0", @ValueAsInt = "6", @ValueAsLong = "6"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "SUNDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "SUNDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "7", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "7.0", @ValueAsFloat = "7.0", @ValueAsInt = "7", @ValueAsLong = "7"]
+- MethodDeclaration[@Abstract = "false", @Arity = "1", @EffectiveVisibility = "public", @Image = "main", @MainMethod = "true", @Name = "main", @Overridden = "false", @Varargs = "false", @Visibility = "public", @Void = "true"]
+- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
+- VoidType[]
+- FormalParameters[@Empty = "false", @Size = "1"]
| +- FormalParameter[@EffectiveVisibility = "local", @Final = "false", @Varargs = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- ArrayType[@ArrayDepth = "1"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"]
| | +- ArrayDimensions[@Empty = "false", @Size = "1"]
| | +- ArrayTypeDim[@Varargs = "false"]
| +- VariableDeclaratorId[@ArrayType = "true", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @LambdaParameter = "false", @LocalVariable = "false", @Name = "args", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
+- Block[@Empty = "false", @Size = "2", @containsComment = "false"]
+- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "day"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "day", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- SwitchStatement[@DefaultCase = "false", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "true"]
+- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "day", @Name = "day", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- SwitchFallthroughBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ExpressionStatement[]
| | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| | +- ArgumentList[@Empty = "false", @Size = "1"]
| | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 6", @Empty = "false", @Image = "\" 6\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
| +- BreakStatement[@Label = null]
+- SwitchFallthroughBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ExpressionStatement[]
| | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| | +- ArgumentList[@Empty = "false", @Size = "1"]
| | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 7", @Empty = "false", @Image = "\" 7\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
| +- BreakStatement[@Label = null]
+- SwitchFallthroughBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ExpressionStatement[]
| | +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| | +- ArgumentList[@Empty = "false", @Size = "1"]
| | +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 8", @Empty = "false", @Image = "\" 8\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
| +- BreakStatement[@Label = null]
+- SwitchFallthroughBranch[@Default = "false"]
+- SwitchLabel[@Default = "false"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- ExpressionStatement[]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| +- ArgumentList[@Empty = "false", @Size = "1"]
| +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 9", @Empty = "false", @Image = "\" 9\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
+- BreakStatement[@Label = null]
@@ -0,0 +1,35 @@
/**
*
* @see <a href="https://openjdk.java.net/jeps/325">JEP 325: Switch Expressions (Preview)</a>
*/
public class SimpleSwitchExpressions {
private static final int MONDAY = 1;
private static final int TUESDAY = 2;
private static final int WEDNESDAY = 3;
private static final int THURSDAY = 4;
private static final int FRIDAY = 5;
private static final int SATURDAY = 6;
private static final int SUNDAY = 7;
public static void main(String[] args) {
int day = FRIDAY;
var numLetters = switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
case THURSDAY, SATURDAY -> 8;
case WEDNESDAY -> 9;
default -> {
int k = day * 2;
int result = f(k);
yield result;
}
};
System.out.printf("NumLetters: %d%n", numLetters);
}
private static int f(int k) {
return k*3;
}
}
@@ -0,0 +1,131 @@
+- CompilationUnit[@PackageName = ""]
+- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "SimpleSwitchExpressions", @CanonicalName = "SimpleSwitchExpressions", @EffectiveVisibility = "public", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "false", @Record = "false", @RegularClass = "true", @RegularInterface = "false", @SimpleName = "SimpleSwitchExpressions", @TopLevel = "true", @Visibility = "public"]
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
+- ClassOrInterfaceBody[@Empty = "false", @Size = "9"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "MONDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "MONDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "1", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "1.0", @ValueAsFloat = "1.0", @ValueAsInt = "1", @ValueAsLong = "1"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "TUESDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "TUESDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "WEDNESDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "WEDNESDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "3", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "3.0", @ValueAsFloat = "3.0", @ValueAsInt = "3", @ValueAsLong = "3"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "THURSDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "THURSDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "4", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "4.0", @ValueAsFloat = "4.0", @ValueAsInt = "4", @ValueAsLong = "4"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "FRIDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "FRIDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "5", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "5.0", @ValueAsFloat = "5.0", @ValueAsInt = "5", @ValueAsLong = "5"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "SATURDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "SATURDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "6", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "6.0", @ValueAsFloat = "6.0", @ValueAsInt = "6", @ValueAsLong = "6"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "SUNDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "SUNDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "7", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "7.0", @ValueAsFloat = "7.0", @ValueAsInt = "7", @ValueAsLong = "7"]
+- MethodDeclaration[@Abstract = "false", @Arity = "1", @EffectiveVisibility = "public", @Image = "main", @MainMethod = "true", @Name = "main", @Overridden = "false", @Varargs = "false", @Visibility = "public", @Void = "true"]
| +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
| +- VoidType[]
| +- FormalParameters[@Empty = "false", @Size = "1"]
| | +- FormalParameter[@EffectiveVisibility = "local", @Final = "false", @Varargs = "false", @Visibility = "local"]
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| | +- ArrayType[@ArrayDepth = "1"]
| | | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"]
| | | +- ArrayDimensions[@Empty = "false", @Size = "1"]
| | | +- ArrayTypeDim[@Varargs = "false"]
| | +- VariableDeclaratorId[@ArrayType = "true", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @LambdaParameter = "false", @LocalVariable = "false", @Name = "args", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
| +- Block[@Empty = "false", @Size = "3", @containsComment = "false"]
| +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"]
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| | +- PrimitiveType[@Kind = "int"]
| | +- VariableDeclarator[@Initializer = "true", @Name = "day"]
| | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "day", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "true", @Visibility = "local"]
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| | +- VariableDeclarator[@Initializer = "true", @Name = "numLetters"]
| | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "numLetters", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "true", @Visibility = "local"]
| | +- SwitchExpression[@CompileTimeConstant = "false", @DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "day", @Name = "day", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- SwitchArrowBranch[@Default = "false"]
| | | +- SwitchLabel[@Default = "false"]
| | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "6", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "6.0", @ValueAsFloat = "6.0", @ValueAsInt = "6", @ValueAsLong = "6"]
| | +- SwitchArrowBranch[@Default = "false"]
| | | +- SwitchLabel[@Default = "false"]
| | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "7", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "7.0", @ValueAsFloat = "7.0", @ValueAsInt = "7", @ValueAsLong = "7"]
| | +- SwitchArrowBranch[@Default = "false"]
| | | +- SwitchLabel[@Default = "false"]
| | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "8", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "8.0", @ValueAsFloat = "8.0", @ValueAsInt = "8", @ValueAsLong = "8"]
| | +- SwitchArrowBranch[@Default = "false"]
| | | +- SwitchLabel[@Default = "false"]
| | | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "9", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "9.0", @ValueAsFloat = "9.0", @ValueAsInt = "9", @ValueAsLong = "9"]
| | +- SwitchArrowBranch[@Default = "true"]
| | +- SwitchLabel[@Default = "true"]
| | +- Block[@Empty = "false", @Size = "3", @containsComment = "false"]
| | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"]
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| | | +- PrimitiveType[@Kind = "int"]
| | | +- VariableDeclarator[@Initializer = "true", @Name = "k"]
| | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "k", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
| | | +- InfixExpression[@CompileTimeConstant = "false", @Operator = "*", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "day", @Name = "day", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
| | +- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"]
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| | | +- PrimitiveType[@Kind = "int"]
| | | +- VariableDeclarator[@Initializer = "true", @Name = "result"]
| | | +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "result", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
| | | +- MethodCall[@CompileTimeConstant = "false", @Image = "f", @MethodName = "f", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | | +- ArgumentList[@Empty = "false", @Size = "1"]
| | | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "k", @Name = "k", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- YieldStatement[]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "result", @Name = "result", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ExpressionStatement[]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "printf", @MethodName = "printf", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| +- ArgumentList[@Empty = "false", @Size = "2"]
| +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = "NumLetters: %d%n", @Empty = "false", @Image = "\"NumLetters: %d%n\"", @Length = "16", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "numLetters", @Name = "numLetters", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- MethodDeclaration[@Abstract = "false", @Arity = "1", @EffectiveVisibility = "private", @Image = "f", @Name = "f", @Overridden = "false", @Varargs = "false", @Visibility = "private", @Void = "false"]
+- ModifierList[@EffectiveModifiers = "{private, static}", @ExplicitModifiers = "{private, static}"]
+- PrimitiveType[@Kind = "int"]
+- FormalParameters[@Empty = "false", @Size = "1"]
| +- FormalParameter[@EffectiveVisibility = "local", @Final = "false", @Varargs = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @LambdaParameter = "false", @LocalVariable = "false", @Name = "k", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
+- Block[@Empty = "false", @Size = "1", @containsComment = "false"]
+- ReturnStatement[]
+- InfixExpression[@CompileTimeConstant = "false", @Operator = "*", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "k", @Name = "k", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "3", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "3.0", @ValueAsFloat = "3.0", @ValueAsInt = "3", @ValueAsLong = "3"]
@@ -0,0 +1,90 @@
/**
* @see <a href="https://openjdk.java.net/jeps/361">JEP 361: Switch Expressions (Standard)</a>
*/
public class SwitchExpressions {
private enum Day {
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
}
public static final int BAZ = 3;
public static void main(String[] args) {
Day day = Day.THURSDAY;
// SwitchStatement
switch (day) {
case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
case TUESDAY -> System.out.println(7);
case THURSDAY, SATURDAY -> System.out.println(8);
case WEDNESDAY -> System.out.println(9);
}
// SwitchExpression
int numLetters = switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
case THURSDAY, SATURDAY -> 8;
case WEDNESDAY -> 9;
};
System.out.printf("numLetters=%d%n", numLetters);
howMany(1);
howMany(2);
howMany(3);
howManyExpr(1);
howManyExpr(2);
howManyExpr(3);
// SwitchExpression
int j = switch (day) {
case MONDAY -> 0;
case TUESDAY -> 1;
default -> {
int k = day.toString().length();
int result = f(k);
yield result;
}
};
System.out.printf("j=%d%n", j);
String s = "Foo";
// SwitchExpression
int result = switch (s) {
case "Foo":
yield 1;
case "Bar":
yield 2;
case "Baz":
yield SwitchExpressions.BAZ;
default:
System.out.println("Neither Foo nor Bar, hmmm...");
yield 0;
};
System.out.printf("result=%d%n", result);
}
private static void howMany(int k) {
// SwitchStatement
switch (k) {
case 1 -> System.out.println("one");
case 2 -> System.out.println("two");
default -> System.out.println("many");
}
}
private static void howManyExpr(int k) {
System.out.println(
// SwitchExpression
switch (k) {
case 1 -> "one";
case 2 -> "two";
default -> "many";
}
);
}
private static int f(int k) {
return k*2;
}
}
@@ -0,0 +1,25 @@
/**
*
* @see <a href="https://openjdk.java.net/jeps/325">JEP 325: Switch Expressions (Preview)</a>
*/
public class SwitchRules {
private static final int MONDAY = 1;
private static final int TUESDAY = 2;
private static final int WEDNESDAY = 3;
private static final int THURSDAY = 4;
private static final int FRIDAY = 5;
private static final int SATURDAY = 6;
private static final int SUNDAY = 7;
public static void main(String[] args) {
int day = WEDNESDAY;
switch (day) {
case MONDAY, FRIDAY, SUNDAY -> System.out.println(" 6");
case TUESDAY -> System.out.println(" 7");
case THURSDAY, SATURDAY -> System.out.println(" 8");
case WEDNESDAY -> { System.out.println(" 9"); }
default -> throw new IllegalArgumentException();
}
}
}
@@ -0,0 +1,113 @@
+- CompilationUnit[@PackageName = ""]
+- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "SwitchRules", @CanonicalName = "SwitchRules", @EffectiveVisibility = "public", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "false", @Record = "false", @RegularClass = "true", @RegularInterface = "false", @SimpleName = "SwitchRules", @TopLevel = "true", @Visibility = "public"]
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
+- ClassOrInterfaceBody[@Empty = "false", @Size = "8"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "MONDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "MONDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "1", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "1.0", @ValueAsFloat = "1.0", @ValueAsInt = "1", @ValueAsLong = "1"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "TUESDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "TUESDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "WEDNESDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "WEDNESDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "3", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "3.0", @ValueAsFloat = "3.0", @ValueAsInt = "3", @ValueAsLong = "3"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "THURSDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "THURSDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "4", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "4.0", @ValueAsFloat = "4.0", @ValueAsInt = "4", @ValueAsLong = "4"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "FRIDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "FRIDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "5", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "5.0", @ValueAsFloat = "5.0", @ValueAsInt = "5", @ValueAsLong = "5"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "SATURDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "SATURDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "6", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "6.0", @ValueAsFloat = "6.0", @ValueAsInt = "6", @ValueAsLong = "6"]
+- FieldDeclaration[@EffectiveVisibility = "private", @Visibility = "private"]
| +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "SUNDAY"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "private", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "true", @Final = "true", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "false", @Name = "SUNDAY", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "private"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "7", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "7.0", @ValueAsFloat = "7.0", @ValueAsInt = "7", @ValueAsLong = "7"]
+- MethodDeclaration[@Abstract = "false", @Arity = "1", @EffectiveVisibility = "public", @Image = "main", @MainMethod = "true", @Name = "main", @Overridden = "false", @Varargs = "false", @Visibility = "public", @Void = "true"]
+- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
+- VoidType[]
+- FormalParameters[@Empty = "false", @Size = "1"]
| +- FormalParameter[@EffectiveVisibility = "local", @Final = "false", @Varargs = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- ArrayType[@ArrayDepth = "1"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"]
| | +- ArrayDimensions[@Empty = "false", @Size = "1"]
| | +- ArrayTypeDim[@Varargs = "false"]
| +- VariableDeclaratorId[@ArrayType = "true", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "true", @LambdaParameter = "false", @LocalVariable = "false", @Name = "args", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
+- Block[@Empty = "false", @Size = "2", @containsComment = "false"]
+- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "day"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "day", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- SwitchStatement[@DefaultCase = "true", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false"]
+- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "day", @Name = "day", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- SwitchArrowBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| +- ArgumentList[@Empty = "false", @Size = "1"]
| +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 6", @Empty = "false", @Image = "\" 6\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
+- SwitchArrowBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| +- ArgumentList[@Empty = "false", @Size = "1"]
| +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 7", @Empty = "false", @Image = "\" 7\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
+- SwitchArrowBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| +- ArgumentList[@Empty = "false", @Size = "1"]
| +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 8", @Empty = "false", @Image = "\" 8\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
+- SwitchArrowBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "true", @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- Block[@Empty = "false", @Size = "1", @containsComment = "false"]
| +- ExpressionStatement[]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "println", @MethodName = "println", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- FieldAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "out", @Name = "out", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- TypeExpression[@CompileTimeConstant = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| | +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "System"]
| +- ArgumentList[@Empty = "false", @Size = "1"]
| +- StringLiteral[@CompileTimeConstant = "true", @ConstValue = " 9", @Empty = "false", @Image = "\" 9\"", @Length = "3", @ParenthesisDepth = "0", @Parenthesized = "false", @TextBlock = "false"]
+- SwitchArrowBranch[@Default = "true"]
+- SwitchLabel[@Default = "true"]
+- ThrowStatement[]
+- ConstructorCall[@AnonymousClass = "false", @CompileTimeConstant = "false", @DiamondTypeArgs = "false", @MethodName = "new", @ParenthesisDepth = "0", @Parenthesized = "false", @QualifiedInstanceCreation = "false"]
+- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "IllegalArgumentException"]
+- ArgumentList[@Empty = "true", @Size = "0"]
@@ -0,0 +1,113 @@
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
/**
* @see <a href="https://openjdk.java.net/jeps/368">JEP 368: Text Blocks (Second Preview)</a>
*/
public class TextBlocks {
public static void main(String[] args) throws Exception {
// note: there is trailing whitespace!!
String html = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";
System.out.println(html);
String query = """
SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB`
WHERE `CITY` = 'INDIANAPOLIS'
ORDER BY `EMP_ID`, `LAST_NAME`;
""";
System.out.println(query);
ScriptEngine engine = new ScriptEngineManager().getEngineByName("js");
Object obj = engine.eval("""
function hello() {
print('"Hello, world"');
}
hello();
""");
// Escape sequences
String htmlWithEscapes = """
<html>\r
<body>\r
<p>Hello, world</p>\r
</body>\r
</html>\r
""";
System.out.println(htmlWithEscapes);
String season = """
winter"""; // the six characters w i n t e r
String period = """
winter
"""; // the seven characters w i n t e r LF
String greeting =
"""
Hi, "Bob"
"""; // the ten characters H i , SP " B o b " LF
String salutation =
"""
Hi,
"Bob"
"""; // the eleven characters H i , LF SP " B o b " LF
String empty = """
"""; // the empty string (zero length)
String quote = """
"
"""; // the two characters " LF
String backslash = """
\\
"""; // the two characters \ LF
String normalStringLiteral = "test";
String code =
"""
String text = \"""
A text block inside a text block
\""";
""";
// new escape sequences
String text = """
Lorem ipsum dolor sit amet, consectetur adipiscing \
elit, sed do eiusmod tempor incididunt ut labore \
et dolore magna aliqua.\
""";
System.out.println(text);
String colors = """
red \s
green\s
blue \s
""";
System.out.println(colors);
// empty new line as first content
String emptyLine = """
test
""";
System.out.println(emptyLine.replaceAll("\n", "<LF>"));
// backslash escapes
String bs = """
\\test
""";
System.out.println(bs.replaceAll("\n", "<LF>"));
}
}
@@ -0,0 +1,83 @@
+- CompilationUnit[@PackageName = ""]
+- ClassOrInterfaceDeclaration[@Abstract = "false", @Annotation = "false", @Anonymous = "false", @BinaryName = "YieldStatements", @CanonicalName = "YieldStatements", @EffectiveVisibility = "public", @Enum = "false", @Final = "false", @Interface = "false", @Local = "false", @Nested = "false", @PackageName = "", @PackagePrivate = "false", @Record = "false", @RegularClass = "true", @RegularInterface = "false", @SimpleName = "YieldStatements", @TopLevel = "true", @Visibility = "public"]
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
+- ClassOrInterfaceBody[@Empty = "false", @Size = "1"]
+- Initializer[@Static = "false"]
+- Block[@Empty = "false", @Size = "5", @containsComment = "false"]
+- LocalVariableDeclaration[@EffectiveVisibility = "local", @Final = "false", @TypeInferred = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- PrimitiveType[@Kind = "int"]
| +- VariableDeclarator[@Initializer = "true", @Name = "yield"]
| +- VariableDeclaratorId[@ArrayType = "false", @EffectiveVisibility = "local", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @Final = "false", @ForLoopVariable = "false", @ForeachVariable = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "yield", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "local"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "0", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "0.0", @ValueAsFloat = "0.0", @ValueAsInt = "0", @ValueAsLong = "0"]
+- ExpressionStatement[]
| +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "yield", @Name = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
+- ExpressionStatement[]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "yield", @MethodName = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ArgumentList[@Empty = "false", @Size = "1"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
+- ExpressionStatement[]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "yield", @MethodName = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ArgumentList[@Empty = "false", @Size = "2"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "a", @Name = "a", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "b", @Name = "b", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- ExpressionStatement[]
+- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "yield", @Name = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- SwitchExpression[@CompileTimeConstant = "false", @DefaultCase = "false", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "e", @Name = "e", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- SwitchArrowBranch[@Default = "false"]
+- SwitchLabel[@Default = "false"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "1", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "1.0", @ValueAsFloat = "1.0", @ValueAsInt = "1", @ValueAsLong = "1"]
+- Block[@Empty = "false", @Size = "12", @containsComment = "true"]
+- ExpressionStatement[]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "yield", @MethodName = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ArgumentList[@Empty = "false", @Size = "2"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "a", @Name = "a", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "b", @Name = "b", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- ExpressionStatement[]
| +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "yield", @Name = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
+- YieldStatement[]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "1", @Parenthesized = "true", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
+- YieldStatement[]
| +- UnaryExpression[@CompileTimeConstant = "false", @Operator = "++", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "bar", @Name = "bar", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- YieldStatement[]
| +- UnaryExpression[@CompileTimeConstant = "false", @Operator = "--", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "bar", @Name = "bar", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- ExpressionStatement[]
| +- UnaryExpression[@CompileTimeConstant = "false", @Operator = "++", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "yield", @Name = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- ExpressionStatement[]
| +- UnaryExpression[@CompileTimeConstant = "false", @Operator = "--", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "yield", @Name = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- IfStatement[@Else = "true"]
| +- BooleanLiteral[@CompileTimeConstant = "true", @ParenthesisDepth = "0", @Parenthesized = "false", @True = "true"]
| +- YieldStatement[]
| | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "1", @Parenthesized = "true", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]
| +- YieldStatement[]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "4", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "4.0", @ValueAsFloat = "4.0", @ValueAsInt = "4", @ValueAsLong = "4"]
+- ExpressionStatement[]
| +- AssignmentExpression[@CompileTimeConstant = "false", @Compound = "false", @Operator = "=", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "WRITE", @CompileTimeConstant = "false", @Image = "yield", @Name = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- SwitchExpression[@CompileTimeConstant = "false", @DefaultCase = "false", @EnumSwitch = "false", @ExhaustiveEnumSwitch = "false", @FallthroughSwitch = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "foo", @Name = "foo", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- SwitchArrowBranch[@Default = "false"]
| +- SwitchLabel[@Default = "false"]
| | +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "4", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "0", @Parenthesized = "false", @ValueAsDouble = "4.0", @ValueAsFloat = "4.0", @ValueAsInt = "4", @ValueAsLong = "4"]
| +- Block[@Empty = "false", @Size = "1", @containsComment = "false"]
| +- YieldStatement[]
| +- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "5", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "1", @Parenthesized = "true", @ValueAsDouble = "5.0", @ValueAsFloat = "5.0", @ValueAsInt = "5", @ValueAsLong = "5"]
+- YieldStatement[]
| +- LambdaExpression[@BlockBody = "true", @CompileTimeConstant = "false", @ExpressionBody = "false", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- LambdaParameterList[@Empty = "true", @Size = "0"]
| +- Block[@Empty = "true", @Size = "0", @containsComment = "false"]
+- ExpressionStatement[]
| +- MethodCall[@CompileTimeConstant = "false", @Image = "yield", @MethodName = "yield", @ParenthesisDepth = "0", @Parenthesized = "false"]
| +- ArgumentList[@Empty = "true", @Size = "0"]
+- YieldStatement[]
+- NumericLiteral[@Base = "10", @CompileTimeConstant = "true", @DoubleLiteral = "false", @FloatLiteral = "false", @Image = "2", @IntLiteral = "true", @Integral = "true", @LongLiteral = "false", @ParenthesisDepth = "1", @Parenthesized = "true", @ValueAsDouble = "2.0", @ValueAsFloat = "2.0", @ValueAsInt = "2", @ValueAsLong = "2"]