forked from phoedos/pmd
[java] Remove java language version 20-preview
This commit is contained in:
parent
c4620635ee
commit
2a53ebaa55
@ -19,7 +19,6 @@ Usually the latest non-preview Java Version is the default version.
|
||||
| 22 (default) | | 7.0.0 |
|
||||
| 21-preview | | 7.0.0 |
|
||||
| 21 | | 7.0.0 |
|
||||
| 20-preview | | 6.55.0 |
|
||||
| 20 | | 6.55.0 |
|
||||
| 19 | | 6.48.0 |
|
||||
| 18 | | 6.44.0 |
|
||||
|
@ -232,6 +232,10 @@ The rules have been moved into categories with PMD 6.
|
||||
|
||||
#### API Changes
|
||||
|
||||
**pmd-java**
|
||||
|
||||
* Support for Java 20 preview language features have been removed. The version "20-preview" is no longer available.
|
||||
|
||||
**New API**
|
||||
|
||||
The API around {%jdoc core::util.treeexport.TreeRenderer %} has been declared as stable. It was previously
|
||||
|
@ -49,7 +49,7 @@ class BinaryDistributionIT extends AbstractBinaryDistributionTest {
|
||||
"java-1.6", "java-1.7", "java-1.8", "java-1.9", "java-10",
|
||||
"java-11", "java-12", "java-13", "java-14", "java-15",
|
||||
"java-16", "java-17", "java-18", "java-19",
|
||||
"java-20", "java-20-preview",
|
||||
"java-20",
|
||||
"java-21", "java-21-preview",
|
||||
"java-22", "java-22-preview",
|
||||
"java-5", "java-6", "java-7",
|
||||
|
@ -42,7 +42,6 @@ public class JavaLanguageModule extends LanguageModuleBase implements PmdCapable
|
||||
.addVersion("18")
|
||||
.addVersion("19")
|
||||
.addVersion("20")
|
||||
.addVersion("20-preview")
|
||||
.addVersion("21")
|
||||
.addVersion("21-preview")
|
||||
.addDefaultVersion("22") // 22 is the default
|
||||
|
@ -37,7 +37,6 @@ class LanguageVersionTest extends AbstractLanguageVersionTest {
|
||||
new TestDescriptor(java, "18"),
|
||||
new TestDescriptor(java, "19"),
|
||||
new TestDescriptor(java, "20"),
|
||||
new TestDescriptor(java, "20-preview"),
|
||||
new TestDescriptor(java, "21"),
|
||||
new TestDescriptor(java, "21-preview"),
|
||||
new TestDescriptor(java, "22"),
|
||||
@ -48,7 +47,7 @@ class LanguageVersionTest extends AbstractLanguageVersionTest {
|
||||
// this one won't be found: case-sensitive!
|
||||
versionDoesNotExist("JAVA", "JAVA", "1.7"),
|
||||
// not supported anymore
|
||||
versionDoesNotExist(java, "19-preview")
|
||||
versionDoesNotExist(java, "20-preview")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import org.junit.platform.suite.api.Suite;
|
||||
Java15TreeDumpTest.class,
|
||||
Java16TreeDumpTest.class,
|
||||
Java17TreeDumpTest.class,
|
||||
Java20PreviewTreeDumpTest.class,
|
||||
Java21TreeDumpTest.class,
|
||||
Java21PreviewTreeDumpTest.class
|
||||
})
|
||||
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
|
||||
class Java20PreviewTreeDumpTest extends BaseJavaTreeDumpTest {
|
||||
private final JavaParsingHelper java20p =
|
||||
JavaParsingHelper.DEFAULT.withDefaultVersion("20-preview")
|
||||
.withResourceContext(Java20PreviewTreeDumpTest.class, "jdkversiontests/java20p/");
|
||||
private final JavaParsingHelper java20 = java20p.withDefaultVersion("20");
|
||||
|
||||
@Override
|
||||
public BaseParsingHelper<?, ?> getParser() {
|
||||
return java20p;
|
||||
}
|
||||
|
||||
@Test
|
||||
void dealingWithNullBeforeJava20Preview() {
|
||||
ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("DealingWithNull.java"));
|
||||
assertTrue(thrown.getMessage().contains("Null in switch cases is a preview feature of JDK 20, you should select your language version accordingly"),
|
||||
"Unexpected message: " + thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void dealingWithNull() {
|
||||
doTest("DealingWithNull");
|
||||
}
|
||||
|
||||
@Test
|
||||
void enhancedTypeCheckingSwitch() {
|
||||
doTest("EnhancedTypeCheckingSwitch");
|
||||
}
|
||||
|
||||
@Test
|
||||
void exhaustiveSwitch() {
|
||||
doTest("ExhaustiveSwitch");
|
||||
}
|
||||
|
||||
@Test
|
||||
void guardedAndParenthesizedPatternsBeforeJava20Preview() {
|
||||
ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("GuardedAndParenthesizedPatterns.java"));
|
||||
assertTrue(thrown.getMessage().contains("Patterns in switch statements is a preview feature of JDK 20, you should select your language version accordingly"),
|
||||
"Unexpected message: " + thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void guardedAndParenthesizedPatterns() {
|
||||
doTest("GuardedAndParenthesizedPatterns");
|
||||
}
|
||||
|
||||
@Test
|
||||
void patternsInSwitchLabelsBeforeJava20Preview() {
|
||||
ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("PatternsInSwitchLabels.java"));
|
||||
assertTrue(thrown.getMessage().contains("Patterns in switch statements is a preview feature of JDK 20, you should select your language version accordingly"),
|
||||
"Unexpected message: " + thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void patternsInSwitchLabels() {
|
||||
doTest("PatternsInSwitchLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void refiningPatternsInSwitch() {
|
||||
doTest("RefiningPatternsInSwitch");
|
||||
}
|
||||
|
||||
@Test
|
||||
void scopeOfPatternVariableDeclarations() {
|
||||
doTest("ScopeOfPatternVariableDeclarations");
|
||||
}
|
||||
|
||||
@Test
|
||||
void recordPatterns() {
|
||||
doTest("RecordPatterns");
|
||||
}
|
||||
|
||||
@Test
|
||||
void recordPatternsBeforeJava20Preview() {
|
||||
ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("RecordPatterns.java"));
|
||||
assertTrue(thrown.getMessage().contains("Record patterns is a preview feature of JDK 20, you should select your language version accordingly"),
|
||||
"Unexpected message: " + thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void recordPatternsInEnhancedFor() {
|
||||
doTest("RecordPatternsInEnhancedFor");
|
||||
}
|
||||
|
||||
@Test
|
||||
void recordPatternsInEnhancedForBeforeJava20Preview() {
|
||||
ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("RecordPatternsInEnhancedFor.java"));
|
||||
assertTrue(thrown.getMessage().contains("Deconstruction patterns in enhanced for statement is a preview feature of JDK 20, you should select your language version accordingly"),
|
||||
"Unexpected message: " + thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void recordPatternsExhaustiveSwitch() {
|
||||
doTest("RecordPatternsExhaustiveSwitch");
|
||||
}
|
||||
}
|
@ -23,12 +23,12 @@ class DataflowPassTest extends BaseParserTest {
|
||||
void testSimple() {
|
||||
|
||||
ASTCompilationUnit ast = java.parseResource(
|
||||
"/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.java",
|
||||
"20-preview"
|
||||
"/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.java",
|
||||
"21"
|
||||
);
|
||||
|
||||
DataflowResult dataflow = DataflowPass.getDataflowResult(ast);
|
||||
assertThat(dataflow.getUnusedAssignments(), Matchers.hasSize(2));
|
||||
assertThat(dataflow.getUnusedAssignments(), Matchers.hasSize(0));
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ enum class JavaVersion : Comparable<JavaVersion> {
|
||||
J17,
|
||||
J18,
|
||||
J19,
|
||||
J20, J20__PREVIEW,
|
||||
J20,
|
||||
J21, J21__PREVIEW,
|
||||
J22, J22__PREVIEW;
|
||||
|
||||
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/433">JEP 433: Pattern Matching for switch (Fourth Preview)</a>
|
||||
*/
|
||||
public class DealingWithNull {
|
||||
|
||||
static void testFooBar(String s) {
|
||||
switch (s) {
|
||||
case null -> System.out.println("Oops");
|
||||
case "Foo", "Bar" -> System.out.println("Great"); // CaseConstant
|
||||
default -> System.out.println("Ok");
|
||||
}
|
||||
}
|
||||
|
||||
static void testStringOrNull(Object o) {
|
||||
switch (o) {
|
||||
case String s -> System.out.println("String: " + s); // CasePattern
|
||||
case null -> System.out.println("null");
|
||||
default -> System.out.println("default case");
|
||||
}
|
||||
}
|
||||
|
||||
static void testStringOrDefaultNull(Object o) {
|
||||
switch (o) {
|
||||
case String s -> System.out.println("String: " + s);
|
||||
case null, default -> System.out.println("null or default case");
|
||||
}
|
||||
}
|
||||
|
||||
static void test2(Object o) {
|
||||
switch (o) {
|
||||
case null -> throw new NullPointerException();
|
||||
case String s -> System.out.println("String: "+s);
|
||||
case Integer i -> System.out.println("Integer");
|
||||
default -> System.out.println("default");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void test3(Object o) {
|
||||
switch(o) {
|
||||
case null:
|
||||
System.out.println("null");
|
||||
break; // note: fall-through to a CasePattern is not allowed, as the pattern variable is not initialized
|
||||
case String s:
|
||||
System.out.println("String");
|
||||
break;
|
||||
default:
|
||||
System.out.println("default case");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(o) {
|
||||
case null -> System.out.println("null");
|
||||
case String s -> System.out.println("String");
|
||||
default -> System.out.println("default case");
|
||||
}
|
||||
|
||||
switch(o) {
|
||||
case null: default:
|
||||
System.out.println("The rest (including null)");
|
||||
}
|
||||
|
||||
switch(o) {
|
||||
case null, default ->
|
||||
System.out.println("The rest (including null)");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
testStringOrDefaultNull("test");
|
||||
test2(2);
|
||||
try {
|
||||
test2(null);
|
||||
} catch (NullPointerException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
test3(3);
|
||||
test3("test");
|
||||
test3(null);
|
||||
|
||||
testFooBar(null);
|
||||
testFooBar("Foo");
|
||||
testFooBar("Bar");
|
||||
testFooBar("baz");
|
||||
|
||||
testStringOrNull(null);
|
||||
testStringOrNull("some string");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/433">JEP 433: Pattern Matching for switch (Fourth Preview)</a>
|
||||
*/
|
||||
public class EnhancedTypeCheckingSwitch {
|
||||
|
||||
|
||||
static void typeTester(Object o) {
|
||||
switch (o) {
|
||||
case null -> System.out.println("null");
|
||||
case String s -> System.out.println("String");
|
||||
case Color c -> System.out.println("Color with " + c.values().length + " values");
|
||||
case Point p -> System.out.println("Record class: " + p.toString());
|
||||
case int[] ia -> System.out.println("Array of ints of length " + ia.length);
|
||||
default -> System.out.println("Something else");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Object o = "test";
|
||||
typeTester(o);
|
||||
typeTester(Color.BLUE);
|
||||
|
||||
o = new int[] {1, 2, 3, 4};
|
||||
typeTester(o);
|
||||
|
||||
o = new Point(7, 8);
|
||||
typeTester(o);
|
||||
|
||||
o = new Object();
|
||||
typeTester(o);
|
||||
}
|
||||
}
|
||||
|
||||
record Point(int i, int j) {}
|
||||
enum Color { RED, GREEN, BLUE; }
|
@ -1,188 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = ""]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "EnhancedTypeCheckingSwitch", @CanonicalName = "EnhancedTypeCheckingSwitch", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "EnhancedTypeCheckingSwitch", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC]
|
||||
| +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
|
||||
| +- ClassBody[@Empty = false, @Size = 2]
|
||||
| +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "typeTester", @Name = "typeTester", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| | +- VoidType[]
|
||||
| | +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- SwitchArrowBranch[@Default = false]
|
||||
| | | +- SwitchLabel[@Default = false]
|
||||
| | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "null", @Empty = false, @Image = "\"null\"", @Length = 4, @LiteralText = "\"null\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- SwitchArrowBranch[@Default = false]
|
||||
| | | +- SwitchLabel[@Default = false]
|
||||
| | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String", @Empty = false, @Image = "\"String\"", @Length = 6, @LiteralText = "\"String\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- SwitchArrowBranch[@Default = false]
|
||||
| | | +- SwitchLabel[@Default = false]
|
||||
| | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "Color"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Color with ", @Empty = false, @Image = "\"Color with \"", @Length = 11, @LiteralText = "\"Color with \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "length", @Name = "length", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- MethodCall[@CompileTimeConstant = false, @Image = "values", @MethodName = "values", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " values", @Empty = false, @Image = "\" values\"", @Length = 7, @LiteralText = "\" values\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- SwitchArrowBranch[@Default = false]
|
||||
| | | +- SwitchLabel[@Default = false]
|
||||
| | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "p", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Record class: ", @Empty = false, @Image = "\"Record class: \"", @Length = 14, @LiteralText = "\"Record class: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "toString", @MethodName = "toString", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | +- SwitchArrowBranch[@Default = false]
|
||||
| | | +- SwitchLabel[@Default = false]
|
||||
| | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ArrayType[@ArrayDepth = 1]
|
||||
| | | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | | | | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | | | | +- ArrayTypeDim[@Varargs = false]
|
||||
| | | | +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "ia", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Array of ints of length ", @Empty = false, @Image = "\"Array of ints of length \"", @Length = 24, @LiteralText = "\"Array of ints of length \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "length", @Name = "length", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "ia", @Name = "ia", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- SwitchArrowBranch[@Default = true]
|
||||
| | +- SwitchLabel[@Default = true]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Something else", @Empty = false, @Image = "\"Something else\"", @Length = 14, @LiteralText = "\"Something else\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PUBLIC, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ArrayType[@ArrayDepth = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | | +- ArrayTypeDim[@Varargs = false]
|
||||
| | +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_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 = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 9, @containsComment = false]
|
||||
| +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | +- VariableDeclarator[@Initializer = true, @Name = "o"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "test", @Empty = false, @Image = "\"test\"", @Length = 4, @LiteralText = "\"test\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- ExpressionStatement[]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "typeTester", @MethodName = "typeTester", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ExpressionStatement[]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "typeTester", @MethodName = "typeTester", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "BLUE", @Name = "BLUE", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Color"]
|
||||
| +- ExpressionStatement[]
|
||||
| | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArrayAllocation[@ArrayDepth = 1, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArrayType[@ArrayDepth = 1]
|
||||
| | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | | +- ArrayTypeDim[@Varargs = false]
|
||||
| | +- ArrayInitializer[@CompileTimeConstant = false, @Length = 4, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1]
|
||||
| | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "2", @IntLiteral = true, @Integral = true, @LiteralText = "2", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 2.0, @ValueAsFloat = 2.0, @ValueAsInt = 2, @ValueAsLong = 2]
|
||||
| | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "3", @IntLiteral = true, @Integral = true, @LiteralText = "3", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 3.0, @ValueAsFloat = 3.0, @ValueAsInt = 3, @ValueAsLong = 3]
|
||||
| | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "4", @IntLiteral = true, @Integral = true, @LiteralText = "4", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 4.0, @ValueAsFloat = 4.0, @ValueAsInt = 4, @ValueAsLong = 4]
|
||||
| +- ExpressionStatement[]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "typeTester", @MethodName = "typeTester", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ExpressionStatement[]
|
||||
| | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Point"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 2]
|
||||
| | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "7", @IntLiteral = true, @Integral = true, @LiteralText = "7", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.0, @ValueAsFloat = 7.0, @ValueAsInt = 7, @ValueAsLong = 7]
|
||||
| | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "8", @IntLiteral = true, @Integral = true, @LiteralText = "8", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 8.0, @ValueAsFloat = 8.0, @ValueAsInt = 8, @ValueAsLong = 8]
|
||||
| +- ExpressionStatement[]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "typeTester", @MethodName = "typeTester", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ExpressionStatement[]
|
||||
| | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| +- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "typeTester", @MethodName = "typeTester", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Point", @CanonicalName = "Point", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Point", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{}"]
|
||||
| +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "j", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| +- RecordBody[@Empty = true, @Size = 0]
|
||||
+- EnumDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Color", @CanonicalName = "Color", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = true, @Final = true, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = false, @RegularInterface = false, @SimpleName = "Color", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PACKAGE]
|
||||
+- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{}"]
|
||||
+- EnumBody[@Empty = false, @SeparatorSemi = true, @Size = 3, @TrailingComma = false]
|
||||
+- EnumConstant[@AnonymousClass = false, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "RED", @MethodName = "new", @Name = "RED", @Visibility = Visibility.V_PUBLIC]
|
||||
| +- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = true, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "RED", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- EnumConstant[@AnonymousClass = false, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "GREEN", @MethodName = "new", @Name = "GREEN", @Visibility = Visibility.V_PUBLIC]
|
||||
| +- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = true, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "GREEN", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- EnumConstant[@AnonymousClass = false, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "BLUE", @MethodName = "new", @Name = "BLUE", @Visibility = Visibility.V_PUBLIC]
|
||||
+- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{}"]
|
||||
+- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = true, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "BLUE", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_PUBLIC]
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/433">JEP 433: Pattern Matching for switch (Fourth Preview)</a>
|
||||
*/
|
||||
public class ExhaustiveSwitch {
|
||||
|
||||
static int coverage(Object o) {
|
||||
return switch (o) {
|
||||
case String s -> s.length();
|
||||
case Integer i -> i;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
static void coverageStatement(Object o) {
|
||||
switch (o) {
|
||||
case String s:
|
||||
System.out.println(s);
|
||||
break;
|
||||
case Integer i:
|
||||
System.out.println("Integer");
|
||||
break;
|
||||
default: // Now exhaustive!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface S permits A, B, C {}
|
||||
final static class A implements S {}
|
||||
final static class B implements S {}
|
||||
record C(int i) implements S {} // Implicitly final
|
||||
|
||||
static int testSealedExhaustive(S s) {
|
||||
return switch (s) {
|
||||
case A a -> 1;
|
||||
case B b -> 2;
|
||||
case C c -> 3;
|
||||
};
|
||||
}
|
||||
|
||||
static void switchStatementExhaustive(S s) {
|
||||
switch (s) {
|
||||
case A a :
|
||||
System.out.println("A");
|
||||
break;
|
||||
case C c :
|
||||
System.out.println("C");
|
||||
break;
|
||||
default:
|
||||
System.out.println("default case, should be B");
|
||||
break;
|
||||
};
|
||||
}
|
||||
sealed interface I<T> permits E, F {}
|
||||
final static class E<X> implements I<String> {}
|
||||
final static class F<Y> implements I<Y> {}
|
||||
|
||||
static int testGenericSealedExhaustive(I<Integer> i) {
|
||||
return switch (i) {
|
||||
// Exhaustive as no E case possible!
|
||||
case F<Integer> bi -> 42;
|
||||
};
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(coverage("a string"));
|
||||
System.out.println(coverage(42));
|
||||
System.out.println(coverage(new Object()));
|
||||
|
||||
coverageStatement("a string");
|
||||
coverageStatement(21);
|
||||
coverageStatement(new Object());
|
||||
|
||||
System.out.println("A:" + testSealedExhaustive(new A()));
|
||||
System.out.println("B:" + testSealedExhaustive(new B()));
|
||||
System.out.println("C:" + testSealedExhaustive(new C(1)));
|
||||
|
||||
switchStatementExhaustive(new A());
|
||||
switchStatementExhaustive(new B());
|
||||
switchStatementExhaustive(new C(2));
|
||||
|
||||
System.out.println("F:" + testGenericSealedExhaustive(new F<Integer>()));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/433">JEP 433: Pattern Matching for switch (Fourth Preview)</a>
|
||||
*/
|
||||
public class GuardedAndParenthesizedPatterns {
|
||||
|
||||
|
||||
static void test(Object o) {
|
||||
switch (o) {
|
||||
case String s when s.length() == 1 -> System.out.println("single char string");
|
||||
case String s -> System.out.println("string");
|
||||
case Integer i when i.intValue() == 1 -> System.out.println("integer 1");
|
||||
case (Long l) when l.longValue() == 1L -> System.out.println("long 1 with parens");
|
||||
case (((Double d))) -> System.out.println("double with parens");
|
||||
default -> System.out.println("default case");
|
||||
}
|
||||
}
|
||||
|
||||
// verify that "when" can still be used as an identifier -> formal parameter
|
||||
void testIdentifierWhen(String when) {
|
||||
System.out.println(when);
|
||||
}
|
||||
|
||||
// verify that "when" can still be used as an identifier -> local variable
|
||||
void testIdentifierWhen() {
|
||||
int when = 1;
|
||||
System.out.println(when);
|
||||
}
|
||||
|
||||
// verify that "when" can still be used as a type name
|
||||
private static class when {}
|
||||
|
||||
static void testWithNull(Object o) {
|
||||
switch (o) {
|
||||
case String s when (s.length() == 1) -> System.out.println("single char string");
|
||||
case String s -> System.out.println("string");
|
||||
case (Integer i) when i.intValue() == 1 -> System.out.println("integer 1");
|
||||
case ((Long l)) when ((l.longValue() == 1L)) -> System.out.println("long 1 with parens");
|
||||
case (((Double d))) -> System.out.println("double with parens");
|
||||
case null -> System.out.println("null!");
|
||||
default -> System.out.println("default case");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void instanceOfPattern(Object o) {
|
||||
if (o instanceof String s && s.length() > 2) {
|
||||
System.out.println("A string containing at least two characters");
|
||||
}
|
||||
if (o != null && (o instanceof String s && s.length() > 3)) {
|
||||
System.out.println("A string containing at least three characters");
|
||||
}
|
||||
|
||||
// note: with this 3rd preview, the following is not allowed anymore:
|
||||
// if (o instanceof (String s && s.length() > 4)) {
|
||||
// > An alternative to guarded pattern labels is to support guarded patterns directly as a special pattern form,
|
||||
// > e.g. p && e. Having experimented with this in previous previews, the resulting ambiguity with boolean
|
||||
// > expressions have lead us to prefer when clauses in pattern switches.
|
||||
if ((o instanceof String s) && (s.length() > 4)) {
|
||||
System.out.println("A string containing at least four characters");
|
||||
}
|
||||
}
|
||||
|
||||
static void testScopeOfPatternVariableDeclarations(Object obj) {
|
||||
if ((obj instanceof String s) && s.length() > 3) {
|
||||
System.out.println(s);
|
||||
} else {
|
||||
System.out.println("Not a string");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
test("a");
|
||||
test("fooo");
|
||||
test(1);
|
||||
test(1L);
|
||||
instanceOfPattern("abcde");
|
||||
try {
|
||||
test(null); // throws NPE
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
testWithNull(null);
|
||||
testScopeOfPatternVariableDeclarations("a");
|
||||
testScopeOfPatternVariableDeclarations("long enough");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/433">JEP 433: Pattern Matching for switch (Fourth Preview)</a>
|
||||
*/
|
||||
public class PatternsInSwitchLabels {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Object o = 123L;
|
||||
String formatted = switch (o) {
|
||||
case Integer i -> String.format("int %d", i);
|
||||
case Long l -> String.format("long %d", l);
|
||||
case Double d -> String.format("double %f", d);
|
||||
case String s -> String.format("String %s", s);
|
||||
default -> o.toString();
|
||||
};
|
||||
System.out.println(formatted);
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = ""]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "PatternsInSwitchLabels", @CanonicalName = "PatternsInSwitchLabels", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "PatternsInSwitchLabels", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
|
||||
+- ClassBody[@Empty = false, @Size = 1]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PUBLIC, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true]
|
||||
+- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
|
||||
+- VoidType[]
|
||||
+- FormalParameters[@Empty = false, @Size = 1]
|
||||
| +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ArrayType[@ArrayDepth = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | +- ArrayTypeDim[@Varargs = false]
|
||||
| +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_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 = Visibility.V_LOCAL]
|
||||
+- Block[@Empty = false, @Size = 3, @containsComment = false]
|
||||
+- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "o"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "123L", @IntLiteral = false, @Integral = true, @LiteralText = "123L", @LongLiteral = true, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 123.0, @ValueAsFloat = 123.0, @ValueAsInt = 123, @ValueAsLong = 123]
|
||||
+- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "formatted"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "formatted", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Integer"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "format", @MethodName = "format", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 2]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "int %d", @Empty = false, @Image = "\"int %d\"", @Length = 6, @LiteralText = "\"int %d\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Long"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "l", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "format", @MethodName = "format", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 2]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "long %d", @Empty = false, @Image = "\"long %d\"", @Length = 7, @LiteralText = "\"long %d\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "l", @Name = "l", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Double"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "d", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "format", @MethodName = "format", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 2]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "double %f", @Empty = false, @Image = "\"double %f\"", @Length = 9, @LiteralText = "\"double %f\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "d", @Name = "d", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "format", @MethodName = "format", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 2]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String %s", @Empty = false, @Image = "\"String %s\"", @Length = 9, @LiteralText = "\"String %s\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = true]
|
||||
| +- SwitchLabel[@Default = true]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "toString", @MethodName = "toString", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = true, @Size = 0]
|
||||
+- ExpressionStatement[]
|
||||
+- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
+- ArgumentList[@Empty = false, @Size = 1]
|
||||
+- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "formatted", @Name = "formatted", @ParenthesisDepth = 0, @Parenthesized = false]
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/432">JEP 432: Record Patterns (Second Preview)</a>
|
||||
*/
|
||||
public class RecordPatterns {
|
||||
|
||||
record Point(int x, int y) {}
|
||||
enum Color { RED, GREEN, BLUE }
|
||||
record ColoredPoint(Point p, Color c) {}
|
||||
record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) {}
|
||||
|
||||
void printSum1(Object o) {
|
||||
if (o instanceof Point p) {
|
||||
int x = p.x();
|
||||
int y = p.y();
|
||||
System.out.println(x+y);
|
||||
}
|
||||
}
|
||||
|
||||
// record pattern
|
||||
void printSum2(Object o) {
|
||||
if (o instanceof Point(int x, int y)) {
|
||||
System.out.println(x+y);
|
||||
}
|
||||
}
|
||||
|
||||
void printUpperLeftColoredPoint(Rectangle r) {
|
||||
if (r instanceof Rectangle(ColoredPoint ul, ColoredPoint lr)) {
|
||||
System.out.println(ul.c());
|
||||
}
|
||||
}
|
||||
|
||||
// nested record pattern
|
||||
void printColorOfUpperLeftPoint(Rectangle r) {
|
||||
if (r instanceof Rectangle(ColoredPoint(Point p, Color c),
|
||||
ColoredPoint lr)) {
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle createRectangle(int x1, int y1, Color c1, int x2, int y2, Color c2) {
|
||||
Rectangle r = new Rectangle(new ColoredPoint(new Point(x1, y1), c1),
|
||||
new ColoredPoint(new Point(x2, y2), c2));
|
||||
return r;
|
||||
}
|
||||
|
||||
// fully nested record pattern, also using "var"
|
||||
void printXCoordOfUpperLeftPointWithPatterns(Rectangle r) {
|
||||
if (r instanceof Rectangle(ColoredPoint(Point(var x, var y), var c),
|
||||
var lr)) {
|
||||
System.out.println("Upper-left corner: " + x);
|
||||
}
|
||||
}
|
||||
|
||||
record Pair(Object x, Object y) {}
|
||||
void nestedPatternsCanFailToMatch() {
|
||||
Pair p = new Pair(42, 42);
|
||||
if (p instanceof Pair(String s, String t)) {
|
||||
System.out.println(s + ", " + t);
|
||||
} else {
|
||||
System.out.println("Not a pair of strings");
|
||||
}
|
||||
}
|
||||
|
||||
// record patterns with generic types
|
||||
record Box<T>(T t) {}
|
||||
void test1a(Box<Object> bo) {
|
||||
if (bo instanceof Box<Object>(String s)) {
|
||||
System.out.println("String " + s);
|
||||
}
|
||||
}
|
||||
void test1(Box<String> bo) {
|
||||
if (bo instanceof Box<String>(var s)) {
|
||||
System.out.println("String " + s);
|
||||
}
|
||||
}
|
||||
|
||||
// type argument is inferred
|
||||
void test2(Box<String> bo) {
|
||||
if (bo instanceof Box(var s)) { // Inferred to be Box<String>(var s)
|
||||
System.out.println("String " + s);
|
||||
}
|
||||
}
|
||||
|
||||
// nested record patterns
|
||||
void test3(Box<Box<String>> bo) {
|
||||
if (bo instanceof Box<Box<String>>(Box(var s))) {
|
||||
System.out.println("String " + s);
|
||||
}
|
||||
}
|
||||
|
||||
void test4(Box<Box<String>> bo) {
|
||||
if (bo instanceof Box(Box(var s))) {
|
||||
System.out.println("String " + s);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/432">JEP 432: Record Patterns (Second Preview)</a>
|
||||
*/
|
||||
public class RecordPatternsExhaustiveSwitch {
|
||||
class A {}
|
||||
class B extends A {}
|
||||
sealed interface I permits C, D {}
|
||||
final class C implements I {}
|
||||
final class D implements I {}
|
||||
record Pair<T>(T x, T y) {}
|
||||
|
||||
static void test() {
|
||||
Pair<A> p1 = null;
|
||||
Pair<I> p2 = null;
|
||||
|
||||
switch (p1) { // Error!
|
||||
case Pair<A>(A a, B b) -> System.out.println("a");
|
||||
case Pair<A>(B b, A a) -> System.out.println("a");
|
||||
case Pair<A>(A a1, A a2) -> System.out.println("exhaustive now"); // without this case, compile error
|
||||
}
|
||||
|
||||
switch (p2) {
|
||||
case Pair<I>(I i, C c) -> System.out.println("a");
|
||||
case Pair<I>(I i, D d) -> System.out.println("a");
|
||||
}
|
||||
|
||||
switch (p2) {
|
||||
case Pair<I>(C c, I i) -> System.out.println("a");
|
||||
case Pair<I>(D d, C c) -> System.out.println("a");
|
||||
case Pair<I>(D d1, D d2) -> System.out.println("a");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = ""]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsExhaustiveSwitch", @CanonicalName = "RecordPatternsExhaustiveSwitch", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RecordPatternsExhaustiveSwitch", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
|
||||
+- ClassBody[@Empty = false, @Size = 7]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsExhaustiveSwitch$A", @CanonicalName = "RecordPatternsExhaustiveSwitch.A", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "A", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassBody[@Empty = true, @Size = 0]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsExhaustiveSwitch$B", @CanonicalName = "RecordPatternsExhaustiveSwitch.B", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "B", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ExtendsList[@Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| +- ClassBody[@Empty = true, @Size = 0]
|
||||
+- ClassDeclaration[@Abstract = true, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsExhaustiveSwitch$I", @CanonicalName = "RecordPatternsExhaustiveSwitch.I", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = true, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = false, @RegularInterface = true, @SimpleName = "I", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{sealed, abstract, static}", @ExplicitModifiers = "{sealed}"]
|
||||
| +- PermitsList[@Empty = false, @Size = 2]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "C"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "D"]
|
||||
| +- ClassBody[@Empty = true, @Size = 0]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsExhaustiveSwitch$C", @CanonicalName = "RecordPatternsExhaustiveSwitch.C", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "C", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"]
|
||||
| +- ImplementsList[@Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| +- ClassBody[@Empty = true, @Size = 0]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsExhaustiveSwitch$D", @CanonicalName = "RecordPatternsExhaustiveSwitch.D", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "D", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"]
|
||||
| +- ImplementsList[@Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| +- ClassBody[@Empty = true, @Size = 0]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsExhaustiveSwitch$Pair", @CanonicalName = "RecordPatternsExhaustiveSwitch.Pair", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Pair", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- TypeParameters[@Empty = false, @Size = 1]
|
||||
| | +- TypeParameter[@Image = "T", @Name = "T", @TypeBound = false]
|
||||
| +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "T"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "x", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "T"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| +- RecordBody[@Empty = true, @Size = 0]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "test", @Name = "test", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
+- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
+- VoidType[]
|
||||
+- FormalParameters[@Empty = true, @Size = 0]
|
||||
+- Block[@Empty = false, @Size = 5, @containsComment = false]
|
||||
+- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "p1"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "p1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "p2"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "p2", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p1", @Name = "p1", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| | | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "a", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "B"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "b", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| | | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "B"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "b", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "a", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| +- SwitchLabel[@Default = false]
|
||||
| | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "a1", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "A"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "a2", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "exhaustive now", @Empty = false, @Image = "\"exhaustive now\"", @Length = 14, @LiteralText = "\"exhaustive now\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p2", @Name = "p2", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| | | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "C"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| +- SwitchLabel[@Default = false]
|
||||
| | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "D"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "d", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false]
|
||||
+- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p2", @Name = "p2", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- SwitchArrowBranch[@Default = false]
|
||||
| +- SwitchLabel[@Default = false]
|
||||
| | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "C"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- SwitchArrowBranch[@Default = false]
|
||||
| +- SwitchLabel[@Default = false]
|
||||
| | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "D"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "d", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "C"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- SwitchArrowBranch[@Default = false]
|
||||
+- SwitchLabel[@Default = false]
|
||||
| +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "I"]
|
||||
| +- PatternList[@Empty = false, @Size = 2]
|
||||
| +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "D"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "d1", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "D"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "d2", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
+- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
+- ArgumentList[@Empty = false, @Size = 1]
|
||||
+- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/432">JEP 432: Record Patterns (Second Preview)</a>
|
||||
*/
|
||||
public class RecordPatternsInEnhancedFor {
|
||||
record Point(int x, int y) {}
|
||||
enum Color { RED, GREEN, BLUE }
|
||||
record ColoredPoint(Point p, Color c) {}
|
||||
record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) {}
|
||||
|
||||
// record patterns in for-each loop (enhanced for statement)
|
||||
static void dump(Point[] pointArray) {
|
||||
for (Point(var x, var y) : pointArray) { // Record Pattern in header!
|
||||
System.out.println("(" + x + ", " + y + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// nested record patterns in enhanced for statement
|
||||
static void printUpperLeftColors(Rectangle[] r) {
|
||||
for (Rectangle(ColoredPoint(Point p, Color c), ColoredPoint lr): r) {
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
|
||||
record Pair(Object fst, Object snd){}
|
||||
static void exceptionTest() {
|
||||
Pair[] ps = new Pair[]{
|
||||
new Pair(1,2),
|
||||
null,
|
||||
new Pair("hello","world")
|
||||
};
|
||||
for (Pair(var f, var s): ps) { // Run-time MatchException
|
||||
System.out.println(f + " -> " + s);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
exceptionTest();
|
||||
}
|
||||
}
|
@ -1,215 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = ""]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsInEnhancedFor", @CanonicalName = "RecordPatternsInEnhancedFor", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RecordPatternsInEnhancedFor", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
|
||||
+- ClassBody[@Empty = false, @Size = 9]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsInEnhancedFor$Point", @CanonicalName = "RecordPatternsInEnhancedFor.Point", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Point", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "x", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| +- RecordBody[@Empty = true, @Size = 0]
|
||||
+- EnumDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsInEnhancedFor$Color", @CanonicalName = "RecordPatternsInEnhancedFor.Color", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = true, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = false, @RegularInterface = false, @SimpleName = "Color", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- EnumBody[@Empty = false, @SeparatorSemi = false, @Size = 3, @TrailingComma = false]
|
||||
| +- EnumConstant[@AnonymousClass = false, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "RED", @MethodName = "new", @Name = "RED", @Visibility = Visibility.V_PUBLIC]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = true, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "RED", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_PUBLIC]
|
||||
| +- EnumConstant[@AnonymousClass = false, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "GREEN", @MethodName = "new", @Name = "GREEN", @Visibility = Visibility.V_PUBLIC]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = true, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "GREEN", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_PUBLIC]
|
||||
| +- EnumConstant[@AnonymousClass = false, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "BLUE", @MethodName = "new", @Name = "BLUE", @Visibility = Visibility.V_PUBLIC]
|
||||
| +- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = true, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "BLUE", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsInEnhancedFor$ColoredPoint", @CanonicalName = "RecordPatternsInEnhancedFor.ColoredPoint", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "ColoredPoint", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "p", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Color"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| +- RecordBody[@Empty = true, @Size = 0]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsInEnhancedFor$Rectangle", @CanonicalName = "RecordPatternsInEnhancedFor.Rectangle", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Rectangle", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "upperLeft", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "lowerRight", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| +- RecordBody[@Empty = true, @Size = 0]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "dump", @Name = "dump", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ArrayType[@ArrayDepth = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"]
|
||||
| | | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | | +- ArrayTypeDim[@Varargs = false]
|
||||
| | +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "pointArray", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- ForeachStatement[]
|
||||
| +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Point"]
|
||||
| | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "var"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "x", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "var"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "pointArray", @Name = "pointArray", @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 = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "(", @Empty = false, @Image = "\"(\"", @Length = 1, @LiteralText = "\"(\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = ", ", @Empty = false, @Image = "\", \"", @Length = 2, @LiteralText = "\", \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = ")", @Empty = false, @Image = "\")\"", @Length = 1, @LiteralText = "\")\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "printUpperLeftColors", @Name = "printUpperLeftColors", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ArrayType[@ArrayDepth = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"]
|
||||
| | | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | | +- ArrayTypeDim[@Varargs = false]
|
||||
| | +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "r", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- ForeachStatement[]
|
||||
| +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"]
|
||||
| | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"]
|
||||
| | | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "p", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Color"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "lr", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @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 = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatternsInEnhancedFor$Pair", @CanonicalName = "RecordPatternsInEnhancedFor.Pair", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Pair", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"]
|
||||
| +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "fst", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "snd", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| +- RecordBody[@Empty = true, @Size = 0]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "exceptionTest", @Name = "exceptionTest", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = true, @Size = 0]
|
||||
| +- Block[@Empty = false, @Size = 2, @containsComment = false]
|
||||
| +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ArrayType[@ArrayDepth = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | | +- ArrayTypeDim[@Varargs = false]
|
||||
| | +- VariableDeclarator[@Initializer = true, @Name = "ps"]
|
||||
| | +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "ps", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ArrayAllocation[@ArrayDepth = 1, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArrayType[@ArrayDepth = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | | +- ArrayTypeDim[@Varargs = false]
|
||||
| | +- ArrayInitializer[@CompileTimeConstant = false, @Length = 3, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 2]
|
||||
| | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1]
|
||||
| | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "2", @IntLiteral = true, @Integral = true, @LiteralText = "2", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 2.0, @ValueAsFloat = 2.0, @ValueAsInt = 2, @ValueAsLong = 2]
|
||||
| | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 2]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "hello", @Empty = false, @Image = "\"hello\"", @Length = 5, @LiteralText = "\"hello\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "world", @Empty = false, @Image = "\"world\"", @Length = 5, @LiteralText = "\"world\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- ForeachStatement[]
|
||||
| +- RecordPattern[@ParenthesisDepth = 0]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"]
|
||||
| | +- PatternList[@Empty = false, @Size = 2]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "var"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "f", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "var"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "ps", @Name = "ps", @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 = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "f", @Name = "f", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " -> ", @Empty = false, @Image = "\" -> \"", @Length = 4, @LiteralText = "\" -> \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PUBLIC, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true]
|
||||
+- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
|
||||
+- VoidType[]
|
||||
+- FormalParameters[@Empty = false, @Size = 1]
|
||||
| +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ArrayType[@ArrayDepth = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | +- ArrayTypeDim[@Varargs = false]
|
||||
| +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_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 = Visibility.V_LOCAL]
|
||||
+- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
+- ExpressionStatement[]
|
||||
+- MethodCall[@CompileTimeConstant = false, @Image = "exceptionTest", @MethodName = "exceptionTest", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ArgumentList[@Empty = true, @Size = 0]
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/433">JEP 433: Pattern Matching for switch (Fourth Preview)</a>
|
||||
*/
|
||||
public class RefiningPatternsInSwitch {
|
||||
|
||||
static class Shape {}
|
||||
static class Rectangle extends Shape {}
|
||||
static class Triangle extends Shape {
|
||||
private int area;
|
||||
Triangle(int area) {
|
||||
this.area = area;
|
||||
}
|
||||
int calculateArea() { return area; }
|
||||
}
|
||||
|
||||
static void testTriangle(Shape s) {
|
||||
switch (s) {
|
||||
case null:
|
||||
break;
|
||||
case Triangle t:
|
||||
if (t.calculateArea() > 100) {
|
||||
System.out.println("Large triangle");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
System.out.println("A shape, possibly a small triangle");
|
||||
}
|
||||
}
|
||||
|
||||
static void testTriangleRefined(Shape s) {
|
||||
switch (s) {
|
||||
case null ->
|
||||
{ break; }
|
||||
case Triangle t
|
||||
when t.calculateArea() > 100 ->
|
||||
System.out.println("Large triangle");
|
||||
default ->
|
||||
System.out.println("A shape, possibly a small triangle");
|
||||
}
|
||||
}
|
||||
|
||||
static void testTriangleRefined2(Shape s) {
|
||||
switch (s) {
|
||||
case null ->
|
||||
{ break; }
|
||||
case Triangle t
|
||||
when t.calculateArea() > 100 ->
|
||||
System.out.println("Large triangle");
|
||||
case Triangle t ->
|
||||
System.out.println("Small triangle");
|
||||
default ->
|
||||
System.out.println("Non-triangle");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Triangle large = new Triangle(200);
|
||||
Triangle small = new Triangle(10);
|
||||
Rectangle rect = new Rectangle();
|
||||
|
||||
testTriangle(large);
|
||||
testTriangle(small);
|
||||
testTriangle(rect);
|
||||
|
||||
testTriangleRefined(large);
|
||||
testTriangleRefined(small);
|
||||
testTriangleRefined(rect);
|
||||
|
||||
testTriangleRefined2(large);
|
||||
testTriangleRefined2(small);
|
||||
testTriangleRefined2(rect);
|
||||
}
|
||||
}
|
@ -1,257 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = ""]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RefiningPatternsInSwitch", @CanonicalName = "RefiningPatternsInSwitch", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RefiningPatternsInSwitch", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
|
||||
+- ClassBody[@Empty = false, @Size = 7]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RefiningPatternsInSwitch$Shape", @CanonicalName = "RefiningPatternsInSwitch.Shape", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Shape", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- ClassBody[@Empty = true, @Size = 0]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RefiningPatternsInSwitch$Rectangle", @CanonicalName = "RefiningPatternsInSwitch.Rectangle", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Rectangle", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- ExtendsList[@Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Shape"]
|
||||
| +- ClassBody[@Empty = true, @Size = 0]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RefiningPatternsInSwitch$Triangle", @CanonicalName = "RefiningPatternsInSwitch.Triangle", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Triangle", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- ExtendsList[@Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Shape"]
|
||||
| +- ClassBody[@Empty = false, @Size = 3]
|
||||
| +- FieldDeclaration[@EffectiveVisibility = Visibility.V_PRIVATE, @Static = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"]
|
||||
| | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | +- VariableDeclarator[@Initializer = false, @Name = "area"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = true, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "area", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE]
|
||||
| +- ConstructorDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "Triangle", @Name = "Triangle", @Varargs = false, @Visibility = Visibility.V_PACKAGE, @containsComment = false]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "area", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| | +- ExpressionStatement[]
|
||||
| | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "area", @Name = "area", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ThisExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "area", @Name = "area", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "calculateArea", @Name = "calculateArea", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- PrimitiveType[@Kind = PrimitiveTypeKind.INT]
|
||||
| +- FormalParameters[@Empty = true, @Size = 0]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- ReturnStatement[]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "area", @Name = "area", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testTriangle", @Name = "testTriangle", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Shape"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchFallthroughBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- BreakStatement[@Label = null]
|
||||
| +- SwitchFallthroughBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "t", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- IfStatement[@Else = false]
|
||||
| | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "calculateArea", @MethodName = "calculateArea", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "t", @Name = "t", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "100", @IntLiteral = true, @Integral = true, @LiteralText = "100", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 100.0, @ValueAsFloat = 100.0, @ValueAsInt = 100, @ValueAsLong = 100]
|
||||
| | +- Block[@Empty = false, @Size = 2, @containsComment = false]
|
||||
| | +- ExpressionStatement[]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Large triangle", @Empty = false, @Image = "\"Large triangle\"", @Length = 14, @LiteralText = "\"Large triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- BreakStatement[@Label = null]
|
||||
| +- SwitchFallthroughBranch[@Default = true]
|
||||
| +- SwitchLabel[@Default = true]
|
||||
| +- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "A shape, possibly a small triangle", @Empty = false, @Image = "\"A shape, possibly a small triangle\"", @Length = 34, @LiteralText = "\"A shape, possibly a small triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testTriangleRefined", @Name = "testTriangleRefined", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Shape"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| | +- BreakStatement[@Label = null]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "t", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- Guard[]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "calculateArea", @MethodName = "calculateArea", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "t", @Name = "t", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "100", @IntLiteral = true, @Integral = true, @LiteralText = "100", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 100.0, @ValueAsFloat = 100.0, @ValueAsInt = 100, @ValueAsLong = 100]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Large triangle", @Empty = false, @Image = "\"Large triangle\"", @Length = 14, @LiteralText = "\"Large triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchArrowBranch[@Default = true]
|
||||
| +- SwitchLabel[@Default = true]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "A shape, possibly a small triangle", @Empty = false, @Image = "\"A shape, possibly a small triangle\"", @Length = 34, @LiteralText = "\"A shape, possibly a small triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testTriangleRefined2", @Name = "testTriangleRefined2", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Shape"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| | +- BreakStatement[@Label = null]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "t", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- Guard[]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "calculateArea", @MethodName = "calculateArea", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "t", @Name = "t", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "100", @IntLiteral = true, @Integral = true, @LiteralText = "100", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 100.0, @ValueAsFloat = 100.0, @ValueAsInt = 100, @ValueAsLong = 100]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Large triangle", @Empty = false, @Image = "\"Large triangle\"", @Length = 14, @LiteralText = "\"Large triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "t", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Small triangle", @Empty = false, @Image = "\"Small triangle\"", @Length = 14, @LiteralText = "\"Small triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchArrowBranch[@Default = true]
|
||||
| +- SwitchLabel[@Default = true]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Non-triangle", @Empty = false, @Image = "\"Non-triangle\"", @Length = 12, @LiteralText = "\"Non-triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PUBLIC, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true]
|
||||
+- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
|
||||
+- VoidType[]
|
||||
+- FormalParameters[@Empty = false, @Size = 1]
|
||||
| +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ArrayType[@ArrayDepth = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | +- ArrayTypeDim[@Varargs = false]
|
||||
| +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_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 = Visibility.V_LOCAL]
|
||||
+- Block[@Empty = false, @Size = 12, @containsComment = false]
|
||||
+- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "large"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "large", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "200", @IntLiteral = true, @Integral = true, @LiteralText = "200", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 200.0, @ValueAsFloat = 200.0, @ValueAsInt = 200, @ValueAsLong = 200]
|
||||
+- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "small"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "small", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Triangle"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "10", @IntLiteral = true, @Integral = true, @LiteralText = "10", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 10.0, @ValueAsFloat = 10.0, @ValueAsInt = 10, @ValueAsLong = 10]
|
||||
+- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"]
|
||||
| +- VariableDeclarator[@Initializer = true, @Name = "rect"]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "rect", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"]
|
||||
| +- ArgumentList[@Empty = true, @Size = 0]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangle", @MethodName = "testTriangle", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "large", @Name = "large", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangle", @MethodName = "testTriangle", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "small", @Name = "small", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangle", @MethodName = "testTriangle", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "rect", @Name = "rect", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangleRefined", @MethodName = "testTriangleRefined", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "large", @Name = "large", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangleRefined", @MethodName = "testTriangleRefined", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "small", @Name = "small", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangleRefined", @MethodName = "testTriangleRefined", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "rect", @Name = "rect", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangleRefined2", @MethodName = "testTriangleRefined2", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "large", @Name = "large", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testTriangleRefined2", @MethodName = "testTriangleRefined2", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "small", @Name = "small", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
+- MethodCall[@CompileTimeConstant = false, @Image = "testTriangleRefined2", @MethodName = "testTriangleRefined2", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ArgumentList[@Empty = false, @Size = 1]
|
||||
+- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "rect", @Name = "rect", @ParenthesisDepth = 0, @Parenthesized = false]
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see <a href="https://openjdk.org/jeps/433">JEP 433: Pattern Matching for switch (Fourth Preview)</a>
|
||||
*/
|
||||
public class ScopeOfPatternVariableDeclarations {
|
||||
|
||||
static void testSwitchBlock(Object obj) {
|
||||
switch (obj) {
|
||||
case Character c
|
||||
when c.charValue() == 7:
|
||||
System.out.println("Ding!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void testSwitchRule(Object o) {
|
||||
switch (o) {
|
||||
case Character c -> {
|
||||
if (c.charValue() == 7) {
|
||||
System.out.println("Ding!");
|
||||
}
|
||||
System.out.println("Character");
|
||||
}
|
||||
case Integer i ->
|
||||
throw new IllegalStateException("Invalid Integer argument of value " + i.intValue());
|
||||
default -> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void test2(Object o) {
|
||||
switch (o) {
|
||||
case Character c:
|
||||
if (c.charValue() == 7) {
|
||||
System.out.print("Ding ");
|
||||
}
|
||||
if (c.charValue() == 9) {
|
||||
System.out.print("Tab ");
|
||||
}
|
||||
System.out.println("character");
|
||||
default:
|
||||
System.out.println("fall-through");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
testSwitchBlock('\u0007');
|
||||
testSwitchRule('A');
|
||||
try {
|
||||
testSwitchRule(42); // throws
|
||||
} catch (IllegalStateException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
test2('\t');
|
||||
}
|
||||
}
|
@ -1,200 +0,0 @@
|
||||
+- CompilationUnit[@PackageName = ""]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "ScopeOfPatternVariableDeclarations", @CanonicalName = "ScopeOfPatternVariableDeclarations", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "ScopeOfPatternVariableDeclarations", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC]
|
||||
+- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"]
|
||||
+- ClassBody[@Empty = false, @Size = 4]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testSwitchBlock", @Name = "testSwitchBlock", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "obj", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchFallthroughBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "Character"]
|
||||
| | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | | +- Guard[]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "charValue", @MethodName = "charValue", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "7", @IntLiteral = true, @Integral = true, @LiteralText = "7", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.0, @ValueAsFloat = 7.0, @ValueAsInt = 7, @ValueAsLong = 7]
|
||||
| | +- ExpressionStatement[]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Ding!", @Empty = false, @Image = "\"Ding!\"", @Length = 5, @LiteralText = "\"Ding!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- BreakStatement[@Label = null]
|
||||
| +- SwitchFallthroughBranch[@Default = true]
|
||||
| +- SwitchLabel[@Default = true]
|
||||
| +- BreakStatement[@Label = null]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testSwitchRule", @Name = "testSwitchRule", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Character"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- Block[@Empty = false, @Size = 2, @containsComment = false]
|
||||
| | +- IfStatement[@Else = false]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- MethodCall[@CompileTimeConstant = false, @Image = "charValue", @MethodName = "charValue", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "7", @IntLiteral = true, @Integral = true, @LiteralText = "7", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.0, @ValueAsFloat = 7.0, @ValueAsInt = 7, @ValueAsLong = 7]
|
||||
| | | +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| | | +- ExpressionStatement[]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Ding!", @Empty = false, @Image = "\"Ding!\"", @Length = 5, @LiteralText = "\"Ding!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- ExpressionStatement[]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Character", @Empty = false, @Image = "\"Character\"", @Length = 9, @LiteralText = "\"Character\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchArrowBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Integer"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ThrowStatement[]
|
||||
| | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "IllegalStateException"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Invalid Integer argument of value ", @Empty = false, @Image = "\"Invalid Integer argument of value \"", @Length = 34, @LiteralText = "\"Invalid Integer argument of value \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "intValue", @MethodName = "intValue", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- AmbiguousName[@CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| +- SwitchArrowBranch[@Default = true]
|
||||
| +- SwitchLabel[@Default = true]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- BreakStatement[@Label = null]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "test2", @Name = "test2", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "Object"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- SwitchFallthroughBranch[@Default = false]
|
||||
| | +- SwitchLabel[@Default = false]
|
||||
| | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE]
|
||||
| | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "Character"]
|
||||
| | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- IfStatement[@Else = false]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- MethodCall[@CompileTimeConstant = false, @Image = "charValue", @MethodName = "charValue", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "7", @IntLiteral = true, @Integral = true, @LiteralText = "7", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.0, @ValueAsFloat = 7.0, @ValueAsInt = 7, @ValueAsLong = 7]
|
||||
| | | +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| | | +- ExpressionStatement[]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "print", @MethodName = "print", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Ding ", @Empty = false, @Image = "\"Ding \"", @Length = 5, @LiteralText = "\"Ding \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- IfStatement[@Else = false]
|
||||
| | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- MethodCall[@CompileTimeConstant = false, @Image = "charValue", @MethodName = "charValue", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | | +- ArgumentList[@Empty = true, @Size = 0]
|
||||
| | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "9", @IntLiteral = true, @Integral = true, @LiteralText = "9", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 9.0, @ValueAsFloat = 9.0, @ValueAsInt = 9, @ValueAsLong = 9]
|
||||
| | | +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| | | +- ExpressionStatement[]
|
||||
| | | +- MethodCall[@CompileTimeConstant = false, @Image = "print", @MethodName = "print", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Tab ", @Empty = false, @Image = "\"Tab \"", @Length = 4, @LiteralText = "\"Tab \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| | +- ExpressionStatement[]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "character", @Empty = false, @Image = "\"character\"", @Length = 9, @LiteralText = "\"character\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- SwitchFallthroughBranch[@Default = true]
|
||||
| +- SwitchLabel[@Default = true]
|
||||
| +- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "fall-through", @Empty = false, @Image = "\"fall-through\"", @Length = 12, @LiteralText = "\"fall-through\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PUBLIC, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true]
|
||||
+- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"]
|
||||
+- VoidType[]
|
||||
+- FormalParameters[@Empty = false, @Size = 1]
|
||||
| +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| +- ArrayType[@ArrayDepth = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "String"]
|
||||
| | +- ArrayDimensions[@Empty = false, @Size = 1]
|
||||
| | +- ArrayTypeDim[@Varargs = false]
|
||||
| +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_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 = Visibility.V_LOCAL]
|
||||
+- Block[@Empty = false, @Size = 4, @containsComment = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testSwitchBlock", @MethodName = "testSwitchBlock", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- CharLiteral[@CompileTimeConstant = true, @Image = "\'\u0007\'", @LiteralText = "\'\u0007\'", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "testSwitchRule", @MethodName = "testSwitchRule", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- CharLiteral[@CompileTimeConstant = true, @Image = "\'A\'", @LiteralText = "\'A\'", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- TryStatement[@TryWithResources = false]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = true]
|
||||
| | +- ExpressionStatement[]
|
||||
| | +- MethodCall[@CompileTimeConstant = false, @Image = "testSwitchRule", @MethodName = "testSwitchRule", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "42", @IntLiteral = true, @Integral = true, @LiteralText = "42", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 42.0, @ValueAsFloat = 42.0, @ValueAsInt = 42, @ValueAsLong = 42]
|
||||
| +- CatchClause[]
|
||||
| +- CatchParameter[@EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Multicatch = false, @Name = "e", @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "IllegalStateException"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = false, @ExceptionBlockParameter = true, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "e", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "e", @Name = "e", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ExpressionStatement[]
|
||||
+- MethodCall[@CompileTimeConstant = false, @Image = "test2", @MethodName = "test2", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- ArgumentList[@Empty = false, @Size = 1]
|
||||
+- CharLiteral[@CompileTimeConstant = true, @Image = "\'\\t\'", @LiteralText = "\'\\t\'", @ParenthesisDepth = 0, @Parenthesized = false]
|
Loading…
x
Reference in New Issue
Block a user