From 9f4d870fa514a90b51c5871f8cc9122c2ca58a24 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 16 Jan 2024 20:23:09 +0100 Subject: [PATCH 01/39] [java] SingletonClassReturningNewInstance - fix double assignment case Fixes #932 --- docs/pages/release_notes.md | 2 + ...ingletonClassReturningNewInstanceRule.java | 37 ++++++++++++++++++- .../SingletonClassReturningNewInstance.xml | 22 +++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index cbf09dab12..2089fa1c28 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -141,6 +141,7 @@ in the Migration Guide. * [#174](https://github.com/pmd/pmd/issues/174): \[java] SingularField false positive with switch in method that both assigns and reads field * java-errorprone * [#718](https://github.com/pmd/pmd/issues/718): \[java] BrokenNullCheck false positive with parameter/field confusion + * [#932](https://github.com/pmd/pmd/issues/932): \[java] SingletonClassReturningNewInstance false positive with double assignment * [#1831](https://github.com/pmd/pmd/issues/1831): \[java] DetachedTestCase reports abstract methods * [#4719](https://github.com/pmd/pmd/pull/4719): \[java] UnnecessaryCaseChange: example doc toUpperCase() should compare to a capitalized string * javascript @@ -765,6 +766,7 @@ Language specific fixes: * java-errorprone * [#659](https://github.com/pmd/pmd/issues/659): \[java] MissingBreakInSwitch - last default case does not contain a break * [#718](https://github.com/pmd/pmd/issues/718): \[java] BrokenNullCheck false positive with parameter/field confusion + * [#932](https://github.com/pmd/pmd/issues/932): \[java] SingletonClassReturningNewInstance false positive with double assignment * [#1005](https://github.com/pmd/pmd/issues/1005): \[java] CloneMethodMustImplementCloneable triggers for interfaces * [#1669](https://github.com/pmd/pmd/issues/1669): \[java] NullAssignment - FP with ternay and null as constructor argument * [#1831](https://github.com/pmd/pmd/issues/1831): \[java] DetachedTestCase reports abstract methods diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java index 7975519f17..a4ebc7e775 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java @@ -6,12 +6,15 @@ package net.sourceforge.pmd.lang.java.rule.errorprone; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.NodeStream.DescendantNodeStream; +import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr; +import net.sourceforge.pmd.lang.java.ast.ASTAssignmentExpression; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTReturnStatement; import net.sourceforge.pmd.lang.java.ast.ASTVariableAccess; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; +import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; public class SingletonClassReturningNewInstanceRule extends AbstractJavaRulechainRule { @@ -37,6 +40,38 @@ public class SingletonClassReturningNewInstanceRule extends AbstractJavaRulechai } private boolean returnsLocalVariables(NodeStream returns) { - return returns.children(ASTVariableAccess.class).filter(JavaAstUtils::isReferenceToLocal).nonEmpty(); + return returns.children(ASTVariableAccess.class) + .filter(JavaAstUtils::isReferenceToLocal) + .filterNot(this::isDoubleAssignment) + .nonEmpty(); } + + private boolean isDoubleAssignment(ASTVariableAccess variableAccess) { + // search in the whole method + return variableAccess.ancestors(ASTMethodDeclaration.class) + .descendants(ASTVariableAccess.class) + // for any writes + .filter(v -> v.getAccessType() == ASTAssignableExpr.AccessType.WRITE) + // to the same variable + .filter(v -> JavaAstUtils.isReferenceToSameVar(variableAccess, v)) + // assignment from a constructor call (next sibling = right hand side) + .filter(v -> v.getNextSibling() instanceof ASTConstructorCall) + // and double assignment + .filter(v -> v.getParent() instanceof ASTAssignmentExpression && v.getParent().getParent() instanceof ASTAssignmentExpression) + .filter(v -> { + ASTAssignmentExpression rightAssignment = (ASTAssignmentExpression) v.getParent(); + ASTAssignmentExpression leftAssignment = (ASTAssignmentExpression) v.getParent().getParent(); + + boolean fromConstructor = rightAssignment.getRightOperand() instanceof ASTConstructorCall; + boolean fromRightToLeft = leftAssignment.getRightOperand() == rightAssignment; + boolean leftIsField = false; + if (leftAssignment.getLeftOperand() instanceof ASTAssignableExpr.ASTNamedReferenceExpr) { + JVariableSymbol symbol = ((ASTAssignableExpr.ASTNamedReferenceExpr) leftAssignment.getLeftOperand()).getReferencedSym(); + leftIsField = symbol.isField(); + } + return fromConstructor && fromRightToLeft && leftIsField; + }) + .nonEmpty(); + } + } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml index df702066b5..5fa7a23d17 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml @@ -57,4 +57,26 @@ public class Singleton { } ]]> + + + [java] SingletonClassReturningNewInstance false positive with double assignment #932 + 0 + + From 023e51e67fe3f02136fab1fbdc57f98038e39a9c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 17 Jan 2024 18:02:45 +0100 Subject: [PATCH 02/39] [java] SingletonClassReturningNewInstance - variant 2 (#932) --- ...ingletonClassReturningNewInstanceRule.java | 50 ++++++++++++++----- .../SingletonClassReturningNewInstance.xml | 28 +++++++++-- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java index a4ebc7e775..52921f547d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SingletonClassReturningNewInstanceRule.java @@ -54,22 +54,46 @@ public class SingletonClassReturningNewInstanceRule extends AbstractJavaRulechai .filter(v -> v.getAccessType() == ASTAssignableExpr.AccessType.WRITE) // to the same variable .filter(v -> JavaAstUtils.isReferenceToSameVar(variableAccess, v)) - // assignment from a constructor call (next sibling = right hand side) - .filter(v -> v.getNextSibling() instanceof ASTConstructorCall) - // and double assignment - .filter(v -> v.getParent() instanceof ASTAssignmentExpression && v.getParent().getParent() instanceof ASTAssignmentExpression) + // assignment from a constructor call (next sibling = right hand side) or another Assignment + .filter(v -> v.getNextSibling() instanceof ASTConstructorCall || v.getNextSibling() instanceof ASTAssignmentExpression) + // check for both variants .filter(v -> { - ASTAssignmentExpression rightAssignment = (ASTAssignmentExpression) v.getParent(); - ASTAssignmentExpression leftAssignment = (ASTAssignmentExpression) v.getParent().getParent(); + boolean variant1 = false; + boolean variant2 = false; - boolean fromConstructor = rightAssignment.getRightOperand() instanceof ASTConstructorCall; - boolean fromRightToLeft = leftAssignment.getRightOperand() == rightAssignment; - boolean leftIsField = false; - if (leftAssignment.getLeftOperand() instanceof ASTAssignableExpr.ASTNamedReferenceExpr) { - JVariableSymbol symbol = ((ASTAssignableExpr.ASTNamedReferenceExpr) leftAssignment.getLeftOperand()).getReferencedSym(); - leftIsField = symbol.isField(); + // check variant 1: field = localVar = new Singleton() + if (v.getNextSibling() instanceof ASTConstructorCall) { + if (v.getParent() instanceof ASTAssignmentExpression && v.getParent().getParent() instanceof ASTAssignmentExpression) { + ASTAssignmentExpression leftAssignment = (ASTAssignmentExpression) v.getParent().getParent(); + ASTAssignmentExpression rightAssignment = (ASTAssignmentExpression) v.getParent(); + + boolean fromConstructor = rightAssignment.getRightOperand() instanceof ASTConstructorCall; + boolean fromRightToLeft = leftAssignment.getRightOperand() == rightAssignment; + boolean leftIsField = false; + if (leftAssignment.getLeftOperand() instanceof ASTAssignableExpr.ASTNamedReferenceExpr) { + JVariableSymbol symbol = ((ASTAssignableExpr.ASTNamedReferenceExpr) leftAssignment.getLeftOperand()).getReferencedSym(); + leftIsField = symbol != null && symbol.isField(); + } + variant1 = fromConstructor && fromRightToLeft && leftIsField; + } + + // check variant 2: localVar = field = new Singleton() + } else if (v.getNextSibling() instanceof ASTAssignmentExpression) { + if (v.getParent() instanceof ASTAssignmentExpression) { + ASTAssignmentExpression leftAssignment = (ASTAssignmentExpression) v.getParent(); + ASTAssignmentExpression rightAssignment = (ASTAssignmentExpression) v.getNextSibling(); + + boolean fromConstructor = rightAssignment.getRightOperand() instanceof ASTConstructorCall; + boolean fromRightToLeft = leftAssignment.getRightOperand() == rightAssignment; + boolean rightIsField = false; + if (rightAssignment.getLeftOperand() instanceof ASTAssignableExpr.ASTNamedReferenceExpr) { + JVariableSymbol symbol = ((ASTAssignableExpr.ASTNamedReferenceExpr) rightAssignment.getLeftOperand()).getReferencedSym(); + rightIsField = symbol != null && symbol.isField(); + } + variant2 = fromConstructor && fromRightToLeft && rightIsField; + } } - return fromConstructor && fromRightToLeft && leftIsField; + return variant1 || variant2; }) .nonEmpty(); } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml index 5fa7a23d17..fb8ac71d02 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/SingletonClassReturningNewInstance.xml @@ -59,7 +59,7 @@ public class Singleton { - [java] SingletonClassReturningNewInstance false positive with double assignment #932 + [java] SingletonClassReturningNewInstance false positive with double assignment #932 - variant 1 0 + + + + [java] SingletonClassReturningNewInstance false positive with double assignment #932 - variant 2 + 0 + Date: Thu, 15 Feb 2024 09:12:47 +0100 Subject: [PATCH 03/39] [java] Add new java language versions 22 and 22-preview --- docs/pages/pmd/languages/java.md | 8 +++++--- docs/pages/pmd/userdocs/tools/ant.md | 2 +- .../java/net/sourceforge/pmd/it/BinaryDistributionIT.java | 1 + .../net/sourceforge/pmd/lang/java/JavaLanguageModule.java | 6 ++++-- .../sourceforge/pmd/lang/java/JavaLanguageModuleTest.java | 6 +++--- .../sourceforge/pmd/lang/java/LanguageVersionTest.java | 4 +++- .../net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt | 3 ++- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md index 6354280cae..fd6397eb45 100644 --- a/docs/pages/pmd/languages/java.md +++ b/docs/pages/pmd/languages/java.md @@ -15,8 +15,10 @@ Usually the latest non-preview Java Version is the default version. | Java Version | Alias | Supported by PMD since | |--------------|-------|------------------------| +| 22-preview | | 7.0.0 | +| 22 (default) | | 7.0.0 | | 21-preview | | 7.0.0 | -| 21 (default) | | 7.0.0 | +| 21 | | 7.0.0 | | 20-preview | | 6.55.0 | | 20 | | 6.55.0 | | 19 | | 6.48.0 | @@ -40,10 +42,10 @@ Usually the latest non-preview Java Version is the default version. ## Using Java preview features In order to analyze a project with PMD that uses preview language features, you'll need to enable -it via the environment variable `PMD_JAVA_OPTS` and select the new language version, e.g. `21-preview`: +it via the environment variable `PMD_JAVA_OPTS` and select the new language version, e.g. `22-preview`: export PMD_JAVA_OPTS=--enable-preview - pmd check --use-version java-21-preview ... + pmd check --use-version java-22-preview ... Note: we only support preview language features for the latest two java versions. diff --git a/docs/pages/pmd/userdocs/tools/ant.md b/docs/pages/pmd/userdocs/tools/ant.md index f259bc7149..4c81ff7daf 100644 --- a/docs/pages/pmd/userdocs/tools/ant.md +++ b/docs/pages/pmd/userdocs/tools/ant.md @@ -212,7 +212,7 @@ accordingly and this rule won't be executed. The specific version of a language to be used is selected via the `sourceLanguage` nested element. Example: - + The available versions depend on the language. You can get a list of the currently supported language versions via the CLI option `--help`. diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java index 57c5de0638..f77532acb4 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java @@ -51,6 +51,7 @@ class BinaryDistributionIT extends AbstractBinaryDistributionTest { "java-16", "java-17", "java-18", "java-19", "java-20", "java-20-preview", "java-21", "java-21-preview", + "java-22", "java-22-preview", "java-5", "java-6", "java-7", "java-8", "java-9", "jsp-2", "jsp-3", "kotlin-1.6", "kotlin-1.7", "kotlin-1.8", "modelica-3.4", "modelica-3.5", diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java index 562b6365e6..fc7a738088 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java @@ -43,8 +43,10 @@ public class JavaLanguageModule extends LanguageModuleBase implements PmdCapable .addVersion("19") .addVersion("20") .addVersion("20-preview") - .addDefaultVersion("21") // 21 is the default - .addVersion("21-preview")); + .addVersion("21") + .addVersion("21-preview") + .addDefaultVersion("22") // 22 is the default + .addVersion("22-preview")); } public static JavaLanguageModule getInstance() { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaLanguageModuleTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaLanguageModuleTest.java index 4655032327..cdf292b34f 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaLanguageModuleTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaLanguageModuleTest.java @@ -24,10 +24,10 @@ class JavaLanguageModuleTest { @Test void previewVersionShouldBeGreaterThanNonPreview() { - LanguageVersion java20 = JavaLanguageModule.getInstance().getVersion("20"); - LanguageVersion java20p = JavaLanguageModule.getInstance().getVersion("20-preview"); + LanguageVersion java = JavaLanguageModule.getInstance().getVersion("22"); + LanguageVersion javaPreview = JavaLanguageModule.getInstance().getVersion("22-preview"); - assertTrue(java20p.compareTo(java20) > 0, "java20-preview should be greater than java20"); + assertTrue(javaPreview.compareTo(java) > 0, "java-preview should be greater than java"); } @Test diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java index 47f1619085..eea0472371 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java @@ -40,8 +40,10 @@ class LanguageVersionTest extends AbstractLanguageVersionTest { new TestDescriptor(java, "20-preview"), new TestDescriptor(java, "21"), new TestDescriptor(java, "21-preview"), + new TestDescriptor(java, "22"), + new TestDescriptor(java, "22-preview"), - defaultVersionIs(java, "21"), + defaultVersionIs(java, "22"), // this one won't be found: case-sensitive! versionDoesNotExist("JAVA", "JAVA", "1.7"), diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt index 791df7c2a3..638f2d35bb 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt @@ -35,7 +35,8 @@ enum class JavaVersion : Comparable { J18, J19, J20, J20__PREVIEW, - J21, J21__PREVIEW; + J21, J21__PREVIEW, + J22, J22__PREVIEW; /** Name suitable for use with e.g. [JavaParsingHelper.parse] */ val pmdName: String = name.removePrefix("J").replaceFirst("__", "-").replace('_', '.').lowercase() From c4620635ee7d2bb741ade27bf1c1c96c7ae518cf Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 09:15:20 +0100 Subject: [PATCH 04/39] Update asm dependency to 9.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8704c34564..e7de1314a5 100644 --- a/pom.xml +++ b/pom.xml @@ -679,7 +679,7 @@ org.ow2.asm asm - 9.5 + 9.6 org.pcollections From 2a53ebaa55a0ab048c5ff1cc360b827bbb64e127 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 09:17:40 +0100 Subject: [PATCH 05/39] [java] Remove java language version 20-preview --- docs/pages/pmd/languages/java.md | 1 - docs/pages/release_notes.md | 4 + .../pmd/it/BinaryDistributionIT.java | 2 +- .../pmd/lang/java/JavaLanguageModule.java | 1 - .../pmd/lang/java/LanguageVersionTest.java | 3 +- .../lang/java/ast/AllJavaAstTreeDumpTest.java | 1 - .../java/ast/Java20PreviewTreeDumpTest.java | 112 ---- .../java/rule/internal/DataflowPassTest.java | 6 +- .../pmd/lang/java/ast/KotlinTestingDsl.kt | 2 +- .../java20p/DealingWithNull.java | 93 --- .../java20p/DealingWithNull.txt | 347 ----------- .../java20p/EnhancedTypeCheckingSwitch.java | 39 -- .../java20p/EnhancedTypeCheckingSwitch.txt | 188 ------ .../java20p/ExhaustiveSwitch.java | 87 --- .../java20p/ExhaustiveSwitch.txt | 365 ------------ .../GuardedAndParenthesizedPatterns.java | 90 --- .../GuardedAndParenthesizedPatterns.txt | 422 ------------- .../java20p/PatternsInSwitchLabels.java | 22 - .../java20p/PatternsInSwitchLabels.txt | 89 --- .../java20p/RecordPatterns.java | 100 ---- .../java20p/RecordPatterns.txt | 557 ------------------ .../RecordPatternsExhaustiveSwitch.java | 37 -- .../RecordPatternsExhaustiveSwitch.txt | 237 -------- .../java20p/RecordPatternsInEnhancedFor.java | 43 -- .../java20p/RecordPatternsInEnhancedFor.txt | 215 ------- .../java20p/RefiningPatternsInSwitch.java | 77 --- .../java20p/RefiningPatternsInSwitch.txt | 257 -------- .../ScopeOfPatternVariableDeclarations.java | 64 -- .../ScopeOfPatternVariableDeclarations.txt | 200 ------- 29 files changed, 10 insertions(+), 3651 deletions(-) delete mode 100644 pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java20PreviewTreeDumpTest.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.txt delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.txt diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md index fd6397eb45..83717461d5 100644 --- a/docs/pages/pmd/languages/java.md +++ b/docs/pages/pmd/languages/java.md @@ -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 | diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7febf0e6ee..510d9a5fbf 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -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 diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java index f77532acb4..360d01d204 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java @@ -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", diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java index fc7a738088..393a5983ef 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java @@ -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 diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java index eea0472371..ce23b99db0 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/LanguageVersionTest.java @@ -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") ); } } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java index 850d2d5f90..42794be992 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java @@ -15,7 +15,6 @@ import org.junit.platform.suite.api.Suite; Java15TreeDumpTest.class, Java16TreeDumpTest.class, Java17TreeDumpTest.class, - Java20PreviewTreeDumpTest.class, Java21TreeDumpTest.class, Java21PreviewTreeDumpTest.class }) diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java20PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java20PreviewTreeDumpTest.java deleted file mode 100644 index fec894662d..0000000000 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java20PreviewTreeDumpTest.java +++ /dev/null @@ -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"); - } -} diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPassTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPassTest.java index 131e1de98e..3fb0c5506d 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPassTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPassTest.java @@ -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)); } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt index 638f2d35bb..4d6c6830fb 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt @@ -34,7 +34,7 @@ enum class JavaVersion : Comparable { J17, J18, J19, - J20, J20__PREVIEW, + J20, J21, J21__PREVIEW, J22, J22__PREVIEW; diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.java deleted file mode 100644 index 69c05218b9..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 433: Pattern Matching for switch (Fourth Preview) - */ -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"); - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.txt deleted file mode 100644 index b8bf1c9fc8..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/DealingWithNull.txt +++ /dev/null @@ -1,347 +0,0 @@ -+- CompilationUnit[@PackageName = ""] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "DealingWithNull", @CanonicalName = "DealingWithNull", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "DealingWithNull", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC] - +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] - +- ClassBody[@Empty = false, @Size = 6] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testFooBar", @Name = "testFooBar", @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 = "String"] - | | +- 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] - | | +- 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 = "Oops", @Empty = false, @Image = "\"Oops\"", @Length = 4, @LiteralText = "\"Oops\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] - | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Foo", @Empty = false, @Image = "\"Foo\"", @Length = 3, @LiteralText = "\"Foo\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bar", @Empty = false, @Image = "\"Bar\"", @Length = 3, @LiteralText = "\"Bar\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = 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 = "Great", @Empty = false, @Image = "\"Great\"", @Length = 5, @LiteralText = "\"Great\"", @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 = "Ok", @Empty = false, @Image = "\"Ok\"", @Length = 2, @LiteralText = "\"Ok\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testStringOrNull", @Name = "testStringOrNull", @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 = "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] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String: ", @Empty = false, @Image = "\"String: \"", @Length = 8, @LiteralText = "\"String: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = 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] - | | +- 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 = 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 = "default case", @Empty = false, @Image = "\"default case\"", @Length = 12, @LiteralText = "\"default case\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testStringOrDefaultNull", @Name = "testStringOrDefaultNull", @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 = "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] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String: ", @Empty = false, @Image = "\"String: \"", @Length = 8, @LiteralText = "\"String: \"", @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] - | | +- 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 or default case", @Empty = false, @Image = "\"null or default case\"", @Length = 20, @LiteralText = "\"null or default case\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- 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 = 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] - | | +- ThrowStatement[] - | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | | +- ClassType[@FullyQualified = false, @SimpleName = "NullPointerException"] - | | +- 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 = "{}"] - | | | +- 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] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String: ", @Empty = false, @Image = "\"String: \"", @Length = 8, @LiteralText = "\"String: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @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 = "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 = "Integer", @Empty = false, @Image = "\"Integer\"", @Length = 7, @LiteralText = "\"Integer\"", @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 = "default", @Empty = false, @Image = "\"default\"", @Length = 7, @LiteralText = "\"default\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "test3", @Name = "test3", @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 = 4, @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] - | | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = 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 = "null", @Empty = false, @Image = "\"null\"", @Length = 4, @LiteralText = "\"null\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = 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 = "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] - | | | +- 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 = "String", @Empty = false, @Image = "\"String\"", @Length = 6, @LiteralText = "\"String\"", @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 = "default case", @Empty = false, @Image = "\"default case\"", @Length = 12, @LiteralText = "\"default case\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | | +- BreakStatement[@Label = null] - | +- 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 = 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 = "default case", @Empty = false, @Image = "\"default case\"", @Length = 12, @LiteralText = "\"default case\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = 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] - | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = 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 = "The rest (including null)", @Empty = false, @Image = "\"The rest (including null)\"", @Length = 25, @LiteralText = "\"The rest (including null)\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = 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 = true] - | +- SwitchLabel[@Default = true] - | | +- 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 = "The rest (including null)", @Empty = false, @Image = "\"The rest (including null)\"", @Length = 25, @LiteralText = "\"The rest (including null)\"", @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] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testStringOrDefaultNull", @MethodName = "testStringOrDefaultNull", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "test", @Empty = false, @Image = "\"test\"", @Length = 4, @LiteralText = "\"test\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "test2", @MethodName = "test2", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 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] - +- TryStatement[@TryWithResources = false] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | | +- ExpressionStatement[] - | | +- MethodCall[@CompileTimeConstant = false, @Image = "test2", @MethodName = "test2", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- ArgumentList[@Empty = false, @Size = 1] - | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] - | +- CatchClause[] - | +- CatchParameter[@EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Multicatch = false, @Name = "e", @Visibility = Visibility.V_PACKAGE] - | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | | +- ClassType[@FullyQualified = false, @SimpleName = "NullPointerException"] - | | +- 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 = "test3", @MethodName = "test3", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- 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] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "test3", @MethodName = "test3", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "test", @Empty = false, @Image = "\"test\"", @Length = 4, @LiteralText = "\"test\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "test3", @MethodName = "test3", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testFooBar", @MethodName = "testFooBar", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testFooBar", @MethodName = "testFooBar", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Foo", @Empty = false, @Image = "\"Foo\"", @Length = 3, @LiteralText = "\"Foo\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testFooBar", @MethodName = "testFooBar", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bar", @Empty = false, @Image = "\"Bar\"", @Length = 3, @LiteralText = "\"Bar\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testFooBar", @MethodName = "testFooBar", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "baz", @Empty = false, @Image = "\"baz\"", @Length = 3, @LiteralText = "\"baz\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testStringOrNull", @MethodName = "testStringOrNull", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] - +- ExpressionStatement[] - +- MethodCall[@CompileTimeConstant = false, @Image = "testStringOrNull", @MethodName = "testStringOrNull", @ParenthesisDepth = 0, @Parenthesized = false] - +- ArgumentList[@Empty = false, @Size = 1] - +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "some string", @Empty = false, @Image = "\"some string\"", @Length = 11, @LiteralText = "\"some string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.java deleted file mode 100644 index ed3951e62e..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 433: Pattern Matching for switch (Fourth Preview) - */ -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; } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.txt deleted file mode 100644 index 8279481824..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/EnhancedTypeCheckingSwitch.txt +++ /dev/null @@ -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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.java deleted file mode 100644 index 3918654e57..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 433: Pattern Matching for switch (Fourth Preview) - */ -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 permits E, F {} - final static class E implements I {} - final static class F implements I {} - - static int testGenericSealedExhaustive(I i) { - return switch (i) { - // Exhaustive as no E case possible! - case F 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())); - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.txt deleted file mode 100644 index 95eb002031..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ExhaustiveSwitch.txt +++ /dev/null @@ -1,365 +0,0 @@ -+- CompilationUnit[@PackageName = ""] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch", @CanonicalName = "ExhaustiveSwitch", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "ExhaustiveSwitch", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC] - +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] - +- ClassBody[@Empty = false, @Size = 13] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "coverage", @Name = "coverage", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] - | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] - | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | +- 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] - | +- ReturnStatement[] - | +- 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 = "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 = "length", @MethodName = "length", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "s", @Name = "s", @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 = "{}"] - | | | +- 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] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] - | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] - | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "coverageStatement", @Name = "coverageStatement", @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 = "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] - | | +- 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 = "s", @Name = "s", @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 = "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] - | | +- 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 = "Integer", @Empty = false, @Image = "\"Integer\"", @Length = 7, @LiteralText = "\"Integer\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | | +- BreakStatement[@Label = null] - | +- SwitchFallthroughBranch[@Default = true] - | +- SwitchLabel[@Default = true] - | +- BreakStatement[@Label = null] - +- ClassDeclaration[@Abstract = true, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$S", @CanonicalName = "ExhaustiveSwitch.S", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = true, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = false, @RegularInterface = true, @SimpleName = "S", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] - | +- ModifierList[@EffectiveModifiers = "{sealed, abstract, static}", @ExplicitModifiers = "{sealed}"] - | +- PermitsList[@Empty = false, @Size = 3] - | | +- ClassType[@FullyQualified = false, @SimpleName = "A"] - | | +- ClassType[@FullyQualified = false, @SimpleName = "B"] - | | +- ClassType[@FullyQualified = false, @SimpleName = "C"] - | +- ClassBody[@Empty = true, @Size = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$A", @CanonicalName = "ExhaustiveSwitch.A", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "A", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] - | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{static, final}"] - | +- ImplementsList[@Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "S"] - | +- ClassBody[@Empty = true, @Size = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$B", @CanonicalName = "ExhaustiveSwitch.B", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "B", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] - | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{static, final}"] - | +- ImplementsList[@Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "S"] - | +- ClassBody[@Empty = true, @Size = 0] - +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$C", @CanonicalName = "ExhaustiveSwitch.C", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "C", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] - | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"] - | +- RecordComponentList[@Empty = false, @Size = 1, @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] - | +- ImplementsList[@Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "S"] - | +- RecordBody[@Empty = true, @Size = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testSealedExhaustive", @Name = "testSealedExhaustive", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] - | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] - | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | +- 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 = "S"] - | | +- 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] - | +- ReturnStatement[] - | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @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 = "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] - | | +- 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] - | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] - | | | +- 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] - | | +- 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] - | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] - | | +- 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] - | +- 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] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "switchStatementExhaustive", @Name = "switchStatementExhaustive", @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 = "S"] - | | +- 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 = 2, @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] - | | | | +- 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] - | | | +- 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", @Empty = false, @Image = "\"A\"", @Length = 1, @LiteralText = "\"A\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = 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 = "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] - | | | +- 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 = "C", @Empty = false, @Image = "\"C\"", @Length = 1, @LiteralText = "\"C\"", @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 = "default case, should be B", @Empty = false, @Image = "\"default case, should be B\"", @Length = 25, @LiteralText = "\"default case, should be B\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | | +- BreakStatement[@Label = null] - | +- EmptyStatement[] - +- ClassDeclaration[@Abstract = true, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$I", @CanonicalName = "ExhaustiveSwitch.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}"] - | +- TypeParameters[@Empty = false, @Size = 1] - | | +- TypeParameter[@Image = "T", @Name = "T", @TypeBound = false] - | +- PermitsList[@Empty = false, @Size = 2] - | | +- ClassType[@FullyQualified = false, @SimpleName = "E"] - | | +- ClassType[@FullyQualified = false, @SimpleName = "F"] - | +- ClassBody[@Empty = true, @Size = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$E", @CanonicalName = "ExhaustiveSwitch.E", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "E", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] - | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{static, final}"] - | +- TypeParameters[@Empty = false, @Size = 1] - | | +- TypeParameter[@Image = "X", @Name = "X", @TypeBound = false] - | +- ImplementsList[@Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "I"] - | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] - | +- ClassBody[@Empty = true, @Size = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$F", @CanonicalName = "ExhaustiveSwitch.F", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "F", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] - | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{static, final}"] - | +- TypeParameters[@Empty = false, @Size = 1] - | | +- TypeParameter[@Image = "Y", @Name = "Y", @TypeBound = false] - | +- ImplementsList[@Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "I"] - | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Y"] - | +- ClassBody[@Empty = true, @Size = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testGenericSealedExhaustive", @Name = "testGenericSealedExhaustive", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] - | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] - | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | +- 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 = "I"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- 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 = true, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- ReturnStatement[] - | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = 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 = "F"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- 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 = "bi", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- 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] - +- 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 = 13, @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] - | +- MethodCall[@CompileTimeConstant = false, @Image = "coverage", @MethodName = "coverage", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a string", @Empty = false, @Image = "\"a string\"", @Length = 8, @LiteralText = "\"a string\"", @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] - | +- MethodCall[@CompileTimeConstant = false, @Image = "coverage", @MethodName = "coverage", @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] - +- 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] - | +- MethodCall[@CompileTimeConstant = false, @Image = "coverage", @MethodName = "coverage", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- 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 = "coverageStatement", @MethodName = "coverageStatement", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a string", @Empty = false, @Image = "\"a string\"", @Length = 8, @LiteralText = "\"a string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "coverageStatement", @MethodName = "coverageStatement", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "21", @IntLiteral = true, @Integral = true, @LiteralText = "21", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 21.0, @ValueAsFloat = 21.0, @ValueAsInt = 21, @ValueAsLong = 21] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "coverageStatement", @MethodName = "coverageStatement", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- 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 = "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 = "A:", @Empty = false, @Image = "\"A:\"", @Length = 2, @LiteralText = "\"A:\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testSealedExhaustive", @MethodName = "testSealedExhaustive", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | +- ClassType[@FullyQualified = false, @SimpleName = "A"] - | +- 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] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "B:", @Empty = false, @Image = "\"B:\"", @Length = 2, @LiteralText = "\"B:\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testSealedExhaustive", @MethodName = "testSealedExhaustive", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | +- ClassType[@FullyQualified = false, @SimpleName = "B"] - | +- 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] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "C:", @Empty = false, @Image = "\"C:\"", @Length = 2, @LiteralText = "\"C:\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testSealedExhaustive", @MethodName = "testSealedExhaustive", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | +- ClassType[@FullyQualified = false, @SimpleName = "C"] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- 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] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "switchStatementExhaustive", @MethodName = "switchStatementExhaustive", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | +- ClassType[@FullyQualified = false, @SimpleName = "A"] - | +- ArgumentList[@Empty = true, @Size = 0] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "switchStatementExhaustive", @MethodName = "switchStatementExhaustive", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | +- ClassType[@FullyQualified = false, @SimpleName = "B"] - | +- ArgumentList[@Empty = true, @Size = 0] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "switchStatementExhaustive", @MethodName = "switchStatementExhaustive", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | +- ClassType[@FullyQualified = false, @SimpleName = "C"] - | +- ArgumentList[@Empty = false, @Size = 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] - +- 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] - +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "F:", @Empty = false, @Image = "\"F:\"", @Length = 2, @LiteralText = "\"F:\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodCall[@CompileTimeConstant = false, @Image = "testGenericSealedExhaustive", @MethodName = "testGenericSealedExhaustive", @ParenthesisDepth = 0, @Parenthesized = false] - +- ArgumentList[@Empty = false, @Size = 1] - +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - +- ClassType[@FullyQualified = false, @SimpleName = "F"] - | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | +- ClassType[@FullyQualified = false, @SimpleName = "Integer"] - +- ArgumentList[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.java deleted file mode 100644 index 41e2a343fe..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 433: Pattern Matching for switch (Fourth Preview) - */ -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"); - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.txt deleted file mode 100644 index 082bb7295f..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/GuardedAndParenthesizedPatterns.txt +++ /dev/null @@ -1,422 +0,0 @@ -+- CompilationUnit[@PackageName = ""] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "GuardedAndParenthesizedPatterns", @CanonicalName = "GuardedAndParenthesizedPatterns", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "GuardedAndParenthesizedPatterns", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC] - +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] - +- ClassBody[@Empty = false, @Size = 8] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @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 = 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 = "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] - | | | +- Guard[] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- MethodCall[@CompileTimeConstant = false, @Image = "length", @MethodName = "length", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- ArgumentList[@Empty = true, @Size = 0] - | | | +- 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] - | | +- 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 = "single char string", @Empty = false, @Image = "\"single char string\"", @Length = 18, @LiteralText = "\"single char 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 = "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 = "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] - | | | +- Guard[] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = 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] - | | | +- 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] - | | +- 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 = "integer 1", @Empty = false, @Image = "\"integer 1\"", @Length = 9, @LiteralText = "\"integer 1\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 1, @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] - | | | +- Guard[] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- MethodCall[@CompileTimeConstant = false, @Image = "longValue", @MethodName = "longValue", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "l", @Name = "l", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- ArgumentList[@Empty = true, @Size = 0] - | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1L", @IntLiteral = false, @Integral = true, @LiteralText = "1L", @LongLiteral = true, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] - | | +- 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 = "long 1 with parens", @Empty = false, @Image = "\"long 1 with parens\"", @Length = 18, @LiteralText = "\"long 1 with parens\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 3, @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 = "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 = "double with parens", @Empty = false, @Image = "\"double with parens\"", @Length = 18, @LiteralText = "\"double with parens\"", @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 = "default case", @Empty = false, @Image = "\"default case\"", @Length = 12, @LiteralText = "\"default case\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testIdentifierWhen", @Name = "testIdentifierWhen", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "String"] - | | +- 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 = "when", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- 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 = "when", @Name = "when", @ParenthesisDepth = 0, @Parenthesized = false] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testIdentifierWhen", @Name = "testIdentifierWhen", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "{}"] - | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | | +- VariableDeclarator[@Initializer = true, @Name = "when"] - | | +- 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 = "when", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- 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] - | +- 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 = "when", @Name = "when", @ParenthesisDepth = 0, @Parenthesized = false] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "GuardedAndParenthesizedPatterns$when", @CanonicalName = "GuardedAndParenthesizedPatterns.when", @EffectiveVisibility = Visibility.V_PRIVATE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "when", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PRIVATE] - | +- ModifierList[@EffectiveModifiers = "{private, static}", @ExplicitModifiers = "{private, static}"] - | +- ClassBody[@Empty = true, @Size = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testWithNull", @Name = "testWithNull", @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 = "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] - | | | +- Guard[] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 1, @Parenthesized = true] - | | | +- MethodCall[@CompileTimeConstant = false, @Image = "length", @MethodName = "length", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- ArgumentList[@Empty = true, @Size = 0] - | | | +- 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] - | | +- 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 = "single char string", @Empty = false, @Image = "\"single char string\"", @Length = 18, @LiteralText = "\"single char 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 = "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 = 1, @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] - | | | +- Guard[] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = 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] - | | | +- 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] - | | +- 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 = "integer 1", @Empty = false, @Image = "\"integer 1\"", @Length = 9, @LiteralText = "\"integer 1\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 2, @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] - | | | +- Guard[] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 2, @Parenthesized = true] - | | | +- MethodCall[@CompileTimeConstant = false, @Image = "longValue", @MethodName = "longValue", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "l", @Name = "l", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- ArgumentList[@Empty = true, @Size = 0] - | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1L", @IntLiteral = false, @Integral = true, @LiteralText = "1L", @LongLiteral = true, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] - | | +- 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 = "long 1 with parens", @Empty = false, @Image = "\"long 1 with parens\"", @Length = 18, @LiteralText = "\"long 1 with parens\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 3, @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 = "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 = "double with parens", @Empty = false, @Image = "\"double with parens\"", @Length = 18, @LiteralText = "\"double with parens\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = 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 = 5, @LiteralText = "\"null!\"", @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 = "default case", @Empty = false, @Image = "\"default case\"", @Length = 12, @LiteralText = "\"default case\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "instanceOfPattern", @Name = "instanceOfPattern", @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 = 3, @containsComment = false] - | +- IfStatement[@Else = false] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.CONDITIONAL_AND, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = 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] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- MethodCall[@CompileTimeConstant = false, @Image = "length", @MethodName = "length", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- ArgumentList[@Empty = true, @Size = 0] - | | | +- 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] - | | +- 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 = "A string containing at least two characters", @Empty = false, @Image = "\"A string containing at least two characters\"", @Length = 43, @LiteralText = "\"A string containing at least two characters\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- IfStatement[@Else = false] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.CONDITIONAL_AND, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.NE, @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.CONDITIONAL_AND, @ParenthesisDepth = 1, @Parenthesized = true] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = 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] - | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- MethodCall[@CompileTimeConstant = false, @Image = "length", @MethodName = "length", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- ArgumentList[@Empty = true, @Size = 0] - | | | +- 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] - | | +- 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 = "A string containing at least three characters", @Empty = false, @Image = "\"A string containing at least three characters\"", @Length = 45, @LiteralText = "\"A string containing at least three characters\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.CONDITIONAL_AND, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 1, @Parenthesized = true] - | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = 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] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 1, @Parenthesized = true] - | | +- MethodCall[@CompileTimeConstant = false, @Image = "length", @MethodName = "length", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- ArgumentList[@Empty = true, @Size = 0] - | | +- 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] - | +- 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 = "A string containing at least four characters", @Empty = false, @Image = "\"A string containing at least four characters\"", @Length = 44, @LiteralText = "\"A string containing at least four characters\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "testScopeOfPatternVariableDeclarations", @Name = "testScopeOfPatternVariableDeclarations", @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] - | +- IfStatement[@Else = true] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.CONDITIONAL_AND, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 1, @Parenthesized = true] - | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = 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] - | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- MethodCall[@CompileTimeConstant = false, @Image = "length", @MethodName = "length", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- ArgumentList[@Empty = true, @Size = 0] - | | +- 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] - | +- 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 = "s", @Name = "s", @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] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Not a string", @Empty = false, @Image = "\"Not a string\"", @Length = 12, @LiteralText = "\"Not a string\"", @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] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "test", @MethodName = "test", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "test", @MethodName = "test", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "fooo", @Empty = false, @Image = "\"fooo\"", @Length = 4, @LiteralText = "\"fooo\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "test", @MethodName = "test", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- 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] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "test", @MethodName = "test", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1L", @IntLiteral = false, @Integral = true, @LiteralText = "1L", @LongLiteral = true, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "instanceOfPattern", @MethodName = "instanceOfPattern", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "abcde", @Empty = false, @Image = "\"abcde\"", @Length = 5, @LiteralText = "\"abcde\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- TryStatement[@TryWithResources = false] - | +- Block[@Empty = false, @Size = 1, @containsComment = true] - | | +- ExpressionStatement[] - | | +- MethodCall[@CompileTimeConstant = false, @Image = "test", @MethodName = "test", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- ArgumentList[@Empty = false, @Size = 1] - | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] - | +- CatchClause[] - | +- CatchParameter[@EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Multicatch = false, @Name = "e", @Visibility = Visibility.V_PACKAGE] - | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | | +- ClassType[@FullyQualified = false, @SimpleName = "NullPointerException"] - | | +- 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 = "printStackTrace", @MethodName = "printStackTrace", @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "e", @Name = "e", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = true, @Size = 0] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testWithNull", @MethodName = "testWithNull", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] - +- ExpressionStatement[] - | +- MethodCall[@CompileTimeConstant = false, @Image = "testScopeOfPatternVariableDeclarations", @MethodName = "testScopeOfPatternVariableDeclarations", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = false, @Size = 1] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- ExpressionStatement[] - +- MethodCall[@CompileTimeConstant = false, @Image = "testScopeOfPatternVariableDeclarations", @MethodName = "testScopeOfPatternVariableDeclarations", @ParenthesisDepth = 0, @Parenthesized = false] - +- ArgumentList[@Empty = false, @Size = 1] - +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "long enough", @Empty = false, @Image = "\"long enough\"", @Length = 11, @LiteralText = "\"long enough\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.java deleted file mode 100644 index 210c03f066..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 433: Pattern Matching for switch (Fourth Preview) - */ -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); - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.txt deleted file mode 100644 index d9f95d947e..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/PatternsInSwitchLabels.txt +++ /dev/null @@ -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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.java deleted file mode 100644 index 2ae278af1e..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 432: Record Patterns (Second Preview) - */ -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) {} - void test1a(Box bo) { - if (bo instanceof Box(String s)) { - System.out.println("String " + s); - } - } - void test1(Box bo) { - if (bo instanceof Box(var s)) { - System.out.println("String " + s); - } - } - - // type argument is inferred - void test2(Box bo) { - if (bo instanceof Box(var s)) { // Inferred to be Box(var s) - System.out.println("String " + s); - } - } - - // nested record patterns - void test3(Box> bo) { - if (bo instanceof Box>(Box(var s))) { - System.out.println("String " + s); - } - } - - void test4(Box> bo) { - if (bo instanceof Box(Box(var s))) { - System.out.println("String " + s); - } - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.txt deleted file mode 100644 index 5fd641f5da..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatterns.txt +++ /dev/null @@ -1,557 +0,0 @@ -+- CompilationUnit[@PackageName = ""] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns", @CanonicalName = "RecordPatterns", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RecordPatterns", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PUBLIC] - +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] - +- ClassBody[@Empty = false, @Size = 18] - +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns$Point", @CanonicalName = "RecordPatterns.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 = "RecordPatterns$Color", @CanonicalName = "RecordPatterns.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 = "RecordPatterns$ColoredPoint", @CanonicalName = "RecordPatterns.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 = "RecordPatterns$Rectangle", @CanonicalName = "RecordPatterns.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 = "printSum1", @Name = "printSum1", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = 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] - | +- Block[@Empty = false, @Size = 3, @containsComment = false] - | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | | +- VariableDeclarator[@Initializer = true, @Name = "x"] - | | +- 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 = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- MethodCall[@CompileTimeConstant = false, @Image = "x", @MethodName = "x", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- ArgumentList[@Empty = true, @Size = 0] - | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | | +- VariableDeclarator[@Initializer = true, @Name = "y"] - | | +- 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 = "y", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- MethodCall[@CompileTimeConstant = false, @Image = "y", @MethodName = "y", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p", @Name = "p", @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] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "printSum2", @Name = "printSum2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- 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 = "{}"] - | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | | | +- 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 = "{}"] - | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] - | | +- 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] - | +- 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] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "printUpperLeftColoredPoint", @Name = "printUpperLeftColoredPoint", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "Rectangle"] - | | +- 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 = "r", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] - | | +- PatternList[@Empty = false, @Size = 2] - | | +- 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 = "ul", @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] - | +- 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] - | +- MethodCall[@CompileTimeConstant = false, @Image = "c", @MethodName = "c", @ParenthesisDepth = 0, @Parenthesized = false] - | +- AmbiguousName[@CompileTimeConstant = false, @Image = "ul", @Name = "ul", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ArgumentList[@Empty = true, @Size = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "printColorOfUpperLeftPoint", @Name = "printColorOfUpperLeftPoint", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "Rectangle"] - | | +- 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 = "r", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- 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] - | +- 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] - +- MethodDeclaration[@Abstract = false, @Arity = 6, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "createRectangle", @Name = "createRectangle", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] - | +- FormalParameters[@Empty = false, @Size = 6] - | | +- 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 = "x1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- 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 = "y1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] - | | | +- 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 = true, @LambdaParameter = false, @LocalVariable = false, @Name = "c1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- 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 = "x2", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- 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 = "y2", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] - | | +- 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 = true, @LambdaParameter = false, @LocalVariable = false, @Name = "c2", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 2, @containsComment = false] - | +- 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 = "r"] - | | +- 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 = "r", @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 = false, @Size = 2] - | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] - | | | +- ArgumentList[@Empty = false, @Size = 2] - | | | +- 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] - | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x1", @Name = "x1", @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y1", @Name = "y1", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c1", @Name = "c1", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] - | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] - | | +- ArgumentList[@Empty = false, @Size = 2] - | | +- 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] - | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x2", @Name = "x2", @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y2", @Name = "y2", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c2", @Name = "c2", @ParenthesisDepth = 0, @Parenthesized = false] - | +- ReturnStatement[] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "printXCoordOfUpperLeftPointWithPatterns", @Name = "printXCoordOfUpperLeftPointWithPatterns", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "Rectangle"] - | | +- 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 = "r", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- 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] - | | | +- 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] - | | | +- 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 = "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 = "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 = "lr", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- 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] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Upper-left corner: ", @Empty = false, @Image = "\"Upper-left corner: \"", @Length = 19, @LiteralText = "\"Upper-left corner: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] - +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns$Pair", @CanonicalName = "RecordPatterns.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 = "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 = "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 = "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 = "nestedPatternsCanFailToMatch", @Name = "nestedPatternsCanFailToMatch", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "{}"] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"] - | | +- VariableDeclarator[@Initializer = true, @Name = "p"] - | | +- 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 = "p", @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 = "Pair"] - | | +- ArgumentList[@Empty = false, @Size = 2] - | | +- 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] - | | +- 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] - | +- IfStatement[@Else = true] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- 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 = "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] - | | +- 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 = "t", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- 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 = "s", @Name = "s", @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 = "t", @Name = "t", @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] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Not a pair of strings", @Empty = false, @Image = "\"Not a pair of strings\"", @Length = 21, @LiteralText = "\"Not a pair of strings\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns$Box", @CanonicalName = "RecordPatterns.Box", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Box", @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 = 1, @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 = "t", @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 = "test1a", @Name = "test1a", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- 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 = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- ClassType[@FullyQualified = false, @SimpleName = "Object"] - | | +- PatternList[@Empty = false, @Size = 1] - | | +- 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] - | +- 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] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @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_PACKAGE, @Final = false, @Image = "test1", @Name = "test1", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- 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 = true, @LambdaParameter = false, @LocalVariable = false, @Name = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] - | | +- PatternList[@Empty = false, @Size = 1] - | | +- 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] - | +- 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] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @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_PACKAGE, @Final = false, @Image = "test2", @Name = "test2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- 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 = true, @LambdaParameter = false, @LocalVariable = false, @Name = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | +- PatternList[@Empty = false, @Size = 1] - | | +- 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] - | +- 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] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @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_PACKAGE, @Final = false, @Image = "test3", @Name = "test3", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - | +- 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 = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- 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 = true, @LambdaParameter = false, @LocalVariable = false, @Name = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | +- Block[@Empty = false, @Size = 1, @containsComment = false] - | +- IfStatement[@Else = false] - | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] - | | +- PatternList[@Empty = false, @Size = 1] - | | +- RecordPattern[@ParenthesisDepth = 0] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | +- PatternList[@Empty = false, @Size = 1] - | | +- 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] - | +- 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] - | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @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_PACKAGE, @Final = false, @Image = "test4", @Name = "test4", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] - +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] - +- 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 = "Box"] - | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] - | | +- 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 = true, @LambdaParameter = false, @LocalVariable = false, @Name = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - +- Block[@Empty = false, @Size = 1, @containsComment = false] - +- IfStatement[@Else = false] - +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] - | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] - | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | +- RecordPattern[@ParenthesisDepth = 0] - | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | +- PatternList[@Empty = false, @Size = 1] - | +- RecordPattern[@ParenthesisDepth = 0] - | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] - | +- PatternList[@Empty = false, @Size = 1] - | +- 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] - +- 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] - +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.java deleted file mode 100644 index 7fb9f1250e..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 432: Record Patterns (Second Preview) - */ -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 x, T y) {} - - static void test() { - Pair p1 = null; - Pair p2 = null; - - switch (p1) { // Error! - case Pair(A a, B b) -> System.out.println("a"); - case Pair(B b, A a) -> System.out.println("a"); - case Pair(A a1, A a2) -> System.out.println("exhaustive now"); // without this case, compile error - } - - switch (p2) { - case Pair(I i, C c) -> System.out.println("a"); - case Pair(I i, D d) -> System.out.println("a"); - } - - switch (p2) { - case Pair(C c, I i) -> System.out.println("a"); - case Pair(D d, C c) -> System.out.println("a"); - case Pair(D d1, D d2) -> System.out.println("a"); - } - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.txt deleted file mode 100644 index 93ed78d5f0..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsExhaustiveSwitch.txt +++ /dev/null @@ -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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.java deleted file mode 100644 index 0f3b5f2274..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 432: Record Patterns (Second Preview) - */ -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(); - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.txt deleted file mode 100644 index 3a29eeffca..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RecordPatternsInEnhancedFor.txt +++ /dev/null @@ -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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.java deleted file mode 100644 index c2eadc6711..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 433: Pattern Matching for switch (Fourth Preview) - */ -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); - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.txt deleted file mode 100644 index 5a961e9b61..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/RefiningPatternsInSwitch.txt +++ /dev/null @@ -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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.java deleted file mode 100644 index d65340e4da..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * @see JEP 433: Pattern Matching for switch (Fourth Preview) - */ -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'); - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.txt deleted file mode 100644 index 50fa9893ec..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java20p/ScopeOfPatternVariableDeclarations.txt +++ /dev/null @@ -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] From c4eccf49af308bdf2b9521f80090968048952c18 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 10:03:37 +0100 Subject: [PATCH 06/39] [java] Remove old java 20 preview features - Record patterns in enhanced for statements - parenthesized patterns These features have not been standardized. --- docs/pages/release_notes.md | 3 + pmd-java/etc/grammar/Java.jjt | 17 ++--- .../pmd/lang/java/ast/ASTPattern.java | 13 ---- .../pmd/lang/java/ast/ASTRecordPattern.java | 16 ----- .../pmd/lang/java/ast/ASTTypePattern.java | 16 +---- .../pmd/lang/java/ast/ASTUnnamedPattern.java | 5 -- .../pmd/lang/java/ast/AstImplUtil.java | 16 ----- .../java16/PatternMatchingInstanceof.txt | 14 ++-- .../java21/DealingWithNull.txt | 12 ++-- .../java21/EnhancedTypeCheckingSwitch.txt | 8 +-- .../java21/ExhaustiveSwitch.txt | 20 +++--- .../java21/GuardedPatterns.txt | 20 +++--- .../java21/Jep440_RecordPatterns.txt | 54 +++++++-------- .../Jep441_PatternMatchingForSwitch.txt | 32 ++++----- .../java21/PatternsInSwitchLabels.txt | 8 +-- .../jdkversiontests/java21/RecordPatterns.txt | 68 +++++++++---------- .../java21/RecordPatternsExhaustiveSwitch.txt | 48 ++++++------- .../java21/RefiningPatternsInSwitch.txt | 8 +-- .../ScopeOfPatternVariableDeclarations.txt | 8 +-- .../Jep443_UnnamedPatternsAndVariables.txt | 56 +++++++-------- 20 files changed, 187 insertions(+), 255 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 510d9a5fbf..8f567c6be6 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -235,6 +235,9 @@ The rules have been moved into categories with PMD 6. **pmd-java** * Support for Java 20 preview language features have been removed. The version "20-preview" is no longer available. +* {%jdoc java::lang.java.ast.ASTPattern %}, {%jdoc java::lang.java.ast.ASTRecordPattern %}, + {%jdoc java::lang.java.ast.ASTTypePattern %}, {%jdoc java::lang.java.ast.ASTUnnamedPattern %} + - method `getParenthesisDepth()` has been removed. **New API** diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index df8f248e1f..69522d60fe 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,8 @@ /** + * Remove support for Record pattern in enhanced for statements. This was only a Java 20 Preview feature. + * Remove support for ParenthesizedPatterns. This was only a Java 20 Preview feature. + * Andreas Dangel 02/2024 + *==================================================================== * Renamed various nodes: * ClassOrInterfaceType -> ClassType * ClassOrInterfaceDeclaration -> ClassDeclaration @@ -1895,18 +1899,9 @@ void Pattern() #void: {} { LOOKAHEAD((Annotation())* ReferenceType() "(") RecordPattern() - | LOOKAHEAD("(") ParenthesizedPattern() | TypePattern() } -// ParenthesizedPatterns are removed with Java 21 (JEP 441), but needed for now to support Java 20 Preview -// TODO: Remove ParenthesizedPattern once java 20-preview is removed -void ParenthesizedPattern() #void: -{} -{ - "(" Pattern() ")" { AstImplUtil.bumpParenDepth((ASTPattern) jjtree.peekNode()); } -} - void TypePattern(): {} { @@ -2771,9 +2766,7 @@ void ForStatement() #void: void EnhancedForDeclaration() #void: {} { - LOOKAHEAD(LocalVariableDeclaration()) LocalVariableDeclaration() - // TODO: a recored pattern here is only valid with Java 20 Preview and not anymore with Java 21 (see JEP 440) - | RecordPattern() + LocalVariableDeclaration() } void ForInit() : diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTPattern.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTPattern.java index e80ed54084..eeedf1aaa8 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTPattern.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTPattern.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.java.ast; -import net.sourceforge.pmd.annotation.Experimental; - /** * A pattern for pattern matching constructs like {@link ASTInfixExpression InstanceOfExpression} * or within a {@link ASTSwitchLabel}). This is a JDK 16 feature. @@ -21,18 +19,7 @@ import net.sourceforge.pmd.annotation.Experimental; * * * @see JEP 394: Pattern Matching for instanceof (Java 16) - * @see JEP 405: Record Patterns (Preview) (Java 19) - * @see JEP 432: Record Patterns (Second Preview) (Java 20) * @see JEP 440: Record Patterns (Java 21) */ public interface ASTPattern extends JavaNode { - - /** - * Returns the number of parenthesis levels around this pattern. - * If this method returns 0, then no parentheses are present. - * @deprecated Parenthesized patterns are only possible with Java 20 Preview and are removed with Java 21. - */ - @Experimental - @Deprecated - int getParenthesisDepth(); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordPattern.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordPattern.java index ee9da2fb40..f16730342f 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordPattern.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordPattern.java @@ -5,8 +5,6 @@ package net.sourceforge.pmd.lang.java.ast; -import net.sourceforge.pmd.annotation.Experimental; - /** * A record pattern, a Java 21 language feature. * @@ -17,14 +15,10 @@ import net.sourceforge.pmd.annotation.Experimental; * * * @see ASTRecordDeclaration - * @see JEP 405: Record Patterns (Preview) (Java 19) - * @see JEP 432: Record Patterns (Second Preview) (Java 20) * @see JEP 440: Record Patterns (Java 21) */ public final class ASTRecordPattern extends AbstractJavaNode implements ASTPattern { - private int parenDepth; - ASTRecordPattern(int id) { super(id); } @@ -45,14 +39,4 @@ public final class ASTRecordPattern extends AbstractJavaNode implements ASTPatte public ASTVariableId getVarId() { return firstChild(ASTVariableId.class); } - - void bumpParenDepth() { - parenDepth++; - } - - @Override - @Experimental - public int getParenthesisDepth() { - return parenDepth; - } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTypePattern.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTypePattern.java index bcbe9802ba..3a99a89ea2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTypePattern.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTypePattern.java @@ -8,8 +8,6 @@ import java.util.Objects; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.annotation.Experimental; - /** * A type pattern (JDK16). This can be found on * the right-hand side of an {@link ASTInfixExpression InstanceOfExpression}, @@ -21,12 +19,10 @@ import net.sourceforge.pmd.annotation.Experimental; * * * - * @see JEP 394: Pattern Matching for instanceof + * @see JEP 394: Pattern Matching for instanceof (Java 16) */ public final class ASTTypePattern extends AbstractJavaNode implements ASTPattern, ModifierOwner { - private int parenDepth; - ASTTypePattern(int id) { super(id); } @@ -47,14 +43,4 @@ public final class ASTTypePattern extends AbstractJavaNode implements ASTPattern public @NonNull ASTVariableId getVarId() { return Objects.requireNonNull(firstChild(ASTVariableId.class)); } - - void bumpParenDepth() { - parenDepth++; - } - - @Override - @Experimental - public int getParenthesisDepth() { - return parenDepth; - } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java index 641e932458..6eed6e6d93 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java @@ -29,9 +29,4 @@ public final class ASTUnnamedPattern extends AbstractJavaNode implements ASTPatt protected R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); } - - @Override - public int getParenthesisDepth() { - return 0; - } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java index 5ed897d23a..e82aa68a37 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java @@ -47,20 +47,4 @@ final class AstImplUtil { ((AbstractJavaExpr) expression).bumpParenDepth(); } - - /** - * @deprecated Parenthesized patterns are only possible with Java 20 Preview and are removed with Java 21. - */ - @Deprecated - static void bumpParenDepth(ASTPattern pattern) { - assert pattern instanceof ASTTypePattern - || pattern instanceof ASTRecordPattern - : pattern.getClass() + " doesn't have parenDepth attribute!"; - - if (pattern instanceof ASTTypePattern) { - ((ASTTypePattern) pattern).bumpParenDepth(); - } else if (pattern instanceof ASTRecordPattern) { - ((ASTRecordPattern) pattern).bumpParenDepth(); - } - } } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java16/PatternMatchingInstanceof.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java16/PatternMatchingInstanceof.txt index 4dd88b2d5d..040bd905eb 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java16/PatternMatchingInstanceof.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java16/PatternMatchingInstanceof.txt @@ -33,7 +33,7 @@ | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -85,7 +85,7 @@ | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 1, @Parenthesized = true] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -118,7 +118,7 @@ | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -144,7 +144,7 @@ | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -169,7 +169,7 @@ | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -201,7 +201,7 @@ | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- Annotation[@SimpleName = "Deprecated"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Deprecated"] @@ -235,7 +235,7 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] | | | +- Annotation[@SimpleName = "Deprecated"] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Deprecated"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt index b8bf1c9fc8..6e3acc92f2 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt @@ -53,7 +53,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -95,7 +95,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -136,7 +136,7 @@ | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -150,7 +150,7 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -192,7 +192,7 @@ | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = false] | | | +- SwitchLabel[@Default = false] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -227,7 +227,7 @@ | | | +- 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] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt index 467b41816f..076c8640c5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt @@ -48,7 +48,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -60,7 +60,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -76,7 +76,7 @@ | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -92,7 +92,7 @@ | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ArrayType[@ArrayDepth = 1] | | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt index 90d5a427d0..71f2d7c7ab 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt @@ -16,7 +16,7 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -25,7 +25,7 @@ | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -46,7 +46,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -60,7 +60,7 @@ | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -116,21 +116,21 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] | | +- 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] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] | | +- 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] | +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -148,7 +148,7 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchFallthroughBranch[@Default = false] | | | +- SwitchLabel[@Default = false] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -162,7 +162,7 @@ | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = false] | | | +- SwitchLabel[@Default = false] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -227,7 +227,7 @@ | +- 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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "F"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt index be1b066f9d..de9bc407a5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt @@ -15,7 +15,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -33,7 +33,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "single char string", @Empty = false, @Image = "\"single char string\"", @Length = 18, @LiteralText = "\"single char string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -45,7 +45,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -119,7 +119,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -137,7 +137,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "single char string", @Empty = false, @Image = "\"single char string\"", @Length = 18, @LiteralText = "\"single char string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -149,7 +149,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -196,7 +196,7 @@ | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -222,7 +222,7 @@ | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -244,7 +244,7 @@ | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 1, @Parenthesized = true] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -275,7 +275,7 @@ | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 1, @Parenthesized = true] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt index 8a5dd29bfb..694d2a5d5f 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt @@ -27,14 +27,14 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- 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 = 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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- 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 = false, @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -97,21 +97,21 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] | | | +- PatternList[@Empty = false, @Size = 2] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -136,28 +136,28 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] | | | +- PatternList[@Empty = false, @Size = 2] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] | | | | +- PatternList[@Empty = false, @Size = 2] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "lr", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -202,14 +202,14 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "t", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -265,14 +265,14 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "pair", @Name = "pair", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "MyPair"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -309,17 +309,17 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bbs", @Name = "bbs", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -350,13 +350,13 @@ +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bbs", @Name = "bbs", @ParenthesisDepth = 0, @Parenthesized = false] | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | +- RecordPattern[@ParenthesisDepth = 0] + | +- RecordPattern[] | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | +- PatternList[@Empty = false, @Size = 1] - | +- RecordPattern[@ParenthesisDepth = 0] + | +- RecordPattern[] | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | +- PatternList[@Empty = false, @Size = 1] - | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt index 97bb756d4b..150946eeee 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt @@ -16,7 +16,7 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -28,7 +28,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -40,7 +40,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -52,7 +52,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -122,7 +122,7 @@ | | +- Block[@Empty = true, @Size = 0, @containsComment = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -141,7 +141,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "You got it", @Empty = false, @Image = "\"You got it\"", @Length = 10, @LiteralText = "\"You got it\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -160,7 +160,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Shame", @Empty = false, @Image = "\"Shame\"", @Length = 5, @LiteralText = "\"Shame\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -213,7 +213,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Shame", @Empty = false, @Image = "\"Shame\"", @Length = 5, @LiteralText = "\"Shame\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -232,7 +232,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "You got it", @Empty = false, @Image = "\"You got it\"", @Length = 10, @LiteralText = "\"You got it\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -251,7 +251,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Shame", @Empty = false, @Image = "\"Shame\"", @Length = 5, @LiteralText = "\"Shame\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -304,7 +304,7 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Suit"] | | | | +- 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] @@ -324,7 +324,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s clubs", @Empty = false, @Image = "\"It\'s clubs\"", @Length = 10, @LiteralText = "\"It\'s clubs\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Suit"] | | | | +- 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] @@ -344,7 +344,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s diamonds", @Empty = false, @Image = "\"It\'s diamonds\"", @Length = 13, @LiteralText = "\"It\'s diamonds\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Suit"] | | | | +- 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] @@ -364,7 +364,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s hearts", @Empty = false, @Image = "\"It\'s hearts\"", @Length = 11, @LiteralText = "\"It\'s hearts\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Suit"] | | | +- 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] @@ -378,7 +378,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s spades", @Empty = false, @Image = "\"It\'s spades\"", @Length = 11, @LiteralText = "\"It\'s spades\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "Tarot"] | | +- 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] @@ -455,7 +455,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s spades", @Empty = false, @Image = "\"It\'s spades\"", @Length = 11, @LiteralText = "\"It\'s spades\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "Tarot"] | | +- 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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt index d9f95d947e..745724d7a7 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt @@ -29,7 +29,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -41,7 +41,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -53,7 +53,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -65,7 +65,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt index 5fd641f5da..eb42a383fd 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatterns.txt @@ -63,7 +63,7 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -106,14 +106,14 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- 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 = 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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- 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 = false, @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -140,14 +140,14 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "ul", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -174,21 +174,21 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] | | | +- PatternList[@Empty = false, @Size = 2] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -270,28 +270,28 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] | | | +- PatternList[@Empty = false, @Size = 2] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] | | | | +- PatternList[@Empty = false, @Size = 2] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "c", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "lr", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -336,14 +336,14 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Pair"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "t", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -392,12 +392,12 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Object"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -426,12 +426,12 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -460,10 +460,10 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -494,17 +494,17 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -535,13 +535,13 @@ +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false] | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | +- RecordPattern[@ParenthesisDepth = 0] + | +- RecordPattern[] | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | +- PatternList[@Empty = false, @Size = 1] - | +- RecordPattern[@ParenthesisDepth = 0] + | +- RecordPattern[] | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | +- PatternList[@Empty = false, @Size = 1] - | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt index 93ed78d5f0..8e9d096f49 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt @@ -65,16 +65,16 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p1", @Name = "p1", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -86,16 +86,16 @@ | | +- 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] + | | | +- RecordPattern[] | | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -107,16 +107,16 @@ | | +- 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] + | | +- RecordPattern[] | | +- 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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -130,16 +130,16 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p2", @Name = "p2", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -151,16 +151,16 @@ | | +- 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] + | | +- RecordPattern[] | | +- 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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -174,16 +174,16 @@ +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p2", @Name = "p2", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- 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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -195,16 +195,16 @@ | +- 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] + | | +- RecordPattern[] | | +- 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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -216,16 +216,16 @@ | +- 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] + | +- RecordPattern[] | +- 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] + | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt index 5a961e9b61..0757c10f56 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt @@ -57,7 +57,7 @@ | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -103,7 +103,7 @@ | | +- BreakStatement[@Label = null] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -145,7 +145,7 @@ | | +- BreakStatement[@Label = null] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -163,7 +163,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt index 50fa9893ec..f559e29cd4 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt @@ -15,7 +15,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -49,7 +49,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -77,7 +77,7 @@ | | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] @@ -107,7 +107,7 @@ | +- 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables.txt index 5cd04c2718..fcb1e37135 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables.txt @@ -67,14 +67,14 @@ | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] | | | +- PatternList[@Empty = false, @Size = 2] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -98,21 +98,21 @@ | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] | | +- PatternList[@Empty = false, @Size = 2] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] | | | +- PatternList[@Empty = false, @Size = 2] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- 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 = 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] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- 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 = false, @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | +- UnnamedPattern[@ParenthesisDepth = 0] + | | +- UnnamedPattern[] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -182,10 +182,10 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] | | | +- SwitchLabel[@Default = false] - | | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -194,10 +194,10 @@ | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] | | | +- SwitchLabel[@Default = false] - | | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -206,10 +206,10 @@ | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- PatternList[@Empty = false, @Size = 1] - | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | +- ClassType[@FullyQualified = false, @SimpleName = "GreenBall"] | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -219,17 +219,17 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] | | | +- SwitchLabel[@Default = false] - | | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | | +- RecordPattern[] | | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | | | +- PatternList[@Empty = false, @Size = 1] - | | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] | | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -238,10 +238,10 @@ | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] | | | +- SwitchLabel[@Default = false] - | | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "GreenBall"] | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -249,10 +249,10 @@ | | | +- ArgumentList[@Empty = true, @Size = 0] | | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | +- PatternList[@Empty = false, @Size = 1] - | | | +- UnnamedPattern[@ParenthesisDepth = 0] + | | | +- UnnamedPattern[] | | +- MethodCall[@CompileTimeConstant = false, @Image = "pickAnotherBox", @MethodName = "pickAnotherBox", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -265,17 +265,17 @@ | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | | +- SwitchLabel[@Default = false] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] - | | | +- RecordPattern[@ParenthesisDepth = 0] + | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] - | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @ParenthesisDepth = 0, @Visibility = Visibility.V_PACKAGE] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] @@ -288,10 +288,10 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] | +- SwitchLabel[@Default = false] - | | +- RecordPattern[@ParenthesisDepth = 0] + | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] | | +- PatternList[@Empty = false, @Size = 1] - | | +- UnnamedPattern[@ParenthesisDepth = 0] + | | +- UnnamedPattern[] | +- MethodCall[@CompileTimeConstant = false, @Image = "pickAnotherBox", @MethodName = "pickAnotherBox", @ParenthesisDepth = 0, @Parenthesized = false] | +- ArgumentList[@Empty = true, @Size = 0] +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "processBox", @Name = "processBox", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] From 96bc9ef6c6b9758993332e375409034fe081a1d9 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 10:24:48 +0100 Subject: [PATCH 07/39] [java] Update LanguageLevelChecker#RegularLanguageFeature - after 20-preview is gone - Note: DECONSTRUCTION_PATTERNS_IN_ENHANCED_FOR_STATEMENT is completely gone. This was only available for 20-preview and has been removed with 21. --- .../ast/internal/LanguageLevelChecker.java | 97 ++++++++----------- .../pmd/lang/java/ast/Java21TreeDumpTest.java | 12 +-- 2 files changed, 49 insertions(+), 60 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java index 2b1267f9ee..e6dbcd8437 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java @@ -122,52 +122,6 @@ public class LanguageLevelChecker { * They might be also be standardized. */ private enum PreviewFeature implements LanguageFeature { - /** - * Pattern matching for switch - * @see JEP 406: Pattern Matching for switch (Preview) (Java 17) - * @see JEP 420: Pattern Matching for switch (Second Preview) (Java 18) - * @see JEP 427: Pattern Matching for switch (Third Preview) (Java 19) - * @see JEP 433: Pattern Matching for switch (Fourth Preview) (Java 20) - * @see JEP 441: Pattern Matching for switch (Java 21) - */ - PATTERNS_IN_SWITCH_STATEMENTS(17, 20, true), - - /** - * Part of pattern matching for switch - * @see #PATTERNS_IN_SWITCH_STATEMENTS - * @see JEP 406: Pattern Matching for switch (Preview) (Java 17) - * @see JEP 420: Pattern Matching for switch (Second Preview) (Java 18) - * @see JEP 427: Pattern Matching for switch (Third Preview) (Java 19) - * @see JEP 433: Pattern Matching for switch (Fourth Preview) (Java 20) - * @see JEP 441: Pattern Matching for switch (Java 21) - */ - NULL_IN_SWITCH_CASES(17, 20, true), - - /** - * Part of pattern matching for switch: Case refinement using "when" - * @see #PATTERNS_IN_SWITCH_STATEMENTS - * @see JEP 427: Pattern Matching for switch (Third Preview) (Java 19) - * @see JEP 433: Pattern Matching for switch (Fourth Preview) (Java 20) - * @see JEP 441: Pattern Matching for switch (Java 21) - */ - CASE_REFINEMENT(19, 20, true), - - /** - * Record patterns - * @see JEP 405: Record Patterns (Preview) (Java 19) - * @see JEP 432: Record Patterns (Second Preview) (Java 20) - * @see JEP 440: Record Patterns (Java 21) - */ - RECORD_PATTERNS(19, 20, true), - - /** - * Record deconstruction patterns in for-each loops. - * Note: support for this has been removed with Java 21 (JEP 440). - * @see JEP 432: Record Patterns (Second Preview) (Java 20) - * @see JEP 440: Record Patterns (Java 21) - */ - DECONSTRUCTION_PATTERNS_IN_ENHANCED_FOR_STATEMENT(20, 20, false), - /** * String Templates. * @see JEP 430: String Templates (Preview) (Java 21) @@ -378,6 +332,44 @@ public class LanguageLevelChecker { */ SEALED_CLASSES(17), + /** + * Pattern matching for switch + * @see JEP 406: Pattern Matching for switch (Preview) (Java 17) + * @see JEP 420: Pattern Matching for switch (Second Preview) (Java 18) + * @see JEP 427: Pattern Matching for switch (Third Preview) (Java 19) + * @see JEP 433: Pattern Matching for switch (Fourth Preview) (Java 20) + * @see JEP 441: Pattern Matching for switch (Java 21) + */ + PATTERNS_IN_SWITCH_STATEMENTS(21), + + /** + * Part of pattern matching for switch + * @see #PATTERNS_IN_SWITCH_STATEMENTS + * @see JEP 406: Pattern Matching for switch (Preview) (Java 17) + * @see JEP 420: Pattern Matching for switch (Second Preview) (Java 18) + * @see JEP 427: Pattern Matching for switch (Third Preview) (Java 19) + * @see JEP 433: Pattern Matching for switch (Fourth Preview) (Java 20) + * @see JEP 441: Pattern Matching for switch (Java 21) + */ + NULL_IN_SWITCH_CASES(21), + + /** + * Part of pattern matching for switch: Case refinement using "when" + * @see #PATTERNS_IN_SWITCH_STATEMENTS + * @see JEP 427: Pattern Matching for switch (Third Preview) (Java 19) + * @see JEP 433: Pattern Matching for switch (Fourth Preview) (Java 20) + * @see JEP 441: Pattern Matching for switch (Java 21) + */ + CASE_REFINEMENT(21), + + /** + * Record patterns + * @see JEP 405: Record Patterns (Preview) (Java 19) + * @see JEP 432: Record Patterns (Second Preview) (Java 20) + * @see JEP 440: Record Patterns (Java 21) + */ + RECORD_PATTERNS(21), + ; // SUPPRESS CHECKSTYLE enum trailing semi is awesome private final int minJdkLevel; @@ -512,9 +504,6 @@ public class LanguageLevelChecker { @Override public Void visit(ASTForeachStatement node, T data) { check(node, RegularLanguageFeature.FOREACH_LOOPS, data); - if (node.getFirstChild() instanceof ASTRecordPattern) { - check(node, PreviewFeature.DECONSTRUCTION_PATTERNS_IN_ENHANCED_FOR_STATEMENT, data); - } return null; } @@ -578,13 +567,13 @@ public class LanguageLevelChecker { @Override public Void visit(ASTRecordPattern node, T data) { - check(node, PreviewFeature.RECORD_PATTERNS, data); + check(node, RegularLanguageFeature.RECORD_PATTERNS, data); return null; } @Override public Void visit(ASTGuard node, T data) { - check(node, PreviewFeature.CASE_REFINEMENT, data); + check(node, RegularLanguageFeature.CASE_REFINEMENT, data); return null; } @@ -627,13 +616,13 @@ public class LanguageLevelChecker { check(node, RegularLanguageFeature.COMPOSITE_CASE_LABEL, data); } if (node.isDefault() && JavaTokenKinds.CASE == node.getFirstToken().getKind()) { - check(node, PreviewFeature.PATTERNS_IN_SWITCH_STATEMENTS, data); + check(node, RegularLanguageFeature.PATTERNS_IN_SWITCH_STATEMENTS, data); } if (node.getFirstChild() instanceof ASTNullLiteral) { - check(node, PreviewFeature.NULL_IN_SWITCH_CASES, data); + check(node, RegularLanguageFeature.NULL_IN_SWITCH_CASES, data); } if (node.getFirstChild() instanceof ASTPattern) { - check(node, PreviewFeature.PATTERNS_IN_SWITCH_STATEMENTS, data); + check(node, RegularLanguageFeature.PATTERNS_IN_SWITCH_STATEMENTS, data); } return null; } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21TreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21TreeDumpTest.java index 6ffde7d974..b5f7eed371 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21TreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21TreeDumpTest.java @@ -34,7 +34,7 @@ class Java21TreeDumpTest extends BaseJavaTreeDumpTest { @Test void patternMatchingForSwitchBeforeJava21() { ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("Jep441_PatternMatchingForSwitch.java")); - assertThat(thrown.getMessage(), containsString("Patterns in switch statements is a preview feature of JDK 20, you should select your language version accordingly")); + assertThat(thrown.getMessage(), containsString("Patterns in switch statements are a feature of Java 21, you should select your language version accordingly")); } @Test @@ -45,7 +45,7 @@ class Java21TreeDumpTest extends BaseJavaTreeDumpTest { @Test void dealingWithNullBeforeJava21() { ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("DealingWithNull.java")); - assertThat(thrown.getMessage(), containsString("Null in switch cases is a preview feature of JDK 20, you should select your language version accordingly")); + assertThat(thrown.getMessage(), containsString("Null in switch cases are a feature of Java 21, you should select your language version accordingly")); } @@ -67,7 +67,7 @@ class Java21TreeDumpTest extends BaseJavaTreeDumpTest { @Test void guardedPatternsBeforeJava21() { ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("GuardedPatterns.java")); - assertThat(thrown.getMessage(), containsString("Patterns in switch statements is a preview feature of JDK 20, you should select your language version accordingly")); + assertThat(thrown.getMessage(), containsString("Patterns in switch statements are a feature of Java 21, you should select your language version accordingly")); } @Test @@ -78,7 +78,7 @@ class Java21TreeDumpTest extends BaseJavaTreeDumpTest { @Test void patternsInSwitchLabelsBeforeJava21() { ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("PatternsInSwitchLabels.java")); - assertThat(thrown.getMessage(), containsString("Patterns in switch statements is a preview feature of JDK 20, you should select your language version accordingly")); + assertThat(thrown.getMessage(), containsString("Patterns in switch statements are a feature of Java 21, you should select your language version accordingly")); } @Test @@ -99,7 +99,7 @@ class Java21TreeDumpTest extends BaseJavaTreeDumpTest { @Test void recordPatternsJepBeforeJava21() { ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("Jep440_RecordPatterns.java")); - assertThat(thrown.getMessage(), containsString("Record patterns is a preview feature of JDK 20, you should select your language version accordingly")); + assertThat(thrown.getMessage(), containsString("Record patterns are a feature of Java 21, you should select your language version accordingly")); } @Test @@ -110,7 +110,7 @@ class Java21TreeDumpTest extends BaseJavaTreeDumpTest { @Test void recordPatternsBeforeJava21() { ParseException thrown = assertThrows(ParseException.class, () -> java20.parseResource("RecordPatterns.java")); - assertThat(thrown.getMessage(), containsString("Record patterns is a preview feature of JDK 20, you should select your language version accordingly")); + assertThat(thrown.getMessage(), containsString("Record patterns are a feature of Java 21, you should select your language version accordingly")); } @Test From fbb9da24f214a40d0235c48cd3d0992ac245c889 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 11:04:54 +0100 Subject: [PATCH 08/39] [java] Update Tests for JEP 459 String Templates TemplateFragment now has an attribute "content". --- docs/pages/release_notes.md | 2 + pmd-java/etc/grammar/Java.jjt | 16 +- .../pmd/lang/java/ast/ASTTemplate.java | 7 +- .../lang/java/ast/ASTTemplateExpression.java | 7 +- .../lang/java/ast/ASTTemplateFragment.java | 18 +- .../ast/internal/LanguageLevelChecker.java | 7 +- .../java/ast/Java22PreviewTreeDumpTest.java | 104 +++ .../java21p/Jep430_StringTemplates.txt | 160 ++-- .../Jep443_UnnamedPatternsAndVariables.java | 123 +++ .../Jep443_UnnamedPatternsAndVariables.txt | 608 +++++++++++++++ .../Jep443_UnnamedPatternsAndVariables2.java | 26 + .../java22p/Jep445_UnnamedClasses1.java | 13 + .../java22p/Jep445_UnnamedClasses1.txt | 13 + .../java22p/Jep445_UnnamedClasses2.java | 15 + .../java22p/Jep445_UnnamedClasses2.txt | 21 + .../java22p/Jep445_UnnamedClasses3.java | 15 + .../java22p/Jep445_UnnamedClasses3.txt | 19 + .../java22p/Jep459_StringTemplates.java | 194 +++++ .../java22p/Jep459_StringTemplates.txt | 707 ++++++++++++++++++ 19 files changed, 1976 insertions(+), 99 deletions(-) create mode 100644 pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.txt create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.txt create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.txt create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.txt create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 8f567c6be6..e9df137ccc 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -238,6 +238,8 @@ The rules have been moved into categories with PMD 6. * {%jdoc java::lang.java.ast.ASTPattern %}, {%jdoc java::lang.java.ast.ASTRecordPattern %}, {%jdoc java::lang.java.ast.ASTTypePattern %}, {%jdoc java::lang.java.ast.ASTUnnamedPattern %} - method `getParenthesisDepth()` has been removed. +* {%jdoc java::lang.java.ast.ASTTemplateFragment %}: To get the content of the template, use now + {%jdoc java::lang.java.ast.ASTTemplateFragment#getContent() %} or `@Content` instead of `getImage()`/`@Image`. **New API** diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 69522d60fe..111c4cc2a1 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,6 @@ /** + * Support "JEP 459: String Templates (Second Preview)" (Java 22) + * Use ASTTemplate.setContent instead of setImage. * Remove support for Record pattern in enhanced for statements. This was only a Java 20 Preview feature. * Remove support for ParenthesizedPatterns. This was only a Java 20 Preview feature. * Andreas Dangel 02/2024 @@ -1053,7 +1055,7 @@ TOKEN : // In order to produce the correct token sequence, the ambiguity needs to be resolved using the context. // That means, that STRING_TEMPLATE_MID/END and TEXT_BLOCK_TEMPLATE_MID/END could actually be a closing bracket ("}"). // Additionally, a STRING_TEMPLATE_MID could be a TEXT_BLOCK_TEMPLATE_MID and the other way round. -// See JLS 3.13 Fragments (Java 21 Preview) +// See JLS 3.13 Fragments (Java 21 Preview and Java 22 Preview) TOKEN : { @@ -2336,10 +2338,10 @@ void StringTemplate() #void : { { tokenContexts.push(TokenContext.STRING_TEMPLATE); } - { setLastTokenImage(jjtThis); } #TemplateFragment + { jjtThis.setContent(getToken(0).getImage()); } #TemplateFragment EmbeddedExpression() - ( { setLastTokenImage(jjtThis); } #TemplateFragment EmbeddedExpression() )* - { setLastTokenImage(jjtThis); } #TemplateFragment + ( { jjtThis.setContent(getToken(0).getImage()); } #TemplateFragment EmbeddedExpression() )* + { jjtThis.setContent(getToken(0).getImage()); } #TemplateFragment { tokenContexts.pop(); } } @@ -2349,10 +2351,10 @@ void TextBlockTemplate() #void : { { tokenContexts.push(TokenContext.TEXT_BLOCK_TEMPLATE); } - { setLastTokenImage(jjtThis); } #TemplateFragment + { jjtThis.setContent(getToken(0).getImage()); } #TemplateFragment EmbeddedExpression() - ( { setLastTokenImage(jjtThis); } #TemplateFragment EmbeddedExpression() )* - { setLastTokenImage(jjtThis); } #TemplateFragment + ( { jjtThis.setContent(getToken(0).getImage()); } #TemplateFragment EmbeddedExpression() )* + { jjtThis.setContent(getToken(0).getImage()); } #TemplateFragment { tokenContexts.pop(); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplate.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplate.java index 15c2c72a85..13decf984d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplate.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplate.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.java.ast; import net.sourceforge.pmd.annotation.Experimental; /** - * This is a Java 21 Preview feature. + * This is a Java 21/22 Preview feature. * *
  *
@@ -15,9 +15,10 @@ import net.sourceforge.pmd.annotation.Experimental;
  *
  * 
* - * @see JEP 430: String Templates (Preview) + * @see JEP 430: String Templates (Preview) (Java 21) + * @see JEP 459: String Templates (Second Preview) (Java 22) */ -@Experimental +@Experimental("String templates is a Java 21/22 Preview feature") public final class ASTTemplate extends AbstractJavaNode { ASTTemplate(int i) { super(i); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateExpression.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateExpression.java index 76a91b8e0b..ef2b512b09 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateExpression.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateExpression.java @@ -8,7 +8,7 @@ import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; /** - * This is a Java 21 Preview feature. + * This is a Java 21/22 Preview feature. * *
  *
@@ -17,9 +17,10 @@ import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr
  *
  * 
* - * @see JEP 430: String Templates (Preview) + * @see JEP 430: String Templates (Preview) (Java 21) + * @see JEP 459: String Templates (Second Preview) (Java 22) */ -@Experimental +@Experimental("String templates is a Java 21/22 Preview feature") public final class ASTTemplateExpression extends AbstractJavaExpr { ASTTemplateExpression(int i) { super(i); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateFragment.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateFragment.java index 8bb1c40b87..2ecf0cc3fc 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateFragment.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTTemplateFragment.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.java.ast; import net.sourceforge.pmd.annotation.Experimental; /** - * This is a Java 21 Preview feature. + * This is a Java 21/22 Preview feature. * *
  *
@@ -16,10 +16,13 @@ import net.sourceforge.pmd.annotation.Experimental;
  *
  * 
* - * @see JEP 430: String Templates (Preview) + * @see JEP 430: String Templates (Preview) (Java 21) + * @see JEP 459: String Templates (Second Preview) (Java 22) */ -@Experimental +@Experimental("String templates is a Java 21/22 Preview feature") public final class ASTTemplateFragment extends AbstractJavaNode { + private String content; + ASTTemplateFragment(int i) { super(i); } @@ -28,4 +31,13 @@ public final class ASTTemplateFragment extends AbstractJavaNode { protected R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); } + + public String getContent() { + return content; + } + + void setContent(String content) { + this.content = content; + } + } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java index e6dbcd8437..a9dd43a843 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java @@ -125,20 +125,21 @@ public class LanguageLevelChecker { /** * String Templates. * @see JEP 430: String Templates (Preview) (Java 21) + * @see JEP 459: String Templates (Second Preview) (Java 22) */ - STRING_TEMPLATES(21, 21, false), + STRING_TEMPLATES(21, 22, false), /** * Unnamed patterns and variables. * @see JEP 443: Unnamed patterns and variables (Preview) (Java 21) */ - UNNAMED_PATTERNS_AND_VARIABLES(21, 21, false), + UNNAMED_PATTERNS_AND_VARIABLES(21, 22, false), /** * Unnamed Classes and Instance Main Methods * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) (Java 21) */ - UNNAMED_CLASSES(21, 21, false), + UNNAMED_CLASSES(21, 22, false), ; // SUPPRESS CHECKSTYLE enum trailing semi is awesome diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java new file mode 100644 index 0000000000..6d9a59e087 --- /dev/null +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java @@ -0,0 +1,104 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.ast; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +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; +import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; +import net.sourceforge.pmd.lang.java.types.JTypeMirror; + +class Java22PreviewTreeDumpTest extends BaseJavaTreeDumpTest { + private final JavaParsingHelper java22p = + JavaParsingHelper.DEFAULT.withDefaultVersion("22-preview") + .withResourceContext(Java22PreviewTreeDumpTest.class, "jdkversiontests/java22p/"); + private final JavaParsingHelper java22 = java22p.withDefaultVersion("22"); + + @Override + public BaseParsingHelper getParser() { + return java22p; + } + + @Test + void jep459TemplateProcessors() { + doTest("Jep459_StringTemplates"); + } + + @Test + void jep459TemplateProcessorsBeforeJava22Preview() { + ParseException thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep459_StringTemplates.java")); + assertThat(thrown.getMessage(), containsString("String templates is a preview feature of JDK 22, you should select your language version accordingly")); + } + + @Test + void jep459TemplateExpressionType() { + ASTCompilationUnit unit = java22p.parse("class Foo {{ int i = 1; String s = STR.\"i = \\{i}\"; }}"); + ASTTemplateExpression templateExpression = unit.descendants(ASTTemplateExpression.class).first(); + JTypeMirror typeMirror = templateExpression.getTypeMirror(); + assertEquals("java.lang.String", ((JClassSymbol) typeMirror.getSymbol()).getCanonicalName()); + } + + @Test + void unnamedPatternsAndVariables() { + doTest("Jep443_UnnamedPatternsAndVariables"); + } + + @Test + void unnamedPatternsAndVariablesBeforeJava22Preview() { + ParseException thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep443_UnnamedPatternsAndVariables.java")); + assertThat(thrown.getMessage(), containsString("Since Java 9, '_' is reserved and cannot be used as an identifier")); + + thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep443_UnnamedPatternsAndVariables2.java")); + assertThat(thrown.getMessage(), containsString("Unnamed patterns and variables is a preview feature of JDK 22, you should select your language version accordingly")); + } + + @Test + void unnamedClasses1() { + doTest("Jep445_UnnamedClasses1"); + ASTCompilationUnit compilationUnit = java22p.parseResource("Jep445_UnnamedClasses1.java"); + assertTrue(compilationUnit.isUnnamedClass()); + ASTMethodCall methodCall = compilationUnit.descendants(ASTMethodCall.class).first(); + assertNotNull(methodCall.getTypeMirror()); + } + + @Test + void unnamedClasses2() { + doTest("Jep445_UnnamedClasses2"); + } + + @Test + void unnamedClasses3() { + doTest("Jep445_UnnamedClasses3"); + } + + @Test + void unnamedClassesBeforeJava22Preview() { + ParseException thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep445_UnnamedClasses1.java")); + assertThat(thrown.getMessage(), containsString("Unnamed classes is a preview feature of JDK 22, you should select your language version accordingly")); + } + + @Test + void testOrdinaryCompilationUnit() { + ASTCompilationUnit compilationUnit = java22.parse("public class Foo { public static void main(String[] args) {}}"); + assertFalse(compilationUnit.isUnnamedClass()); + } + + @Test + void testModularCompilationUnit() { + ASTCompilationUnit compilationUnit = java22.parse("module foo {}"); + assertFalse(compilationUnit.isUnnamedClass()); + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep430_StringTemplates.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep430_StringTemplates.txt index 1c58280187..1ecf0c1a3b 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep430_StringTemplates.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep430_StringTemplates.txt @@ -48,11 +48,11 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"\\{"] + | | +- TemplateFragment[@Content = "\"\\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "firstName", @Name = "firstName", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "} \\{"] + | | +- TemplateFragment[@Content = "} \\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lastName", @Name = "lastName", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}\""] + | | +- TemplateFragment[@Content = "}\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -61,11 +61,11 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"\\{"] + | | +- TemplateFragment[@Content = "\"\\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lastName", @Name = "lastName", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}, \\{"] + | | +- TemplateFragment[@Content = "}, \\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "firstName", @Name = "firstName", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}\""] + | | +- TemplateFragment[@Content = "}\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] @@ -83,15 +83,15 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"\\{"] + | | +- TemplateFragment[@Content = "\"\\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "} + \\{"] + | | +- TemplateFragment[@Content = "} + \\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "} = \\{"] + | | +- TemplateFragment[@Content = "} = \\{"] | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}\""] + | | +- TemplateFragment[@Content = "}\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -100,10 +100,10 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"You have a \\{"] + | | +- TemplateFragment[@Content = "\"You have a \\{"] | | +- MethodCall[@CompileTimeConstant = false, @Image = "getOfferType", @MethodName = "getOfferType", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ArgumentList[@Empty = true, @Size = 0] - | | +- TemplateFragment[@Image = "} waiting for you!\""] + | | +- TemplateFragment[@Content = "} waiting for you!\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "Request"] @@ -123,16 +123,16 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"Access at \\{"] + | | +- TemplateFragment[@Content = "\"Access at \\{"] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "date", @Name = "date", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "req", @Name = "req", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "} \\{"] + | | +- TemplateFragment[@Content = "} \\{"] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "time", @Name = "time", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "req", @Name = "req", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "} from \\{"] + | | +- TemplateFragment[@Content = "} from \\{"] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "ipAddress", @Name = "ipAddress", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "req", @Name = "req", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}\""] + | | +- TemplateFragment[@Content = "}\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -175,16 +175,16 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"The file \\{"] + | | +- TemplateFragment[@Content = "\"The file \\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "filePath", @Name = "filePath", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "} \\{"] + | | +- TemplateFragment[@Content = "} \\{"] | | +- ConditionalExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "exists", @MethodName = "exists", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "file", @Name = "file", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- ArgumentList[@Empty = true, @Size = 0] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "does", @Empty = false, @Image = "\"does\"", @Length = 4, @LiteralText = "\"does\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "does not", @Empty = false, @Image = "\"does not\"", @Length = 8, @LiteralText = "\"does not\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - | | +- TemplateFragment[@Image = "} exist\""] + | | +- TemplateFragment[@Content = "} exist\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -193,7 +193,7 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"The time is \\{"] + | | +- TemplateFragment[@Content = "\"The time is \\{"] | | +- MethodCall[@CompileTimeConstant = false, @Image = "format", @MethodName = "format", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "ofPattern", @MethodName = "ofPattern", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -205,7 +205,7 @@ | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- ClassType[@FullyQualified = false, @SimpleName = "LocalTime"] | | | +- ArgumentList[@Empty = true, @Size = 0] - | | +- TemplateFragment[@Image = "} right now\""] + | | +- TemplateFragment[@Content = "} right now\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] @@ -220,19 +220,19 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"\\{"] + | | +- TemplateFragment[@Content = "\"\\{"] | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}, \\{"] + | | +- TemplateFragment[@Content = "}, \\{"] | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}, \\{"] + | | +- TemplateFragment[@Content = "}, \\{"] | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}, \\{"] + | | +- TemplateFragment[@Content = "}, \\{"] | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}\""] + | | +- TemplateFragment[@Content = "}\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ArrayType[@ArrayDepth = 1] @@ -253,24 +253,24 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"\\{"] + | | +- TemplateFragment[@Content = "\"\\{"] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | | +- TemplateFragment[@Image = "}, \\{"] + | | +- TemplateFragment[@Content = "}, \\{"] | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- Template[] - | | | +- TemplateFragment[@Image = "\"\\{"] + | | | +- TemplateFragment[@Content = "\"\\{"] | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @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] - | | | +- TemplateFragment[@Image = "}, \\{"] + | | | +- TemplateFragment[@Content = "}, \\{"] | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- 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] - | | | +- TemplateFragment[@Image = "}\""] - | | +- TemplateFragment[@Image = "}\""] + | | | +- TemplateFragment[@Content = "}\""] + | | +- TemplateFragment[@Content = "}\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -279,24 +279,24 @@ | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | +- Template[] - | +- TemplateFragment[@Image = "\"\\{"] + | +- TemplateFragment[@Content = "\"\\{"] | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | +- TemplateFragment[@Image = "}, \\{"] + | +- TemplateFragment[@Content = "}, \\{"] | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"\\{"] + | | +- TemplateFragment[@Content = "\"\\{"] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @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] - | | +- TemplateFragment[@Image = "}, \\{"] + | | +- TemplateFragment[@Content = "}, \\{"] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- 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] - | | +- TemplateFragment[@Image = "}\""] - | +- TemplateFragment[@Image = "}\""] + | | +- TemplateFragment[@Content = "}\""] + | +- TemplateFragment[@Content = "}\""] +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "getOfferType", @Name = "getOfferType", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -329,11 +329,11 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"\"\"\n \n \n \\{"] + | | +- TemplateFragment[@Content = "\"\"\"\n <html>\n <head>\n <title>\\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "title", @Name = "title", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}\n \n \n

\\{"] + | | +- TemplateFragment[@Content = "}\n \n \n

\\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "text", @Name = "text", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}

\n \n \n \"\"\""] + | | +- TemplateFragment[@Content = "}

\n \n \n \"\"\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -360,76 +360,76 @@ | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | +- Template[] - | +- TemplateFragment[@Image = "\"\"\"\n {\n \"name\": \"\\{"] + | +- TemplateFragment[@Content = "\"\"\"\n {\n \"name\": \"\\{"] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] - | +- TemplateFragment[@Image = "}\",\n \"phone\": \"\\{"] + | +- TemplateFragment[@Content = "}\",\n \"phone\": \"\\{"] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "phone", @Name = "phone", @ParenthesisDepth = 0, @Parenthesized = false] - | +- TemplateFragment[@Image = "}\",\n \"address\": \"\\{"] + | +- TemplateFragment[@Content = "}\",\n \"address\": \"\\{"] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "address", @Name = "address", @ParenthesisDepth = 0, @Parenthesized = false] - | +- TemplateFragment[@Image = "}\"\n }\n \"\"\";\n /*\n | \"\"\"\n | {\n | \"name\": \"Joan Smith\",\n | \"phone\": \"555-123-4567\",\n | \"address\": \"1 Maple Drive, Anytown\"\n | }\n | \"\"\"\n */\n\n record Rectangle(String name, double width, double height) {\n double area() {\n return width * height;\n }\n }\n Rectangle[] zone = new Rectangle[] {\n new Rectangle(\"Alfa\", 17.8, 31.4),\n new Rectangle(\"Bravo\", 9.6, 12.4),\n new Rectangle(\"Charlie\", 7.1, 11.23),\n };\n String table = STR.\"\"\"\n Description Width Height Area\n \\{"] + | +- TemplateFragment[@Content = "}\"\n }\n \"\"\";\n /*\n | \"\"\"\n | {\n | \"name\": \"Joan Smith\",\n | \"phone\": \"555-123-4567\",\n | \"address\": \"1 Maple Drive, Anytown\"\n | }\n | \"\"\"\n */\n\n record Rectangle(String name, double width, double height) {\n double area() {\n return width * height;\n }\n }\n Rectangle[] zone = new Rectangle[] {\n new Rectangle(\"Alfa\", 17.8, 31.4),\n new Rectangle(\"Bravo\", 9.6, 12.4),\n new Rectangle(\"Charlie\", 7.1, 11.23),\n };\n String table = STR.\"\"\"\n Description Width Height Area\n \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n \\{"] + | +- TemplateFragment[@Content = "}\n \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n \\{"] + | +- TemplateFragment[@Content = "}\n \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- 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] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- 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] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- 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] - | +- TemplateFragment[@Image = "} \\{"] + | +- TemplateFragment[@Content = "} \\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- 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] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n Total \\{"] + | +- TemplateFragment[@Content = "}\n Total \\{"] | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] @@ -447,7 +447,7 @@ | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- 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] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n \"\"\""] + | +- TemplateFragment[@Content = "}\n \"\"\""] +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "FMTTemplateProcessor", @Name = "FMTTemplateProcessor", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- VoidType[] @@ -520,75 +520,75 @@ | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "FMT", @Name = "FMT", @ParenthesisDepth = 0, @Parenthesized = false] | +- Template[] - | +- TemplateFragment[@Image = "\"\"\"\n Description Width Height Area\n %-12s\\{"] + | +- TemplateFragment[@Content = "\"\"\"\n Description Width Height Area\n %-12s\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n %-12s\\{"] + | +- TemplateFragment[@Content = "}\n %-12s\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n %-12s\\{"] + | +- TemplateFragment[@Content = "}\n %-12s\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- 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] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- 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] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | +- 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] - | +- TemplateFragment[@Image = "} %7.2f\\{"] + | +- TemplateFragment[@Content = "} %7.2f\\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- 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] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n \\{"] + | +- TemplateFragment[@Content = "}\n \\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "repeat", @MethodName = "repeat", @ParenthesisDepth = 0, @Parenthesized = false] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " ", @Empty = false, @Image = "\" \"", @Length = 1, @LiteralText = "\" \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- ArgumentList[@Empty = false, @Size = 1] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "28", @IntLiteral = true, @Integral = true, @LiteralText = "28", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 28.0, @ValueAsFloat = 28.0, @ValueAsInt = 28, @ValueAsLong = 28] - | +- TemplateFragment[@Image = "} Total %7.2f\\{"] + | +- TemplateFragment[@Content = "} Total %7.2f\\{"] | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] @@ -606,7 +606,7 @@ | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- 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] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\n \"\"\""] + | +- TemplateFragment[@Content = "}\n \"\"\""] +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "ensuringSafety", @Name = "ensuringSafety", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- VoidType[] @@ -626,9 +626,9 @@ | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "RAW", @Name = "RAW", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Template[] - | | +- TemplateFragment[@Image = "\"My name is \\{"] + | | +- TemplateFragment[@Content = "\"My name is \\{"] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] - | | +- TemplateFragment[@Image = "}\""] + | | +- TemplateFragment[@Content = "}\""] | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassType[@FullyQualified = false, @SimpleName = "String"] @@ -681,15 +681,15 @@ | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] | +- Template[] - | +- TemplateFragment[@Image = "\"Welcome, \\{"] + | +- TemplateFragment[@Content = "\"Welcome, \\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "firstName", @MethodName = "firstName", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "user", @Name = "user", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}, to your account \\{"] + | +- TemplateFragment[@Content = "}, to your account \\{"] | +- MethodCall[@CompileTimeConstant = false, @Image = "accountNumber", @MethodName = "accountNumber", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "user", @Name = "user", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] - | +- TemplateFragment[@Image = "}\""] + | +- TemplateFragment[@Content = "}\""] +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "emptyEmbeddedExpression", @Name = "emptyEmbeddedExpression", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] +- VoidType[] @@ -703,5 +703,5 @@ +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] +- Template[] - +- TemplateFragment[@Image = "\"Test \\{"] - +- TemplateFragment[@Image = "}\""] + +- TemplateFragment[@Content = "\"Test \\{"] + +- TemplateFragment[@Content = "}\""] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.java new file mode 100644 index 0000000000..dc2e9f4c7a --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.java @@ -0,0 +1,123 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + + +import java.util.ArrayDeque; +import java.util.List; +import java.util.Queue; +import java.util.stream.Collectors; + +/** + * @see JEP 443: Unnamed Patterns and Variables (Preview) + */ +class Jep443_UnamedPatternsAndVariables { + record Point(int x, int y) { } + enum Color { RED, GREEN, BLUE } + record ColoredPoint(Point p, Color c) { } + + void unnamedPatterns1() { + ColoredPoint r = new ColoredPoint(new Point(3,4), Color.GREEN); + + if (r instanceof ColoredPoint(Point p, Color _)) { + System.out.println(p.x() + " " + p.y()); + } + + if (r instanceof ColoredPoint(Point(int x, int y), _)) { + System.out.println(x + " " + y); + } + } + + sealed abstract class Ball permits RedBall, BlueBall, GreenBall { } + final class RedBall extends Ball { } + final class BlueBall extends Ball { } + final class GreenBall extends Ball { } + + record Box(T content) { } + + void unnamedPatterns2() { + Box b = new Box<>(new RedBall()); + switch (b) { + case Box(RedBall _) -> processBox(b); + case Box(BlueBall _) -> processBox(b); + case Box(GreenBall _) -> stopProcessing(); + } + + switch (b) { + case Box(RedBall _), Box(BlueBall _) -> processBox(b); + case Box(GreenBall _) -> stopProcessing(); + case Box(_) -> pickAnotherBox(); + } + + int x = 42; + switch (b) { + // multiple patterns guarded by one guard + case Box(RedBall _), Box(BlueBall _) when x == 42 -> processBox(b); + case Box(_) -> pickAnotherBox(); + } + } + + private void processBox(Box b) {} + private void stopProcessing() {} + private void pickAnotherBox() {} + + class Order {} + private static final int LIMIT = 10; + private int sideEffect() { + return 0; + } + + void unnamedVariables(List orders) { + int total = 0; + for (Order _ : orders) { + if (total < LIMIT) { + total++; + } + } + System.out.println("total: " + total); + + for (int i = 0, _ = sideEffect(); i < 10; i++) { + System.out.println(i); + } + + Queue q = new ArrayDeque<>(); // x1, y1, z1, x2, y2, z2 .. + while (q.size() >= 3) { + int x = q.remove(); + int y = q.remove(); + int _ = q.remove(); // z is unused + Point p = new Point(x, y); + } + while (q.size() >= 3) { + var x = q.remove(); + var _ = q.remove(); + var _ = q.remove(); + Point p = new Point(x, 0); + } + } + + static class ScopedContext implements AutoCloseable { + @Override + public void close() { } + public static ScopedContext acquire() { + return new ScopedContext(); + } + } + + void unusedVariables2() { + try (var _ = ScopedContext.acquire()) { + //... acquiredContext not used ... + } + + String s = "123"; + try { + int i = Integer.parseInt(s); + System.out.println(i); + } catch (NumberFormatException _) { + System.out.println("Bad number: " + s); + } catch (Exception _) { + System.out.println("error..."); + } + + List.of("a", "b").stream().collect(Collectors.toMap(String::toUpperCase, _ -> "NO_DATA")); + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.txt new file mode 100644 index 0000000000..fcb1e37135 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.txt @@ -0,0 +1,608 @@ ++- CompilationUnit[@PackageName = ""] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.ArrayDeque", @ImportedSimpleName = "ArrayDeque", @PackageName = "java.util", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.List", @ImportedSimpleName = "List", @PackageName = "java.util", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.Queue", @ImportedSimpleName = "Queue", @PackageName = "java.util", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.stream.Collectors", @ImportedSimpleName = "Collectors", @PackageName = "java.util.stream", @Static = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables", @CanonicalName = "Jep443_UnamedPatternsAndVariables", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Jep443_UnamedPatternsAndVariables", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PACKAGE] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- ClassBody[@Empty = false, @Size = 19] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Point", @CanonicalName = "Jep443_UnamedPatternsAndVariables.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 = "Jep443_UnamedPatternsAndVariables$Color", @CanonicalName = "Jep443_UnamedPatternsAndVariables.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 = "Jep443_UnamedPatternsAndVariables$ColoredPoint", @CanonicalName = "Jep443_UnamedPatternsAndVariables.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] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "unnamedPatterns1", @Name = "unnamedPatterns1", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- VoidType[] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- 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 = "ColoredPoint"] + | | +- VariableDeclarator[@Initializer = true, @Name = "r"] + | | +- 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 = "r", @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 = "ColoredPoint"] + | | +- ArgumentList[@Empty = false, @Size = 2] + | | +- 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 = "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] + | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "GREEN", @Name = "GREEN", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Color"] + | +- IfStatement[@Else = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- RecordPattern[] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] + | | | +- PatternList[@Empty = false, @Size = 2] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @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, @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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- 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] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "x", @MethodName = "x", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " ", @Empty = false, @Image = "\" \"", @Length = 1, @LiteralText = "\" \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "y", @MethodName = "y", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- IfStatement[@Else = false] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "r", @Name = "r", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- RecordPattern[] + | | +- ClassType[@FullyQualified = false, @SimpleName = "ColoredPoint"] + | | +- PatternList[@Empty = false, @Size = 2] + | | +- RecordPattern[] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] + | | | +- PatternList[@Empty = false, @Size = 2] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- 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 = false, @LambdaParameter = false, @LocalVariable = false, @Name = "x", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | +- 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 = false, @LambdaParameter = false, @LocalVariable = false, @Name = "y", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- UnnamedPattern[] + | +- 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 = "x", @Name = "x", @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 = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] + +- ClassDeclaration[@Abstract = true, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Ball", @CanonicalName = "Jep443_UnamedPatternsAndVariables.Ball", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Ball", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{sealed, abstract}", @ExplicitModifiers = "{sealed, abstract}"] + | +- PermitsList[@Empty = false, @Size = 3] + | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "GreenBall"] + | +- ClassBody[@Empty = true, @Size = 0] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$RedBall", @CanonicalName = "Jep443_UnamedPatternsAndVariables.RedBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RedBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] + | +- ExtendsList[@Empty = false, @Size = 1] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] + | +- ClassBody[@Empty = true, @Size = 0] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$BlueBall", @CanonicalName = "Jep443_UnamedPatternsAndVariables.BlueBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "BlueBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] + | +- ExtendsList[@Empty = false, @Size = 1] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] + | +- ClassBody[@Empty = true, @Size = 0] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$GreenBall", @CanonicalName = "Jep443_UnamedPatternsAndVariables.GreenBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "GreenBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] + | +- ExtendsList[@Empty = false, @Size = 1] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] + | +- ClassBody[@Empty = true, @Size = 0] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Box", @CanonicalName = "Jep443_UnamedPatternsAndVariables.Box", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Box", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"] + | +- TypeParameters[@Empty = false, @Size = 1] + | | +- TypeParameter[@Image = "T", @Name = "T", @TypeBound = true] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] + | +- RecordComponentList[@Empty = false, @Size = 1, @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 = "content", @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 = "unnamedPatterns2", @Name = "unnamedPatterns2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- 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 = "Box"] + | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] + | | | +- WildcardType[@LowerBound = false, @UpperBound = true] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] + | | +- VariableDeclarator[@Initializer = true, @Name = "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 = true, @Name = "b", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = true, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | +- TypeArguments[@Diamond = true, @Empty = true, @Size = 0] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- SwitchArrowBranch[@Default = false] + | | | +- SwitchLabel[@Default = false] + | | | | +- RecordPattern[] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | | +- PatternList[@Empty = false, @Size = 1] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] + | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "processBox", @MethodName = "processBox", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- SwitchArrowBranch[@Default = false] + | | | +- SwitchLabel[@Default = false] + | | | | +- RecordPattern[] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | | +- PatternList[@Empty = false, @Size = 1] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] + | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "processBox", @MethodName = "processBox", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- SwitchArrowBranch[@Default = false] + | | +- SwitchLabel[@Default = false] + | | | +- RecordPattern[] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | +- PatternList[@Empty = false, @Size = 1] + | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "GreenBall"] + | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "stopProcessing", @MethodName = "stopProcessing", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- SwitchArrowBranch[@Default = false] + | | | +- SwitchLabel[@Default = false] + | | | | +- RecordPattern[] + | | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | | | +- PatternList[@Empty = false, @Size = 1] + | | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] + | | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | | +- RecordPattern[] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | | +- PatternList[@Empty = false, @Size = 1] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] + | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "processBox", @MethodName = "processBox", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- SwitchArrowBranch[@Default = false] + | | | +- SwitchLabel[@Default = false] + | | | | +- RecordPattern[] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | | +- PatternList[@Empty = false, @Size = 1] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "GreenBall"] + | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "stopProcessing", @MethodName = "stopProcessing", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- SwitchArrowBranch[@Default = false] + | | +- SwitchLabel[@Default = false] + | | | +- RecordPattern[] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | +- PatternList[@Empty = false, @Size = 1] + | | | +- UnnamedPattern[] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "pickAnotherBox", @MethodName = "pickAnotherBox", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | +- VariableDeclarator[@Initializer = true, @Name = "x"] + | | +- 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 = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- 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] + | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] + | +- SwitchArrowBranch[@Default = false] + | | +- SwitchLabel[@Default = false] + | | | +- RecordPattern[] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | | +- PatternList[@Empty = false, @Size = 1] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] + | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- RecordPattern[] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | | | +- PatternList[@Empty = false, @Size = 1] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] + | | | | +- 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 = "_", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- Guard[] + | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- 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] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "processBox", @MethodName = "processBox", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] + | +- SwitchArrowBranch[@Default = false] + | +- SwitchLabel[@Default = false] + | | +- RecordPattern[] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Box"] + | | +- PatternList[@Empty = false, @Size = 1] + | | +- UnnamedPattern[] + | +- MethodCall[@CompileTimeConstant = false, @Image = "pickAnotherBox", @MethodName = "pickAnotherBox", @ParenthesisDepth = 0, @Parenthesized = false] + | +- ArgumentList[@Empty = true, @Size = 0] + +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "processBox", @Name = "processBox", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] + | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] + | +- 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 = "Box"] + | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] + | | | +- WildcardType[@LowerBound = false, @UpperBound = true] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] + | | +- 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 = "b", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = true, @Size = 0, @containsComment = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "stopProcessing", @Name = "stopProcessing", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] + | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] + | +- VoidType[] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = true, @Size = 0, @containsComment = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "pickAnotherBox", @Name = "pickAnotherBox", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] + | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] + | +- VoidType[] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = true, @Size = 0, @containsComment = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Order", @CanonicalName = "Jep443_UnamedPatternsAndVariables.Order", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Order", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- ClassBody[@Empty = true, @Size = 0] + +- FieldDeclaration[@EffectiveVisibility = Visibility.V_PRIVATE, @Static = true, @Visibility = Visibility.V_PRIVATE] + | +- ModifierList[@EffectiveModifiers = "{private, static, final}", @ExplicitModifiers = "{private, static, final}"] + | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | +- VariableDeclarator[@Initializer = true, @Name = "LIMIT"] + | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = true, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "LIMIT", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE] + | +- 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] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "sideEffect", @Name = "sideEffect", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = false] + | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] + | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- ReturnStatement[] + | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "unnamedVariables", @Name = "unnamedVariables", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- 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 = "List"] + | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Order"] + | | +- 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 = "orders", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 7, @containsComment = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | +- VariableDeclarator[@Initializer = true, @Name = "total"] + | | +- 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 = "total", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- ForeachStatement[] + | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Order"] + | | | +- VariableDeclarator[@Initializer = false, @Name = "_"] + | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = true, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "_", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "orders", @Name = "orders", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | | +- IfStatement[@Else = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.LT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "total", @Name = "total", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "LIMIT", @Name = "LIMIT", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | | +- ExpressionStatement[] + | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "total", @Name = "total", @ParenthesisDepth = 0, @Parenthesized = 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] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "total: ", @Empty = false, @Image = "\"total: \"", @Length = 7, @LiteralText = "\"total: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "total", @Name = "total", @ParenthesisDepth = 0, @Parenthesized = false] + | +- ForStatement[] + | | +- ForInit[] + | | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | | +- VariableDeclarator[@Initializer = true, @Name = "i"] + | | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = true, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "i", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | | +- VariableDeclarator[@Initializer = true, @Name = "_"] + | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = true, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "_", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "sideEffect", @MethodName = "sideEffect", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.LT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- 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] + | | +- ForUpdate[] + | | | +- StatementExpressionList[@Empty = false, @Size = 1] + | | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "i", @Name = "i", @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 = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Queue"] + | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Integer"] + | | +- VariableDeclarator[@Initializer = true, @Name = "q"] + | | +- 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 = "q", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = true, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "ArrayDeque"] + | | | +- TypeArguments[@Diamond = true, @Empty = true, @Size = 0] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- WhileStatement[] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GE, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "size", @MethodName = "size", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- 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] + | | +- Block[@Empty = false, @Size = 4, @containsComment = false] + | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | | +- VariableDeclarator[@Initializer = true, @Name = "x"] + | | | +- 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 = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "remove", @MethodName = "remove", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | | +- VariableDeclarator[@Initializer = true, @Name = "y"] + | | | +- 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 = "y", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "remove", @MethodName = "remove", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | | +- VariableDeclarator[@Initializer = true, @Name = "_"] + | | | +- 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 = "_", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "remove", @MethodName = "remove", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] + | | +- VariableDeclarator[@Initializer = true, @Name = "p"] + | | +- 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 = "p", @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 = "Point"] + | | +- ArgumentList[@Empty = false, @Size = 2] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] + | +- WhileStatement[] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GE, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "size", @MethodName = "size", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- 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] + | +- Block[@Empty = false, @Size = 4, @containsComment = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- VariableDeclarator[@Initializer = true, @Name = "x"] + | | +- 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 = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "remove", @MethodName = "remove", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- VariableDeclarator[@Initializer = true, @Name = "_"] + | | +- 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 = "_", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "remove", @MethodName = "remove", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- VariableDeclarator[@Initializer = true, @Name = "_"] + | | +- 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 = "_", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "remove", @MethodName = "remove", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "q", @Name = "q", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- ClassType[@FullyQualified = false, @SimpleName = "Point"] + | +- VariableDeclarator[@Initializer = true, @Name = "p"] + | +- 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 = "p", @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 = "Point"] + | +- ArgumentList[@Empty = false, @Size = 2] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] + | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$ScopedContext", @CanonicalName = "Jep443_UnamedPatternsAndVariables.ScopedContext", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "ScopedContext", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] + | +- ImplementsList[@Empty = false, @Size = 1] + | | +- ClassType[@FullyQualified = false, @SimpleName = "AutoCloseable"] + | +- ClassBody[@Empty = false, @Size = 2] + | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "close", @Name = "close", @Overridden = true, @Static = false, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true] + | | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | | | +- Annotation[@SimpleName = "Override"] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Override"] + | | +- VoidType[] + | | +- FormalParameters[@Empty = true, @Size = 0] + | | +- Block[@Empty = true, @Size = 0, @containsComment = false] + | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "acquire", @Name = "acquire", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = false] + | +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"] + | +- ClassType[@FullyQualified = false, @SimpleName = "ScopedContext"] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- ReturnStatement[] + | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | +- ClassType[@FullyQualified = false, @SimpleName = "ScopedContext"] + | +- ArgumentList[@Empty = true, @Size = 0] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "unusedVariables2", @Name = "unusedVariables2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- VoidType[] + +- FormalParameters[@Empty = true, @Size = 0] + +- Block[@Empty = false, @Size = 4, @containsComment = false] + +- TryStatement[@TryWithResources = true] + | +- ResourceList[@Empty = false, @Size = 1, @TrailingSemiColon = false] + | | +- Resource[@ConciseResource = false, @StableName = "_"] + | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = true, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{}"] + | | +- VariableDeclarator[@Initializer = true, @Name = "_"] + | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "_", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "acquire", @MethodName = "acquire", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "ScopedContext"] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- Block[@Empty = true, @Size = 0, @containsComment = true] + +- 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 = "s"] + | +- 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 = "s", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "123", @Empty = false, @Image = "\"123\"", @Length = 3, @LiteralText = "\"123\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + +- TryStatement[@TryWithResources = false] + | +- Block[@Empty = false, @Size = 2, @containsComment = false] + | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | | +- VariableDeclarator[@Initializer = true, @Name = "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 = true, @Name = "i", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "parseInt", @MethodName = "parseInt", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Integer"] + | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = 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 = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] + | +- CatchClause[] + | | +- CatchParameter[@EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Multicatch = false, @Name = "_", @Visibility = Visibility.V_PACKAGE] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "NumberFormatException"] + | | | +- 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 = "_", @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] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bad number: ", @Empty = false, @Image = "\"Bad number: \"", @Length = 12, @LiteralText = "\"Bad number: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] + | +- CatchClause[] + | +- CatchParameter[@EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Multicatch = false, @Name = "_", @Visibility = Visibility.V_PACKAGE] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Exception"] + | | +- 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 = "_", @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] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "error...", @Empty = false, @Image = "\"error...\"", @Length = 8, @LiteralText = "\"error...\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + +- ExpressionStatement[] + +- MethodCall[@CompileTimeConstant = false, @Image = "collect", @MethodName = "collect", @ParenthesisDepth = 0, @Parenthesized = false] + +- MethodCall[@CompileTimeConstant = false, @Image = "stream", @MethodName = "stream", @ParenthesisDepth = 0, @Parenthesized = false] + | +- MethodCall[@CompileTimeConstant = false, @Image = "of", @MethodName = "of", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "List"] + | | +- ArgumentList[@Empty = false, @Size = 2] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "b", @Empty = false, @Image = "\"b\"", @Length = 1, @LiteralText = "\"b\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- ArgumentList[@Empty = true, @Size = 0] + +- ArgumentList[@Empty = false, @Size = 1] + +- MethodCall[@CompileTimeConstant = false, @Image = "toMap", @MethodName = "toMap", @ParenthesisDepth = 0, @Parenthesized = false] + +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | +- ClassType[@FullyQualified = false, @SimpleName = "Collectors"] + +- ArgumentList[@Empty = false, @Size = 2] + +- MethodReference[@CompileTimeConstant = false, @ConstructorReference = false, @MethodName = "toUpperCase", @ParenthesisDepth = 0, @Parenthesized = false] + | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + +- LambdaExpression[@Arity = 1, @BlockBody = false, @CompileTimeConstant = false, @ExpressionBody = true, @ParenthesisDepth = 0, @Parenthesized = false] + +- LambdaParameterList[@Empty = false, @Size = 1] + | +- LambdaParameter[@EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @TypeInferred = true, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = true, @LocalVariable = false, @Name = "_", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_PACKAGE] + +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "NO_DATA", @Empty = false, @Image = "\"NO_DATA\"", @Length = 7, @LiteralText = "\"NO_DATA\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java new file mode 100644 index 0000000000..7d690d41e5 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java @@ -0,0 +1,26 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + + +import java.util.ArrayDeque; +import java.util.List; +import java.util.Queue; +import java.util.stream.Collectors; + +/** + * @see JEP 443: Unnamed Patterns and Variables (Preview) + */ +class Jep443_UnamedPatternsAndVariables2 { + record Point(int x, int y) { } + enum Color { RED, GREEN, BLUE } + record ColoredPoint(Point p, Color c) { } + + void unnamedPatterns1() { + ColoredPoint r = new ColoredPoint(new Point(3,4), Color.GREEN); + + if (r instanceof ColoredPoint(Point(int x, int y), _)) { + System.out.println(x + " " + y); + } + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.java new file mode 100644 index 0000000000..5a8891fd2f --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.java @@ -0,0 +1,13 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + + + +/** + * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) + */ + +void main() { + System.out.println("Hello World"); +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.txt new file mode 100644 index 0000000000..7b2ceabde1 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.txt @@ -0,0 +1,13 @@ ++- CompilationUnit[@PackageName = ""] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- VoidType[] + +- FormalParameters[@Empty = true, @Size = 0] + +- 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 = "Hello World", @Empty = false, @Image = "\"Hello World\"", @Length = 11, @LiteralText = "\"Hello World\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.java new file mode 100644 index 0000000000..49d30a40e1 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.java @@ -0,0 +1,15 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + + + +/** + * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) + */ + +String greeting() { return "Hello, World!"; } + +void main() { + System.out.println(greeting()); +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.txt new file mode 100644 index 0000000000..4b147ea7bf --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.txt @@ -0,0 +1,21 @@ ++- CompilationUnit[@PackageName = ""] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "greeting", @Name = "greeting", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- ReturnStatement[] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Hello, World!", @Empty = false, @Image = "\"Hello, World!\"", @Length = 13, @LiteralText = "\"Hello, World!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- VoidType[] + +- FormalParameters[@Empty = true, @Size = 0] + +- 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] + +- MethodCall[@CompileTimeConstant = false, @Image = "greeting", @MethodName = "greeting", @ParenthesisDepth = 0, @Parenthesized = false] + +- ArgumentList[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.java new file mode 100644 index 0000000000..9c4fcae3f7 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.java @@ -0,0 +1,15 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + + + +/** + * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) + */ + +String greeting = "Hello, World!"; + +void main() { + System.out.println(greeting); +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.txt new file mode 100644 index 0000000000..5e04a358e1 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.txt @@ -0,0 +1,19 @@ ++- CompilationUnit[@PackageName = ""] + +- FieldDeclaration[@EffectiveVisibility = Visibility.V_PACKAGE, @Static = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | +- VariableDeclarator[@Initializer = true, @Name = "greeting"] + | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = true, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "greeting", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PACKAGE] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Hello, World!", @Empty = false, @Image = "\"Hello, World!\"", @Length = 13, @LiteralText = "\"Hello, World!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- VoidType[] + +- FormalParameters[@Empty = true, @Size = 0] + +- 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 = "greeting", @Name = "greeting", @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.java new file mode 100644 index 0000000000..1d4cc98254 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.java @@ -0,0 +1,194 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +import static java.lang.StringTemplate.RAW; +import static java.util.FormatProcessor.FMT; + +import java.io.File; +import java.time.format.DateTimeFormatter; +import java.time.LocalTime; + +/** + * @see JEP 430: String Templates (Preview) (Java 21) + * @see JEP 459: String Templates (Second Preview) (Java 22) + */ +class Jep459_StringTemplates { + record Request(String date, String time, String ipAddress) {} + + static void STRTemplateProcessor() { + // Embedded expressions can be strings + String firstName = "Bill"; + String lastName = "Duck"; + String fullName = STR."\{firstName} \{lastName}"; + // | "Bill Duck" + String sortName = STR."\{lastName}, \{firstName}"; + // | "Duck, Bill" + + // Embedded expressions can perform arithmetic + int x = 10, y = 20; + String s1 = STR."\{x} + \{y} = \{x + y}"; + // | "10 + 20 = 30" + + // Embedded expressions can invoke methods and access fields + String s2 = STR."You have a \{getOfferType()} waiting for you!"; + // | "You have a gift waiting for you!" + Request req = new Request("2022-03-25", "15:34", "8.8.8.8"); + String t = STR."Access at \{req.date} \{req.time} from \{req.ipAddress}"; + //| "Access at 2022-03-25 15:34 from 8.8.8.8" + + String filePath = "tmp.dat"; + File file = new File(filePath); + String old = "The file " + filePath + " " + (file.exists() ? "does" : "does not") + " exist"; + String msg = STR."The file \{filePath} \{file.exists() ? "does" : "does not"} exist"; + // | "The file tmp.dat does exist" or "The file tmp.dat does not exist" + + // spread over multiple lines + String time = STR."The time is \{ + // The java.time.format package is very useful + DateTimeFormatter + .ofPattern("HH:mm:ss") + .format(LocalTime.now()) + } right now"; + // | "The time is 12:34:56 right now" + + // Left to right + // Embedded expressions can be postfix increment expressions + int index = 0; + String data = STR."\{index++}, \{index++}, \{index++}, \{index++}"; + // | "0, 1, 2, 3" + + // Embedded expression is a (nested) template expression + String[] fruit = { "apples", "oranges", "peaches" }; + String s3 = STR."\{fruit[0]}, \{STR."\{fruit[1]}, \{fruit[2]}"}"; + // | "apples, oranges, peaches" + String s4 = STR."\{fruit[0]}, \{ + STR."\{fruit[1]}, \{fruit[2]}" + }"; + } + + static String getOfferType() { return "_getOfferType_"; } + + static void multilineTemplateExpressions() { + String title = "My Web Page"; + String text = "Hello, world"; + String html = STR.""" + + + \{title} + + +

\{text}

+ + + """; + /* + | """ + | + | + | My Web Page + | + | + |

Hello, world

+ | + | + | """ + */ + + String name = "Joan Smith"; + String phone = "555-123-4567"; + String address = "1 Maple Drive, Anytown"; + String json = STR.""" + { + "name": "\{name}", + "phone": "\{phone}", + "address": "\{address}" + } + """; + /* + | """ + | { + | "name": "Joan Smith", + | "phone": "555-123-4567", + | "address": "1 Maple Drive, Anytown" + | } + | """ + */ + + record Rectangle(String name, double width, double height) { + double area() { + return width * height; + } + } + Rectangle[] zone = new Rectangle[] { + new Rectangle("Alfa", 17.8, 31.4), + new Rectangle("Bravo", 9.6, 12.4), + new Rectangle("Charlie", 7.1, 11.23), + }; + String table = STR.""" + Description Width Height Area + \{zone[0].name} \{zone[0].width} \{zone[0].height} \{zone[0].area()} + \{zone[1].name} \{zone[1].width} \{zone[1].height} \{zone[1].area()} + \{zone[2].name} \{zone[2].width} \{zone[2].height} \{zone[2].area()} + Total \{zone[0].area() + zone[1].area() + zone[2].area()} + """; + /* + | """ + | Description Width Height Area + | Alfa 17.8 31.4 558.92 + | Bravo 9.6 12.4 119.03999999999999 + | Charlie 7.1 11.23 79.733 + | Total 757.693 + | """ + */ + } + + static void FMTTemplateProcessor() { + record Rectangle(String name, double width, double height) { + double area() { + return width * height; + } + }; + Rectangle[] zone = new Rectangle[] { + new Rectangle("Alfa", 17.8, 31.4), + new Rectangle("Bravo", 9.6, 12.4), + new Rectangle("Charlie", 7.1, 11.23), + }; + String table = FMT.""" + Description Width Height Area + %-12s\{zone[0].name} %7.2f\{zone[0].width} %7.2f\{zone[0].height} %7.2f\{zone[0].area()} + %-12s\{zone[1].name} %7.2f\{zone[1].width} %7.2f\{zone[1].height} %7.2f\{zone[1].area()} + %-12s\{zone[2].name} %7.2f\{zone[2].width} %7.2f\{zone[2].height} %7.2f\{zone[2].area()} + \{" ".repeat(28)} Total %7.2f\{zone[0].area() + zone[1].area() + zone[2].area()} + """; + /* + | """ + | Description Width Height Area + | Alfa 17.80 31.40 558.92 + | Bravo 9.60 12.40 119.04 + | Charlie 7.10 11.23 79.73 + | Total 757.69 + | """ + */ + } + + static void ensuringSafety() { + String name = "Joan"; + StringTemplate st = RAW."My name is \{name}"; + String info = STR.process(st); + } + + record User(String firstName, int accountNumber) {} + + static void literalsInsideTemplateExpressions() { + String s1 = STR."Welcome to your account"; + // | "Welcome to your account" + User user = new User("Lisa", 12345); + String s2 = STR."Welcome, \{user.firstName()}, to your account \{user.accountNumber()}"; + // | "Welcome, Lisa, to your account 12345" + } + + static void emptyEmbeddedExpression() { + String s1=STR."Test \{ }"; + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt new file mode 100644 index 0000000000..7ac8614246 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt @@ -0,0 +1,707 @@ ++- CompilationUnit[@PackageName = ""] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.lang.StringTemplate.RAW", @ImportedSimpleName = "RAW", @PackageName = "java.lang.StringTemplate", @Static = true] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.FormatProcessor.FMT", @ImportedSimpleName = "FMT", @PackageName = "java.util.FormatProcessor", @Static = true] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.io.File", @ImportedSimpleName = "File", @PackageName = "java.io", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.time.format.DateTimeFormatter", @ImportedSimpleName = "DateTimeFormatter", @PackageName = "java.time.format", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.time.LocalTime", @ImportedSimpleName = "LocalTime", @PackageName = "java.time", @Static = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep459_StringTemplates", @CanonicalName = "Jep459_StringTemplates", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Jep459_StringTemplates", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PACKAGE] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- ClassBody[@Empty = false, @Size = 9] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep459_StringTemplates$Request", @CanonicalName = "Jep459_StringTemplates.Request", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Request", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"] + | +- RecordComponentList[@Empty = false, @Size = 3, @Varargs = false] + | | +- RecordComponent[@EffectiveVisibility = Visibility.V_PRIVATE, @Varargs = false, @Visibility = Visibility.V_PRIVATE] + | | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | | | +- 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 = "date", @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 = "String"] + | | | +- 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 = "time", @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 = "String"] + | | +- 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 = "ipAddress", @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 = "STRTemplateProcessor", @Name = "STRTemplateProcessor", @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 = 19, @containsComment = false] + | +- 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 = "firstName"] + | | +- 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 = "firstName", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bill", @Empty = false, @Image = "\"Bill\"", @Length = 4, @LiteralText = "\"Bill\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "lastName"] + | | +- 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 = "lastName", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Duck", @Empty = false, @Image = "\"Duck\"", @Length = 4, @LiteralText = "\"Duck\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "fullName"] + | | +- 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 = "fullName", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"\\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "firstName", @Name = "firstName", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "} \\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lastName", @Name = "lastName", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}\""] + | +- 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 = "sortName"] + | | +- 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 = "sortName", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"\\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lastName", @Name = "lastName", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}, \\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "firstName", @Name = "firstName", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}\""] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | +- VariableDeclarator[@Initializer = true, @Name = "x"] + | | | +- 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 = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- 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] + | | +- VariableDeclarator[@Initializer = true, @Name = "y"] + | | +- 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 = "y", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "20", @IntLiteral = true, @Integral = true, @LiteralText = "20", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 20.0, @ValueAsFloat = 20.0, @ValueAsInt = 20, @ValueAsLong = 20] + | +- 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 = "s1"] + | | +- 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 = "s1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"\\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "} + \\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "} = \\{"] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}\""] + | +- 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 = "s2"] + | | +- 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 = "s2", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"You have a \\{"] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "getOfferType", @MethodName = "getOfferType", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- TemplateFragment[@Content = "} waiting for you!\""] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Request"] + | | +- VariableDeclarator[@Initializer = true, @Name = "req"] + | | +- 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 = "req", @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 = "Request"] + | | +- ArgumentList[@Empty = false, @Size = 3] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "2022-03-25", @Empty = false, @Image = "\"2022-03-25\"", @Length = 10, @LiteralText = "\"2022-03-25\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "15:34", @Empty = false, @Image = "\"15:34\"", @Length = 5, @LiteralText = "\"15:34\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "8.8.8.8", @Empty = false, @Image = "\"8.8.8.8\"", @Length = 7, @LiteralText = "\"8.8.8.8\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "t"] + | | +- 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 = "t", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"Access at \\{"] + | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "date", @Name = "date", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "req", @Name = "req", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "} \\{"] + | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "time", @Name = "time", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "req", @Name = "req", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "} from \\{"] + | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "ipAddress", @Name = "ipAddress", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "req", @Name = "req", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}\""] + | +- 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 = "filePath"] + | | +- 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 = "filePath", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "tmp.dat", @Empty = false, @Image = "\"tmp.dat\"", @Length = 7, @LiteralText = "\"tmp.dat\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "File"] + | | +- VariableDeclarator[@Initializer = true, @Name = "file"] + | | +- 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 = "file", @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 = "File"] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "filePath", @Name = "filePath", @ParenthesisDepth = 0, @Parenthesized = false] + | +- 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 = "old"] + | | +- 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 = "old", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- 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 = "The file ", @Empty = false, @Image = "\"The file \"", @Length = 9, @LiteralText = "\"The file \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "filePath", @Name = "filePath", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " ", @Empty = false, @Image = "\" \"", @Length = 1, @LiteralText = "\" \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | | +- ConditionalExpression[@CompileTimeConstant = false, @ParenthesisDepth = 1, @Parenthesized = true] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "exists", @MethodName = "exists", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "file", @Name = "file", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "does", @Empty = false, @Image = "\"does\"", @Length = 4, @LiteralText = "\"does\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "does not", @Empty = false, @Image = "\"does not\"", @Length = 8, @LiteralText = "\"does not\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " exist", @Empty = false, @Image = "\" exist\"", @Length = 6, @LiteralText = "\" exist\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "msg"] + | | +- 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 = "msg", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"The file \\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "filePath", @Name = "filePath", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "} \\{"] + | | +- ConditionalExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "exists", @MethodName = "exists", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "file", @Name = "file", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "does", @Empty = false, @Image = "\"does\"", @Length = 4, @LiteralText = "\"does\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "does not", @Empty = false, @Image = "\"does not\"", @Length = 8, @LiteralText = "\"does not\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- TemplateFragment[@Content = "} exist\""] + | +- 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 = "time"] + | | +- 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 = "time", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"The time is \\{"] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "format", @MethodName = "format", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "ofPattern", @MethodName = "ofPattern", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | | +- ClassType[@FullyQualified = false, @SimpleName = "DateTimeFormatter"] + | | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "HH:mm:ss", @Empty = false, @Image = "\"HH:mm:ss\"", @Length = 8, @LiteralText = "\"HH:mm:ss\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "now", @MethodName = "now", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "LocalTime"] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- TemplateFragment[@Content = "} right now\""] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] + | | +- VariableDeclarator[@Initializer = true, @Name = "index"] + | | +- 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 = "index", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- 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 = "data"] + | | +- 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 = "data", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"\\{"] + | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}, \\{"] + | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}, \\{"] + | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}, \\{"] + | | +- UnaryExpression[@CompileTimeConstant = false, @Operator = UnaryOp.POST_INCREMENT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "index", @Name = "index", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}\""] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ArrayType[@ArrayDepth = 1] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | | | +- ArrayDimensions[@Empty = false, @Size = 1] + | | | +- ArrayTypeDim[@Varargs = false] + | | +- VariableDeclarator[@Initializer = true, @Name = "fruit"] + | | +- 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 = "fruit", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ArrayInitializer[@CompileTimeConstant = false, @Length = 3, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "apples", @Empty = false, @Image = "\"apples\"", @Length = 6, @LiteralText = "\"apples\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "oranges", @Empty = false, @Image = "\"oranges\"", @Length = 7, @LiteralText = "\"oranges\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "peaches", @Empty = false, @Image = "\"peaches\"", @Length = 7, @LiteralText = "\"peaches\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "s3"] + | | +- 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 = "s3", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"\\{"] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | +- TemplateFragment[@Content = "}, \\{"] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- Template[] + | | | +- TemplateFragment[@Content = "\"\\{"] + | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @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] + | | | +- TemplateFragment[@Content = "}, \\{"] + | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- 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] + | | | +- TemplateFragment[@Content = "}\""] + | | +- TemplateFragment[@Content = "}\""] + | +- 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 = "s4"] + | +- 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 = "s4", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | +- Template[] + | +- TemplateFragment[@Content = "\"\\{"] + | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- TemplateFragment[@Content = "}, \\{"] + | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"\\{"] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @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] + | | +- TemplateFragment[@Content = "}, \\{"] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "fruit", @Name = "fruit", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- 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] + | | +- TemplateFragment[@Content = "}\""] + | +- TemplateFragment[@Content = "}\""] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "getOfferType", @Name = "getOfferType", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] + | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] + | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- ReturnStatement[] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "_getOfferType_", @Empty = false, @Image = "\"_getOfferType_\"", @Length = 14, @LiteralText = "\"_getOfferType_\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "multilineTemplateExpressions", @Name = "multilineTemplateExpressions", @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 = 7, @containsComment = false] + | +- 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 = "title"] + | | +- 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 = "title", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "My Web Page", @Empty = false, @Image = "\"My Web Page\"", @Length = 11, @LiteralText = "\"My Web Page\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "text"] + | | +- 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 = "text", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Hello, world", @Empty = false, @Image = "\"Hello, world\"", @Length = 12, @LiteralText = "\"Hello, world\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "html"] + | | +- 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 = "html", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"\"\"\n \n \n \\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "title", @Name = "title", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}\n \n \n

\\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "text", @Name = "text", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}

\n \n \n \"\"\""] + | +- 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 = "name"] + | | +- 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 = "name", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Joan Smith", @Empty = false, @Image = "\"Joan Smith\"", @Length = 10, @LiteralText = "\"Joan Smith\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "phone"] + | | +- 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 = "phone", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "555-123-4567", @Empty = false, @Image = "\"555-123-4567\"", @Length = 12, @LiteralText = "\"555-123-4567\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "address"] + | | +- 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 = "address", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "1 Maple Drive, Anytown", @Empty = false, @Image = "\"1 Maple Drive, Anytown\"", @Length = 22, @LiteralText = "\"1 Maple Drive, Anytown\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- 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 = "json"] + | +- 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 = "json", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | +- Template[] + | +- TemplateFragment[@Content = "\"\"\"\n {\n \"name\": \"\\{"] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | +- TemplateFragment[@Content = "}\",\n \"phone\": \"\\{"] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "phone", @Name = "phone", @ParenthesisDepth = 0, @Parenthesized = false] + | +- TemplateFragment[@Content = "}\",\n \"address\": \"\\{"] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "address", @Name = "address", @ParenthesisDepth = 0, @Parenthesized = false] + | +- TemplateFragment[@Content = "}\"\n }\n \"\"\";\n /*\n | \"\"\"\n | {\n | \"name\": \"Joan Smith\",\n | \"phone\": \"555-123-4567\",\n | \"address\": \"1 Maple Drive, Anytown\"\n | }\n | \"\"\"\n */\n\n record Rectangle(String name, double width, double height) {\n double area() {\n return width * height;\n }\n }\n Rectangle[] zone = new Rectangle[] {\n new Rectangle(\"Alfa\", 17.8, 31.4),\n new Rectangle(\"Bravo\", 9.6, 12.4),\n new Rectangle(\"Charlie\", 7.1, 11.23),\n };\n String table = STR.\"\"\"\n Description Width Height Area\n \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- TemplateFragment[@Content = "} \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- TemplateFragment[@Content = "} \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- TemplateFragment[@Content = "} \\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | +- TemplateFragment[@Content = "} \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | +- TemplateFragment[@Content = "} \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | +- TemplateFragment[@Content = "} \\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- 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] + | +- TemplateFragment[@Content = "} \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- 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] + | +- TemplateFragment[@Content = "} \\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- 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] + | +- TemplateFragment[@Content = "} \\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- 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] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n Total \\{"] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- 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] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n \"\"\""] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "FMTTemplateProcessor", @Name = "FMTTemplateProcessor", @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 = 4, @containsComment = false] + | +- LocalClassStatement[] + | | +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep459_StringTemplates$1Rectangle", @CanonicalName = null, @EffectiveVisibility = Visibility.V_LOCAL, @Enum = false, @Final = true, @Interface = false, @Local = true, @Nested = false, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Rectangle", @Static = true, @TopLevel = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"] + | | +- RecordComponentList[@Empty = false, @Size = 3, @Varargs = false] + | | | +- RecordComponent[@EffectiveVisibility = Visibility.V_LOCAL, @Varargs = false, @Visibility = Visibility.V_PRIVATE] + | | | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "name", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE] + | | | +- RecordComponent[@EffectiveVisibility = Visibility.V_LOCAL, @Varargs = false, @Visibility = Visibility.V_PRIVATE] + | | | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"] + | | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.DOUBLE] + | | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "width", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE] + | | | +- RecordComponent[@EffectiveVisibility = Visibility.V_LOCAL, @Varargs = false, @Visibility = Visibility.V_PRIVATE] + | | | +- ModifierList[@EffectiveModifiers = "{private, final}", @ExplicitModifiers = "{}"] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.DOUBLE] + | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "height", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE] + | | +- RecordBody[@Empty = false, @Size = 1] + | | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Image = "area", @Name = "area", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.DOUBLE] + | | +- FormalParameters[@Empty = true, @Size = 0] + | | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | | +- ReturnStatement[] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.MUL, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] + | +- EmptyStatement[] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ArrayType[@ArrayDepth = 1] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] + | | | +- ArrayDimensions[@Empty = false, @Size = 1] + | | | +- ArrayTypeDim[@Varargs = false] + | | +- VariableDeclarator[@Initializer = true, @Name = "zone"] + | | +- 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 = "zone", @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 = "Rectangle"] + | | | +- 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 = "Rectangle"] + | | | +- ArgumentList[@Empty = false, @Size = 3] + | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Alfa", @Empty = false, @Image = "\"Alfa\"", @Length = 4, @LiteralText = "\"Alfa\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = true, @FloatLiteral = false, @Image = "17.8", @IntLiteral = false, @Integral = false, @LiteralText = "17.8", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 17.8, @ValueAsFloat = 17.8, @ValueAsInt = 17, @ValueAsLong = 17] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = true, @FloatLiteral = false, @Image = "31.4", @IntLiteral = false, @Integral = false, @LiteralText = "31.4", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 31.4, @ValueAsFloat = 31.4, @ValueAsInt = 31, @ValueAsLong = 31] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] + | | | +- ArgumentList[@Empty = false, @Size = 3] + | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bravo", @Empty = false, @Image = "\"Bravo\"", @Length = 5, @LiteralText = "\"Bravo\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = true, @FloatLiteral = false, @Image = "9.6", @IntLiteral = false, @Integral = false, @LiteralText = "9.6", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 9.6, @ValueAsFloat = 9.6, @ValueAsInt = 9, @ValueAsLong = 9] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = true, @FloatLiteral = false, @Image = "12.4", @IntLiteral = false, @Integral = false, @LiteralText = "12.4", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 12.4, @ValueAsFloat = 12.4, @ValueAsInt = 12, @ValueAsLong = 12] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Rectangle"] + | | +- ArgumentList[@Empty = false, @Size = 3] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Charlie", @Empty = false, @Image = "\"Charlie\"", @Length = 7, @LiteralText = "\"Charlie\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = true, @FloatLiteral = false, @Image = "7.1", @IntLiteral = false, @Integral = false, @LiteralText = "7.1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.1, @ValueAsFloat = 7.1, @ValueAsInt = 7, @ValueAsLong = 7] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = true, @FloatLiteral = false, @Image = "11.23", @IntLiteral = false, @Integral = false, @LiteralText = "11.23", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 11.23, @ValueAsFloat = 11.23, @ValueAsInt = 11, @ValueAsLong = 11] + | +- 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 = "table"] + | +- 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 = "table", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = false] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "FMT", @Name = "FMT", @ParenthesisDepth = 0, @Parenthesized = false] + | +- Template[] + | +- TemplateFragment[@Content = "\"\"\"\n Description Width Height Area\n %-12s\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n %-12s\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n %-12s\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- 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] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "width", @Name = "width", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- 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] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "height", @Name = "height", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- 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] + | +- TemplateFragment[@Content = "} %7.2f\\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- 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] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n \\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "repeat", @MethodName = "repeat", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " ", @Empty = false, @Image = "\" \"", @Length = 1, @LiteralText = "\" \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "28", @IntLiteral = true, @Integral = true, @LiteralText = "28", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 28.0, @ValueAsFloat = 28.0, @ValueAsInt = 28, @ValueAsLong = 28] + | +- TemplateFragment[@Content = "} Total %7.2f\\{"] + | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @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] + | | | +- ArgumentList[@Empty = true, @Size = 0] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "area", @MethodName = "area", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "zone", @Name = "zone", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- 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] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\n \"\"\""] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "ensuringSafety", @Name = "ensuringSafety", @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 = 3, @containsComment = false] + | +- 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 = "name"] + | | +- 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 = "name", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Joan", @Empty = false, @Image = "\"Joan\"", @Length = 4, @LiteralText = "\"Joan\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "StringTemplate"] + | | +- VariableDeclarator[@Initializer = true, @Name = "st"] + | | +- 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 = "st", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "RAW", @Name = "RAW", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- Template[] + | | +- TemplateFragment[@Content = "\"My name is \\{"] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "name", @Name = "name", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TemplateFragment[@Content = "}\""] + | +- 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 = "info"] + | +- 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 = "info", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- MethodCall[@CompileTimeConstant = false, @Image = "process", @MethodName = "process", @ParenthesisDepth = 0, @Parenthesized = false] + | +- AmbiguousName[@CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "st", @Name = "st", @ParenthesisDepth = 0, @Parenthesized = false] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep459_StringTemplates$User", @CanonicalName = "Jep459_StringTemplates.User", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "User", @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 = "String"] + | | | +- 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 = "firstName", @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 = "accountNumber", @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 = "literalsInsideTemplateExpressions", @Name = "literalsInsideTemplateExpressions", @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 = 3, @containsComment = false] + | +- 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 = "s1"] + | | +- 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 = "s1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Welcome to your account", @Empty = false, @Image = "\"Welcome to your account\"", @Length = 23, @LiteralText = "\"Welcome to your account\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "User"] + | | +- VariableDeclarator[@Initializer = true, @Name = "user"] + | | +- 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 = "user", @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 = "User"] + | | +- ArgumentList[@Empty = false, @Size = 2] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Lisa", @Empty = false, @Image = "\"Lisa\"", @Length = 4, @LiteralText = "\"Lisa\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "12345", @IntLiteral = true, @Integral = true, @LiteralText = "12345", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 12345.0, @ValueAsFloat = 12345.0, @ValueAsInt = 12345, @ValueAsLong = 12345] + | +- 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 = "s2"] + | +- 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 = "s2", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + | +- Template[] + | +- TemplateFragment[@Content = "\"Welcome, \\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "firstName", @MethodName = "firstName", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "user", @Name = "user", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}, to your account \\{"] + | +- MethodCall[@CompileTimeConstant = false, @Image = "accountNumber", @MethodName = "accountNumber", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "user", @Name = "user", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- TemplateFragment[@Content = "}\""] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "emptyEmbeddedExpression", @Name = "emptyEmbeddedExpression", @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 = 1, @containsComment = false] + +- 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 = "s1"] + +- 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 = "s1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + +- TemplateExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false, @StringTemplate = true] + +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "STR", @Name = "STR", @ParenthesisDepth = 0, @Parenthesized = false] + +- Template[] + +- TemplateFragment[@Content = "\"Test \\{"] + +- TemplateFragment[@Content = "}\""] From cb3ceef17ab9c265c6da030f1ca9f1efec9607ff Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 11:26:12 +0100 Subject: [PATCH 09/39] [java] Update Tests for JEP 463: Implicitly Declared Classes and Instance Main Methods --- pmd-java/etc/grammar/Java.jjt | 4 ++- .../ast/internal/LanguageLevelChecker.java | 1 + .../java/ast/Java22PreviewTreeDumpTest.java | 27 ++++++++------ ...sses1.java => Jep463_UnnamedClasses1.java} | 3 +- ...lasses1.txt => Jep463_UnnamedClasses1.txt} | 0 ...sses2.java => Jep463_UnnamedClasses2.java} | 3 +- ...lasses2.txt => Jep463_UnnamedClasses2.txt} | 0 ...sses3.java => Jep463_UnnamedClasses3.java} | 3 +- ...lasses3.txt => Jep463_UnnamedClasses3.txt} | 0 .../Jep463_UnnamedClasses4WithImports.java | 17 +++++++++ .../Jep463_UnnamedClasses4WithImports.txt | 35 +++++++++++++++++++ 11 files changed, 78 insertions(+), 15 deletions(-) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/{Jep445_UnnamedClasses1.java => Jep463_UnnamedClasses1.java} (52%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/{Jep445_UnnamedClasses1.txt => Jep463_UnnamedClasses1.txt} (100%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/{Jep445_UnnamedClasses2.java => Jep463_UnnamedClasses2.java} (56%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/{Jep445_UnnamedClasses2.txt => Jep463_UnnamedClasses2.txt} (100%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/{Jep445_UnnamedClasses3.java => Jep463_UnnamedClasses3.java} (55%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/{Jep445_UnnamedClasses3.txt => Jep463_UnnamedClasses3.txt} (100%) create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 111c4cc2a1..cf66ce0cb0 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,6 @@ /** + * Support "JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)" (Java 22) + * No changes. * Support "JEP 459: String Templates (Second Preview)" (Java 22) * Use ASTTemplate.setContent instead of setImage. * Remove support for Record pattern in enhanced for statements. This was only a Java 20 Preview feature. @@ -1153,7 +1155,7 @@ ASTCompilationUnit CompilationUnit() : // OrdinaryCompilationUnit: -> TopLevelClassOrInterfaceDeclaration ( TypeDeclaration() ( EmptyDeclaration() )* )* - // UnnamedClassCompilationUnit: + // SimpleCompilationUnit: [ ( LOOKAHEAD(3) ClassMemberDeclarationNoMethod() )* ModifierList() MethodDeclaration() diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java index a9dd43a843..dccede5cc9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java @@ -138,6 +138,7 @@ public class LanguageLevelChecker { /** * Unnamed Classes and Instance Main Methods * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) (Java 21) + * @see JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview) (Java 22) */ UNNAMED_CLASSES(21, 22, false), diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java index 6d9a59e087..0b24ca452e 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java @@ -66,38 +66,43 @@ class Java22PreviewTreeDumpTest extends BaseJavaTreeDumpTest { } @Test - void unnamedClasses1() { - doTest("Jep445_UnnamedClasses1"); - ASTCompilationUnit compilationUnit = java22p.parseResource("Jep445_UnnamedClasses1.java"); + void jep463UnnamedClasses1() { + doTest("Jep463_UnnamedClasses1"); + ASTCompilationUnit compilationUnit = java22p.parseResource("Jep463_UnnamedClasses1.java"); assertTrue(compilationUnit.isUnnamedClass()); ASTMethodCall methodCall = compilationUnit.descendants(ASTMethodCall.class).first(); assertNotNull(methodCall.getTypeMirror()); } @Test - void unnamedClasses2() { - doTest("Jep445_UnnamedClasses2"); + void jep463UnnamedClasses2() { + doTest("Jep463_UnnamedClasses2"); } @Test - void unnamedClasses3() { - doTest("Jep445_UnnamedClasses3"); + void jep463UnnamedClasses3() { + doTest("Jep463_UnnamedClasses3"); } @Test - void unnamedClassesBeforeJava22Preview() { - ParseException thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep445_UnnamedClasses1.java")); + void jep463UnnamedClasses4WithImports() { + doTest("Jep463_UnnamedClasses4WithImports"); + } + + @Test + void jep463UnnamedClassesBeforeJava22Preview() { + ParseException thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep463_UnnamedClasses1.java")); assertThat(thrown.getMessage(), containsString("Unnamed classes is a preview feature of JDK 22, you should select your language version accordingly")); } @Test - void testOrdinaryCompilationUnit() { + void jep463TestOrdinaryCompilationUnit() { ASTCompilationUnit compilationUnit = java22.parse("public class Foo { public static void main(String[] args) {}}"); assertFalse(compilationUnit.isUnnamedClass()); } @Test - void testModularCompilationUnit() { + void jep463TestModularCompilationUnit() { ASTCompilationUnit compilationUnit = java22.parse("module foo {}"); assertFalse(compilationUnit.isUnnamedClass()); } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.java similarity index 52% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.java rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.java index 5a8891fd2f..fc1cea6d7c 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.java @@ -5,7 +5,8 @@ /** - * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) + * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) (Java 21) + * @see JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview) (Java 22) */ void main() { diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.txt similarity index 100% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses1.txt rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.txt diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.java similarity index 56% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.java rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.java index 49d30a40e1..1e2d223c24 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.java @@ -5,7 +5,8 @@ /** - * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) + * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) (Java 21) + * @see JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview) (Java 22) */ String greeting() { return "Hello, World!"; } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.txt similarity index 100% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses2.txt rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.txt diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.java similarity index 55% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.java rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.java index 9c4fcae3f7..3cbde1d0e5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.java @@ -5,7 +5,8 @@ /** - * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) + * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) (Java 21) + * @see JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview) (Java 22) */ String greeting = "Hello, World!"; diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.txt similarity index 100% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep445_UnnamedClasses3.txt rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.txt diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.java new file mode 100644 index 0000000000..b22ef710d0 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.java @@ -0,0 +1,17 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +import java.util.Arrays; +import java.util.stream.Collectors; + +/** + * @see JEP 445: Unnamed Classes and Instance Main Methods (Preview) (Java 21) + * @see JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview) (Java 22) + */ + +String greeting = Arrays.asList("Hello", "World!").stream().collect(Collectors.joining(", ")); + +void main() { + System.out.println(greeting); +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt new file mode 100644 index 0000000000..6324eadc34 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt @@ -0,0 +1,35 @@ ++- CompilationUnit[@PackageName = ""] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.Arrays", @ImportedSimpleName = "Arrays", @PackageName = "java.util", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.stream.Collectors", @ImportedSimpleName = "Collectors", @PackageName = "java.util.stream", @Static = false] + +- FieldDeclaration[@EffectiveVisibility = Visibility.V_PACKAGE, @Static = false, @Visibility = Visibility.V_PACKAGE] + | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | +- VariableDeclarator[@Initializer = true, @Name = "greeting"] + | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = true, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "greeting", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PACKAGE] + | +- MethodCall[@CompileTimeConstant = false, @Image = "collect", @MethodName = "collect", @ParenthesisDepth = 0, @Parenthesized = false] + | +- MethodCall[@CompileTimeConstant = false, @Image = "stream", @MethodName = "stream", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "asList", @MethodName = "asList", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "Arrays"] + | | | +- 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 = 6, @LiteralText = "\"World!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- MethodCall[@CompileTimeConstant = false, @Image = "joining", @MethodName = "joining", @ParenthesisDepth = 0, @Parenthesized = false] + | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Collectors"] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = ", ", @Empty = false, @Image = "\", \"", @Length = 2, @LiteralText = "\", \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- VoidType[] + +- FormalParameters[@Empty = true, @Size = 0] + +- 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 = "greeting", @Name = "greeting", @ParenthesisDepth = 0, @Parenthesized = false] From 4e01a3dafb4aea3d78b7e40293e898221ef9c78c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 12:12:12 +0100 Subject: [PATCH 10/39] [java] JEP 456: Unnamed Variables & Patterns This is now standardized. --- docs/pages/release_notes.md | 2 + pmd-java/etc/grammar/Java.jjt | 2 + .../pmd/lang/java/ast/ASTUnnamedPattern.java | 7 +-- .../ast/internal/LanguageLevelChecker.java | 17 +++---- .../lang/java/ast/AllJavaAstTreeDumpTest.java | 3 +- .../java/ast/Java21PreviewTreeDumpTest.java | 5 +- .../java/ast/Java22PreviewTreeDumpTest.java | 14 ------ .../pmd/lang/java/ast/Java22TreeDumpTest.java | 46 +++++++++++++++++++ .../Jep443_UnnamedPatternsAndVariables2.java | 26 ----------- .../Jep456_UnnamedPatternsAndVariables.java} | 5 +- .../Jep456_UnnamedPatternsAndVariables.txt} | 22 ++++----- .../Jep443_UnnamedPatternsAndVariables2.java | 26 ----------- 12 files changed, 78 insertions(+), 97 deletions(-) create mode 100644 pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22TreeDumpTest.java delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables2.java rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/{java22p/Jep443_UnnamedPatternsAndVariables.java => java22/Jep456_UnnamedPatternsAndVariables.java} (94%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/{java22p/Jep443_UnnamedPatternsAndVariables.txt => java22/Jep456_UnnamedPatternsAndVariables.txt} (98%) delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index e9df137ccc..0d1a0b54dd 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -240,6 +240,8 @@ The rules have been moved into categories with PMD 6. - method `getParenthesisDepth()` has been removed. * {%jdoc java::lang.java.ast.ASTTemplateFragment %}: To get the content of the template, use now {%jdoc java::lang.java.ast.ASTTemplateFragment#getContent() %} or `@Content` instead of `getImage()`/`@Image`. +* {%jdoc java::lang.java.ast.ASTUnnamedPattern %} is not experimental anymore. The language feature + has been standardized with Java 22. **New API** diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index cf66ce0cb0..3d01cd8830 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,6 @@ /** + * Support "JEP 456: Unnamed Variables & Patterns" (Java 22) + * This is now a regular language feature. Otherwise no changes. * Support "JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)" (Java 22) * No changes. * Support "JEP 459: String Templates (Second Preview)" (Java 22) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java index 6eed6e6d93..52a5534764 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnnamedPattern.java @@ -5,10 +5,8 @@ package net.sourceforge.pmd.lang.java.ast; -import net.sourceforge.pmd.annotation.Experimental; - /** - * An unnamed pattern, a Java 21 Preview language feature. + * An unnamed pattern, a Java 22 language feature. * *
  *
@@ -16,9 +14,8 @@ import net.sourceforge.pmd.annotation.Experimental;
  *
  * 
* - * @see JEP 443: Unnamed patterns and variables (Preview) (Java 21) + * @see JEP 456: Unnamed Variables & Patterns (Java 22) */ -@Experimental public final class ASTUnnamedPattern extends AbstractJavaNode implements ASTPattern { ASTUnnamedPattern(int id) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java index dccede5cc9..326e14b23a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java @@ -130,10 +130,11 @@ public class LanguageLevelChecker { STRING_TEMPLATES(21, 22, false), /** - * Unnamed patterns and variables. + * Unnamed variables and patterns. * @see JEP 443: Unnamed patterns and variables (Preview) (Java 21) + * @see JEP 456: Unnamed Variables & Patterns (Java 22) */ - UNNAMED_PATTERNS_AND_VARIABLES(21, 22, false), + UNNAMED_VARIABLES_AND_PATTERNS(21, 21, true), /** * Unnamed Classes and Instance Main Methods @@ -167,10 +168,10 @@ public class LanguageLevelChecker { } String message = StringUtils.capitalize(displayNameLower(name())); - if (canBePreview) { + if (wasStandardized) { + message += " was only standardized in Java " + (maxPreviewVersion + 1); + } else if (canBePreview) { message += " is a preview feature of JDK " + jdk; - } else if (wasStandardized) { - message = message + " was only standardized in Java " + (maxPreviewVersion + 1); } else if (minPreviewVersion == maxPreviewVersion) { message += " is a preview feature of JDK " + minPreviewVersion; } else { @@ -655,7 +656,7 @@ public class LanguageLevelChecker { @Override public Void visit(ASTUnnamedPattern node, T data) { - check(node, PreviewFeature.UNNAMED_PATTERNS_AND_VARIABLES, data); + check(node, PreviewFeature.UNNAMED_VARIABLES_AND_PATTERNS, data); return null; } @@ -688,8 +689,8 @@ public class LanguageLevelChecker { } else if ("assert".equals(simpleName)) { check(node, Keywords.ASSERT_AS_AN_IDENTIFIER, acc); } else if ("_".equals(simpleName)) { - if (LanguageLevelChecker.this.preview) { - check(node, PreviewFeature.UNNAMED_PATTERNS_AND_VARIABLES, acc); + if (LanguageLevelChecker.this.jdkVersion >= 21) { + check(node, PreviewFeature.UNNAMED_VARIABLES_AND_PATTERNS, acc); } else { check(node, Keywords.UNDERSCORE_AS_AN_IDENTIFIER, acc); } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java index 42794be992..64c8afd050 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java @@ -16,7 +16,8 @@ import org.junit.platform.suite.api.Suite; Java16TreeDumpTest.class, Java17TreeDumpTest.class, Java21TreeDumpTest.class, - Java21PreviewTreeDumpTest.class + Java21PreviewTreeDumpTest.class, + Java22TreeDumpTest.class }) class AllJavaAstTreeDumpTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21PreviewTreeDumpTest.java index 26c055469d..802d43fdba 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21PreviewTreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java21PreviewTreeDumpTest.java @@ -59,10 +59,7 @@ class Java21PreviewTreeDumpTest extends BaseJavaTreeDumpTest { @Test void unnamedPatternsAndVariablesBeforeJava21Preview() { ParseException thrown = assertThrows(ParseException.class, () -> java21.parseResource("Jep443_UnnamedPatternsAndVariables.java")); - assertThat(thrown.getMessage(), containsString("Since Java 9, '_' is reserved and cannot be used as an identifier")); - - thrown = assertThrows(ParseException.class, () -> java21.parseResource("Jep443_UnnamedPatternsAndVariables2.java")); - assertThat(thrown.getMessage(), containsString("Unnamed patterns and variables is a preview feature of JDK 21, you should select your language version accordingly")); + assertThat(thrown.getMessage(), containsString("Unnamed variables and patterns was only standardized in Java 22, you should select your language version accordingly")); } @Test diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java index 0b24ca452e..e6ceeed81d 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java @@ -51,20 +51,6 @@ class Java22PreviewTreeDumpTest extends BaseJavaTreeDumpTest { assertEquals("java.lang.String", ((JClassSymbol) typeMirror.getSymbol()).getCanonicalName()); } - @Test - void unnamedPatternsAndVariables() { - doTest("Jep443_UnnamedPatternsAndVariables"); - } - - @Test - void unnamedPatternsAndVariablesBeforeJava22Preview() { - ParseException thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep443_UnnamedPatternsAndVariables.java")); - assertThat(thrown.getMessage(), containsString("Since Java 9, '_' is reserved and cannot be used as an identifier")); - - thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep443_UnnamedPatternsAndVariables2.java")); - assertThat(thrown.getMessage(), containsString("Unnamed patterns and variables is a preview feature of JDK 22, you should select your language version accordingly")); - } - @Test void jep463UnnamedClasses1() { doTest("Jep463_UnnamedClasses1"); diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22TreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22TreeDumpTest.java new file mode 100644 index 0000000000..b28af7a40e --- /dev/null +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22TreeDumpTest.java @@ -0,0 +1,46 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.ast; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +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 Java22TreeDumpTest extends BaseJavaTreeDumpTest { + private final JavaParsingHelper java22 = + JavaParsingHelper.DEFAULT.withDefaultVersion("22") + .withResourceContext(Java21TreeDumpTest.class, "jdkversiontests/java22/"); + private final JavaParsingHelper java21 = java22.withDefaultVersion("21"); + private final JavaParsingHelper java17 = java22.withDefaultVersion("17"); + + @Override + public BaseParsingHelper getParser() { + return java22; + } + + @Test + void jep456UnnamedPatternsAndVariables() { + doTest("Jep456_UnnamedPatternsAndVariables"); + } + + @Test + void jep456UnnamedPatternsAndVariablesBeforeJava22() { + ParseException thrown = assertThrows(ParseException.class, () -> java21.parseResource("Jep456_UnnamedPatternsAndVariables.java")); + assertThat(thrown.getMessage(), containsString("Unnamed variables and patterns was only standardized in Java 22, you should select your language version accordingly")); + } + + @Test + void jep456UnnamedVariablesAndPatternsUnderscoreBeforeJava21() { + ParseException thrown = assertThrows(ParseException.class, () -> java17.parse("class Test { { for(Integer _ : java.util.Arrays.asList(1, 2, 3)) {} } }")); + assertThat(thrown.getMessage(), containsString("Since Java 9, '_' is reserved and cannot be used as an identifier")); + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables2.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables2.java deleted file mode 100644 index 7d690d41e5..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21p/Jep443_UnnamedPatternsAndVariables2.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - - -import java.util.ArrayDeque; -import java.util.List; -import java.util.Queue; -import java.util.stream.Collectors; - -/** - * @see JEP 443: Unnamed Patterns and Variables (Preview) - */ -class Jep443_UnamedPatternsAndVariables2 { - record Point(int x, int y) { } - enum Color { RED, GREEN, BLUE } - record ColoredPoint(Point p, Color c) { } - - void unnamedPatterns1() { - ColoredPoint r = new ColoredPoint(new Point(3,4), Color.GREEN); - - if (r instanceof ColoredPoint(Point(int x, int y), _)) { - System.out.println(x + " " + y); - } - } -} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.java similarity index 94% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.java rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.java index dc2e9f4c7a..a9d8cb8004 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.java @@ -9,9 +9,10 @@ import java.util.Queue; import java.util.stream.Collectors; /** - * @see JEP 443: Unnamed Patterns and Variables (Preview) + * @see JEP 443: Unnamed Patterns and Variables (Preview) (Java 21) + * @see JEP 456: Unnamed Variables & Patterns (Java 22) */ -class Jep443_UnamedPatternsAndVariables { +class Jep456_UnamedPatternsAndVariables { record Point(int x, int y) { } enum Color { RED, GREEN, BLUE } record ColoredPoint(Point p, Color c) { } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt similarity index 98% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.txt rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt index fcb1e37135..8ade7f7fcc 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt @@ -3,10 +3,10 @@ +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.List", @ImportedSimpleName = "List", @PackageName = "java.util", @Static = false] +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.Queue", @ImportedSimpleName = "Queue", @PackageName = "java.util", @Static = false] +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.util.stream.Collectors", @ImportedSimpleName = "Collectors", @PackageName = "java.util.stream", @Static = false] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables", @CanonicalName = "Jep443_UnamedPatternsAndVariables", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Jep443_UnamedPatternsAndVariables", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PACKAGE] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables", @CanonicalName = "Jep456_UnamedPatternsAndVariables", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Jep456_UnamedPatternsAndVariables", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PACKAGE] +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] +- ClassBody[@Empty = false, @Size = 19] - +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Point", @CanonicalName = "Jep443_UnamedPatternsAndVariables.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] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$Point", @CanonicalName = "Jep456_UnamedPatternsAndVariables.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] @@ -18,7 +18,7 @@ | | +- 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 = "Jep443_UnamedPatternsAndVariables$Color", @CanonicalName = "Jep443_UnamedPatternsAndVariables.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] + +- EnumDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$Color", @CanonicalName = "Jep456_UnamedPatternsAndVariables.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] @@ -30,7 +30,7 @@ | +- 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 = "Jep443_UnamedPatternsAndVariables$ColoredPoint", @CanonicalName = "Jep443_UnamedPatternsAndVariables.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] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$ColoredPoint", @CanonicalName = "Jep456_UnamedPatternsAndVariables.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] @@ -125,29 +125,29 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @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 = "y", @Name = "y", @ParenthesisDepth = 0, @Parenthesized = false] - +- ClassDeclaration[@Abstract = true, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Ball", @CanonicalName = "Jep443_UnamedPatternsAndVariables.Ball", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Ball", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + +- ClassDeclaration[@Abstract = true, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$Ball", @CanonicalName = "Jep456_UnamedPatternsAndVariables.Ball", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Ball", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = "{sealed, abstract}", @ExplicitModifiers = "{sealed, abstract}"] | +- PermitsList[@Empty = false, @Size = 3] | | +- ClassType[@FullyQualified = false, @SimpleName = "RedBall"] | | +- ClassType[@FullyQualified = false, @SimpleName = "BlueBall"] | | +- ClassType[@FullyQualified = false, @SimpleName = "GreenBall"] | +- ClassBody[@Empty = true, @Size = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$RedBall", @CanonicalName = "Jep443_UnamedPatternsAndVariables.RedBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RedBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$RedBall", @CanonicalName = "Jep456_UnamedPatternsAndVariables.RedBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RedBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] | +- ExtendsList[@Empty = false, @Size = 1] | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] | +- ClassBody[@Empty = true, @Size = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$BlueBall", @CanonicalName = "Jep443_UnamedPatternsAndVariables.BlueBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "BlueBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$BlueBall", @CanonicalName = "Jep456_UnamedPatternsAndVariables.BlueBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "BlueBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] | +- ExtendsList[@Empty = false, @Size = 1] | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] | +- ClassBody[@Empty = true, @Size = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$GreenBall", @CanonicalName = "Jep443_UnamedPatternsAndVariables.GreenBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "GreenBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$GreenBall", @CanonicalName = "Jep456_UnamedPatternsAndVariables.GreenBall", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "GreenBall", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] | +- ExtendsList[@Empty = false, @Size = 1] | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] | +- ClassBody[@Empty = true, @Size = 0] - +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Box", @CanonicalName = "Jep443_UnamedPatternsAndVariables.Box", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Box", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$Box", @CanonicalName = "Jep456_UnamedPatternsAndVariables.Box", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Box", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = "{static, final}", @ExplicitModifiers = "{}"] | +- TypeParameters[@Empty = false, @Size = 1] | | +- TypeParameter[@Image = "T", @Name = "T", @TypeBound = true] @@ -316,7 +316,7 @@ | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] | +- Block[@Empty = true, @Size = 0, @containsComment = false] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$Order", @CanonicalName = "Jep443_UnamedPatternsAndVariables.Order", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Order", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$Order", @CanonicalName = "Jep456_UnamedPatternsAndVariables.Order", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Order", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassBody[@Empty = true, @Size = 0] +- FieldDeclaration[@EffectiveVisibility = Visibility.V_PRIVATE, @Static = true, @Visibility = Visibility.V_PRIVATE] @@ -491,7 +491,7 @@ | +- ArgumentList[@Empty = false, @Size = 2] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep443_UnamedPatternsAndVariables$ScopedContext", @CanonicalName = "Jep443_UnamedPatternsAndVariables.ScopedContext", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "ScopedContext", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep456_UnamedPatternsAndVariables$ScopedContext", @CanonicalName = "Jep456_UnamedPatternsAndVariables.ScopedContext", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "ScopedContext", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- ImplementsList[@Empty = false, @Size = 1] | | +- ClassType[@FullyQualified = false, @SimpleName = "AutoCloseable"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java deleted file mode 100644 index 7d690d41e5..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep443_UnnamedPatternsAndVariables2.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - - -import java.util.ArrayDeque; -import java.util.List; -import java.util.Queue; -import java.util.stream.Collectors; - -/** - * @see JEP 443: Unnamed Patterns and Variables (Preview) - */ -class Jep443_UnamedPatternsAndVariables2 { - record Point(int x, int y) { } - enum Color { RED, GREEN, BLUE } - record ColoredPoint(Point p, Color c) { } - - void unnamedPatterns1() { - ColoredPoint r = new ColoredPoint(new Point(3,4), Color.GREEN); - - if (r instanceof ColoredPoint(Point(int x, int y), _)) { - System.out.println(x + " " + y); - } - } -} From bfe9ce66e2fd323c17309c56ee9b1f5da427d467 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 13:20:46 +0100 Subject: [PATCH 11/39] [java] JEP 447: Statements before super(...) (Preview) (Java 22) --- pmd-java/etc/grammar/Java.jjt | 3 + .../ast/internal/LanguageLevelChecker.java | 19 ++ .../java/ast/Java22PreviewTreeDumpTest.java | 11 + .../java22p/Jep447_StatementsBeforeSuper.java | 86 ++++++ .../java22p/Jep447_StatementsBeforeSuper.txt | 283 ++++++++++++++++++ 5 files changed, 402 insertions(+) create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.java create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 3d01cd8830..3c18bbd5c3 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,6 @@ /** + * Support "JEP 447: Statements before super(...) (Preview)" (Java 22) + * Changes in ConstructorBlock * Support "JEP 456: Unnamed Variables & Patterns" (Java 22) * This is now a regular language feature. Otherwise no changes. * Support "JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)" (Java 22) @@ -1522,6 +1524,7 @@ private void ConstructorBlock() #Block: {} { "{" { tokenContexts.push(TokenContext.BLOCK); } + ( LOOKAHEAD(2) BlockStatement() )* [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ] ( BlockStatement() )* "}" { tokenContexts.pop(); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java index 326e14b23a..aa9ae5a538 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java @@ -18,7 +18,9 @@ import net.sourceforge.pmd.lang.java.ast.ASTCastExpression; import net.sourceforge.pmd.lang.java.ast.ASTCatchClause; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; +import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTExplicitConstructorInvocation; import net.sourceforge.pmd.lang.java.ast.ASTForeachStatement; import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; import net.sourceforge.pmd.lang.java.ast.ASTGuard; @@ -143,6 +145,12 @@ public class LanguageLevelChecker { */ UNNAMED_CLASSES(21, 22, false), + /** + * Statements before super + * @see JEP 447: Statements before super(...) (Preview) (Java 22) + */ + STATEMENTS_BEFORE_SUPER(22, 22, false), + ; // SUPPRESS CHECKSTYLE enum trailing semi is awesome @@ -683,6 +691,17 @@ public class LanguageLevelChecker { return null; } + @Override + public Void visit(ASTConstructorDeclaration node, T data) { + super.visit(node, data); + if (node.getBody().descendants(ASTExplicitConstructorInvocation.class).nonEmpty()) { + if (!(node.getBody().getFirstChild() instanceof ASTExplicitConstructorInvocation)) { + check(node, PreviewFeature.STATEMENTS_BEFORE_SUPER, data); + } + } + return null; + } + private void checkIdent(JavaNode node, String simpleName, T acc) { if ("enum".equals(simpleName)) { check(node, Keywords.ENUM_AS_AN_IDENTIFIER, acc); diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java index e6ceeed81d..387aabfbc7 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java22PreviewTreeDumpTest.java @@ -92,4 +92,15 @@ class Java22PreviewTreeDumpTest extends BaseJavaTreeDumpTest { ASTCompilationUnit compilationUnit = java22.parse("module foo {}"); assertFalse(compilationUnit.isUnnamedClass()); } + + @Test + void jep447StatementsBeforeSuper() { + doTest("Jep447_StatementsBeforeSuper"); + } + + @Test + void jep447StatementsBeforeSuperBeforeJava22Preview() { + ParseException thrown = assertThrows(ParseException.class, () -> java22.parseResource("Jep447_StatementsBeforeSuper.java")); + assertThat(thrown.getMessage(), containsString("Statements before super is a preview feature of JDK 22, you should select your language version accordingly")); + } } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.java new file mode 100644 index 0000000000..de3b25ddaf --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.java @@ -0,0 +1,86 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.security.cert.Certificate; +import java.security.interfaces.DSAPublicKey; +import java.security.interfaces.RSAKey; + +/** + * @see JEP 447: Statements before super(...) (Preview) (Java 22) + */ +class Jep447_StatementsBeforeSuper { + // To test backwards compatibility - "normal" explicit constructor invocation + public static class Old { + public Old() { + super(); + } + } + + // Example: Validating superclass constructor arguments + public static class PositiveBigInteger extends BigInteger { + + public PositiveBigInteger(long value) { + if (value <= 0) + throw new IllegalArgumentException("non-positive value"); + final String valueAsString = String.valueOf(value); + super(valueAsString); + } + } + + // Example: Preparing superclass constructor arguments + public static class Super { + public Super(byte[] bytes) {} + } + + public class Sub extends Super { + public Sub(Certificate certificate) { + var publicKey = certificate.getPublicKey(); + if (publicKey == null) + throw new IllegalArgumentException("null certificate"); + final byte[] byteArray = switch (publicKey) { + case RSAKey rsaKey -> rsaKey.toString().getBytes(StandardCharsets.UTF_8); + case DSAPublicKey dsaKey -> dsaKey.toString().getBytes(StandardCharsets.UTF_8); + default -> new byte[0]; + }; + super(byteArray); + } + } + + // Example: Sharing superclass constructor arguments + public static class F {} + public static class Super2 { + public Super2(F f1, F f2) {} + } + public class Sub2 extends Super2 { + public Sub2(int i) { + var f = new F(); + super(f, f); + // ... i ... + } + } + + // Example with records + public record Range(int lo, int hi) { + public Range(int lo, int hi, int maxDistance) { + if (lo > hi) + throw new IllegalArgumentException(String.format("(%d,%d)", lo, hi)); + if (hi - lo > maxDistance) + throw new IllegalArgumentException(String.format("(%d,%d,%d", lo, hi, maxDistance)); + this(lo, hi); + } + } + + // Example with enum + public enum Color { + BLUE(1); + private Color() { + } + private Color(int a) { + if (a < 0) throw new IllegalArgumentException(); + this(); + }; + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt new file mode 100644 index 0000000000..5d4c451e61 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt @@ -0,0 +1,283 @@ ++- CompilationUnit[@PackageName = ""] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.math.BigInteger", @ImportedSimpleName = "BigInteger", @PackageName = "java.math", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.nio.charset.StandardCharsets", @ImportedSimpleName = "StandardCharsets", @PackageName = "java.nio.charset", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.security.cert.Certificate", @ImportedSimpleName = "Certificate", @PackageName = "java.security.cert", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.security.interfaces.DSAPublicKey", @ImportedSimpleName = "DSAPublicKey", @PackageName = "java.security.interfaces", @Static = false] + +- ImportDeclaration[@ImportOnDemand = false, @ImportedName = "java.security.interfaces.RSAKey", @ImportedSimpleName = "RSAKey", @PackageName = "java.security.interfaces", @Static = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper", @CanonicalName = "Jep447_StatementsBeforeSuper", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Jep447_StatementsBeforeSuper", @Static = false, @TopLevel = true, @Visibility = Visibility.V_PACKAGE] + +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + +- ClassBody[@Empty = false, @Size = 9] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$Old", @CanonicalName = "Jep447_StatementsBeforeSuper.Old", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Old", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"] + | +- ClassBody[@Empty = false, @Size = 1] + | +- ConstructorDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "Old", @Name = "Old", @Varargs = false, @Visibility = Visibility.V_PUBLIC, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = false, @Size = 1, @containsComment = false] + | +- ExplicitConstructorInvocation[@ArgumentCount = 0, @MethodName = "new", @Qualified = false, @Super = true, @This = false] + | +- ArgumentList[@Empty = true, @Size = 0] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$PositiveBigInteger", @CanonicalName = "Jep447_StatementsBeforeSuper.PositiveBigInteger", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "PositiveBigInteger", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"] + | +- ExtendsList[@Empty = false, @Size = 1] + | | +- ClassType[@FullyQualified = false, @SimpleName = "BigInteger"] + | +- ClassBody[@Empty = false, @Size = 1] + | +- ConstructorDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "PositiveBigInteger", @Name = "PositiveBigInteger", @Varargs = false, @Visibility = Visibility.V_PUBLIC, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- FormalParameters[@Empty = false, @Size = 1] + | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.LONG] + | | +- 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 = "value", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 3, @containsComment = false] + | +- IfStatement[@Else = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.LE, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "value", @Name = "value", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | +- ThrowStatement[] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "IllegalArgumentException"] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "non-positive value", @Empty = false, @Image = "\"non-positive value\"", @Length = 18, @LiteralText = "\"non-positive value\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = true, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | | +- VariableDeclarator[@Initializer = true, @Name = "valueAsString"] + | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "valueAsString", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "valueOf", @MethodName = "valueOf", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "value", @Name = "value", @ParenthesisDepth = 0, @Parenthesized = false] + | +- ExplicitConstructorInvocation[@ArgumentCount = 1, @MethodName = "new", @Qualified = false, @Super = true, @This = false] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "valueAsString", @Name = "valueAsString", @ParenthesisDepth = 0, @Parenthesized = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$Super", @CanonicalName = "Jep447_StatementsBeforeSuper.Super", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Super", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"] + | +- ClassBody[@Empty = false, @Size = 1] + | +- ConstructorDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "Super", @Name = "Super", @Varargs = false, @Visibility = Visibility.V_PUBLIC, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- FormalParameters[@Empty = false, @Size = 1] + | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ArrayType[@ArrayDepth = 1] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.BYTE] + | | | +- 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 = "bytes", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = true, @Size = 0, @containsComment = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$Sub", @CanonicalName = "Jep447_StatementsBeforeSuper.Sub", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Sub", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- ExtendsList[@Empty = false, @Size = 1] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Super"] + | +- ClassBody[@Empty = false, @Size = 1] + | +- ConstructorDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "Sub", @Name = "Sub", @Varargs = false, @Visibility = Visibility.V_PUBLIC, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- 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 = "Certificate"] + | | +- 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 = "certificate", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 4, @containsComment = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- VariableDeclarator[@Initializer = true, @Name = "publicKey"] + | | +- 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 = "publicKey", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- MethodCall[@CompileTimeConstant = false, @Image = "getPublicKey", @MethodName = "getPublicKey", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "certificate", @Name = "certificate", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- IfStatement[@Else = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.EQ, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "publicKey", @Name = "publicKey", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ThrowStatement[] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "IllegalArgumentException"] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "null certificate", @Empty = false, @Image = "\"null certificate\"", @Length = 16, @LiteralText = "\"null certificate\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = true, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"] + | | +- ArrayType[@ArrayDepth = 1] + | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.BYTE] + | | | +- ArrayDimensions[@Empty = false, @Size = 1] + | | | +- ArrayTypeDim[@Varargs = false] + | | +- VariableDeclarator[@Initializer = true, @Name = "byteArray"] + | | +- VariableId[@ArrayType = true, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "byteArray", @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 = "publicKey", @Name = "publicKey", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- SwitchArrowBranch[@Default = false] + | | | +- SwitchLabel[@Default = false] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "RSAKey"] + | | | | +- 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 = "rsaKey", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "getBytes", @MethodName = "getBytes", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "toString", @MethodName = "toString", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "rsaKey", @Name = "rsaKey", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "UTF_8", @Name = "UTF_8", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "StandardCharsets"] + | | +- SwitchArrowBranch[@Default = false] + | | | +- SwitchLabel[@Default = false] + | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] + | | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | | +- ClassType[@FullyQualified = false, @SimpleName = "DSAPublicKey"] + | | | | +- 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 = "dsaKey", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "getBytes", @MethodName = "getBytes", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- MethodCall[@CompileTimeConstant = false, @Image = "toString", @MethodName = "toString", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- AmbiguousName[@CompileTimeConstant = false, @Image = "dsaKey", @Name = "dsaKey", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- ArgumentList[@Empty = true, @Size = 0] + | | | +- ArgumentList[@Empty = false, @Size = 1] + | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "UTF_8", @Name = "UTF_8", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "StandardCharsets"] + | | +- SwitchArrowBranch[@Default = true] + | | +- SwitchLabel[@Default = true] + | | +- ArrayAllocation[@ArrayDepth = 1, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ArrayType[@ArrayDepth = 1] + | | +- PrimitiveType[@Kind = PrimitiveTypeKind.BYTE] + | | +- ArrayDimensions[@Empty = false, @Size = 1] + | | +- ArrayDimExpr[@Varargs = false] + | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | +- ExplicitConstructorInvocation[@ArgumentCount = 1, @MethodName = "new", @Qualified = false, @Super = true, @This = false] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "byteArray", @Name = "byteArray", @ParenthesisDepth = 0, @Parenthesized = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$F", @CanonicalName = "Jep447_StatementsBeforeSuper.F", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "F", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"] + | +- ClassBody[@Empty = true, @Size = 0] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$Super2", @CanonicalName = "Jep447_StatementsBeforeSuper.Super2", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Super2", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"] + | +- ClassBody[@Empty = false, @Size = 1] + | +- ConstructorDeclaration[@Abstract = false, @Arity = 2, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "Super2", @Name = "Super2", @Varargs = false, @Visibility = Visibility.V_PUBLIC, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- FormalParameters[@Empty = false, @Size = 2] + | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] + | | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | | +- ClassType[@FullyQualified = false, @SimpleName = "F"] + | | | +- 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 = "f1", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- ClassType[@FullyQualified = false, @SimpleName = "F"] + | | +- 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 = "f2", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = true, @Size = 0, @containsComment = false] + +- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$Sub2", @CanonicalName = "Jep447_StatementsBeforeSuper.Sub2", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "Sub2", @Static = false, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- ExtendsList[@Empty = false, @Size = 1] + | | +- ClassType[@FullyQualified = false, @SimpleName = "Super2"] + | +- ClassBody[@Empty = false, @Size = 1] + | +- ConstructorDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "Sub2", @Name = "Sub2", @Varargs = false, @Visibility = Visibility.V_PUBLIC, @containsComment = true] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- 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 = "i", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 2, @containsComment = true] + | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] + | | +- VariableDeclarator[@Initializer = true, @Name = "f"] + | | +- 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 = "f", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = true, @Visibility = Visibility.V_LOCAL] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "F"] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- ExplicitConstructorInvocation[@ArgumentCount = 2, @MethodName = "new", @Qualified = false, @Super = true, @This = false] + | +- ArgumentList[@Empty = false, @Size = 2] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "f", @Name = "f", @ParenthesisDepth = 0, @Parenthesized = false] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "f", @Name = "f", @ParenthesisDepth = 0, @Parenthesized = false] + +- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$Range", @CanonicalName = "Jep447_StatementsBeforeSuper.Range", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Range", @Static = true, @TopLevel = false, @Visibility = Visibility.V_PUBLIC] + | +- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{public}"] + | +- 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 = "lo", @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 = "hi", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE] + | +- RecordBody[@Empty = false, @Size = 1] + | +- ConstructorDeclaration[@Abstract = false, @Arity = 3, @EffectiveVisibility = Visibility.V_PACKAGE, @Image = "Range", @Name = "Range", @Varargs = false, @Visibility = Visibility.V_PUBLIC, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] + | +- FormalParameters[@Empty = false, @Size = 3] + | | +- 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 = "lo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- 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 = "hi", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | | +- 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 = "maxDistance", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] + | +- Block[@Empty = false, @Size = 3, @containsComment = false] + | +- IfStatement[@Else = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lo", @Name = "lo", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "hi", @Name = "hi", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ThrowStatement[] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "IllegalArgumentException"] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- 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 = 3] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "(%d,%d)", @Empty = false, @Image = "\"(%d,%d)\"", @Length = 7, @LiteralText = "\"(%d,%d)\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lo", @Name = "lo", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "hi", @Name = "hi", @ParenthesisDepth = 0, @Parenthesized = false] + | +- IfStatement[@Else = false] + | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.GT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.SUB, @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "hi", @Name = "hi", @ParenthesisDepth = 0, @Parenthesized = false] + | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lo", @Name = "lo", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "maxDistance", @Name = "maxDistance", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- ThrowStatement[] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "IllegalArgumentException"] + | | +- ArgumentList[@Empty = false, @Size = 1] + | | +- 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 = 4] + | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "(%d,%d,%d", @Empty = false, @Image = "\"(%d,%d,%d\"", @Length = 9, @LiteralText = "\"(%d,%d,%d\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lo", @Name = "lo", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "hi", @Name = "hi", @ParenthesisDepth = 0, @Parenthesized = false] + | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "maxDistance", @Name = "maxDistance", @ParenthesisDepth = 0, @Parenthesized = false] + | +- ExplicitConstructorInvocation[@ArgumentCount = 2, @MethodName = "new", @Qualified = false, @Super = false, @This = true] + | +- ArgumentList[@Empty = false, @Size = 2] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "lo", @Name = "lo", @ParenthesisDepth = 0, @Parenthesized = false] + | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "hi", @Name = "hi", @ParenthesisDepth = 0, @Parenthesized = false] + +- EnumDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "Jep447_StatementsBeforeSuper$Color", @CanonicalName = "Jep447_StatementsBeforeSuper.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_PUBLIC] + +- ModifierList[@EffectiveModifiers = "{public, static, final}", @ExplicitModifiers = "{public}"] + +- EnumBody[@Empty = false, @SeparatorSemi = true, @Size = 4, @TrailingComma = false] + +- 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] + | +- ArgumentList[@Empty = false, @Size = 1] + | +- 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] + +- ConstructorDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Image = "Color", @Name = "Color", @Varargs = false, @Visibility = Visibility.V_PRIVATE, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] + | +- FormalParameters[@Empty = true, @Size = 0] + | +- Block[@Empty = true, @Size = 0, @containsComment = false] + +- ConstructorDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PRIVATE, @Image = "Color", @Name = "Color", @Varargs = false, @Visibility = Visibility.V_PRIVATE, @containsComment = false] + | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] + | +- 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 = "a", @PatternBinding = false, @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.LT, @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "a", @Name = "a", @ParenthesisDepth = 0, @Parenthesized = false] + | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] + | | +- ThrowStatement[] + | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] + | | +- ClassType[@FullyQualified = false, @SimpleName = "IllegalArgumentException"] + | | +- ArgumentList[@Empty = true, @Size = 0] + | +- ExplicitConstructorInvocation[@ArgumentCount = 0, @MethodName = "new", @Qualified = false, @Super = false, @This = true] + | +- ArgumentList[@Empty = true, @Size = 0] + +- EmptyDeclaration[] From 2a1aaa6bce086aff65f33e2959ad1482596990ad Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 15:07:50 +0100 Subject: [PATCH 12/39] [java] Fix tests with ExplicitConstructorInvocations --- pmd-java/etc/grammar/Java.jjt | 8 ++++++-- .../pmd/lang/java/ast/AllJavaAstTreeDumpTest.java | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 3c18bbd5c3..65f530b19e 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1524,8 +1524,12 @@ private void ConstructorBlock() #Block: {} { "{" { tokenContexts.push(TokenContext.BLOCK); } - ( LOOKAHEAD(2) BlockStatement() )* - [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ] + ( + LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() + | + ( LOOKAHEAD(2) BlockStatement() )* + [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ] + ) ( BlockStatement() )* "}" { tokenContexts.pop(); } } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java index 64c8afd050..cd1e20ef28 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AllJavaAstTreeDumpTest.java @@ -17,7 +17,8 @@ import org.junit.platform.suite.api.Suite; Java17TreeDumpTest.class, Java21TreeDumpTest.class, Java21PreviewTreeDumpTest.class, - Java22TreeDumpTest.class + Java22TreeDumpTest.class, + Java22PreviewTreeDumpTest.class }) class AllJavaAstTreeDumpTest { From 01647beb5943c77f8d2d9c93eeadd790dcb48f09 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 15:13:27 +0100 Subject: [PATCH 13/39] [doc] Update release notes (#4794) Java 22 --- docs/pages/release_notes.md | 24 ++++++++++++++++++++++++ docs/pages/release_notes_pmd7.md | 22 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 0d1a0b54dd..cd16d4e593 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -73,6 +73,28 @@ As PMD 7 revamped the Java module, if you have custom rules, you need to migrate See the use case [I'm using custom rules]({{ baseurl }}pmd_userdocs_migrating_to_pmd7.html#im-using-custom-rules) in the Migration Guide. +##### Java 22 Support + +This release of PMD brings support for Java 22. There are the following new standard language features, +that are supported now: + +* [JEP 456: Unnamed Variables & Patterns](https://openjdk.org/jeps/456) + +PMD also supports the following preview language features: + +* [JEP 447: Statements before super(...) (Preview)](https://openjdk.org/jeps/447) +* [JEP 459: String Templates (Second Preview)](https://openjdk.org/jeps/459) +* [JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)](https://openjdk.org/jeps/463) + +In order to analyze a project with PMD that uses these language features, +you'll need to enable it via the environment variable `PMD_JAVA_OPTS` and select the new language +version `22-preview`: + + export PMD_JAVA_OPTS=--enable-preview + pmd check --use-version java-22-preview ... + +Note: Support for Java 20 preview language features have been removed. The version "20-preview" is no longer available. + ##### Swift Support * limited support for Swift 5.9 (Macro Expansions) @@ -212,6 +234,7 @@ The rules have been moved into categories with PMD 6. * [#3751](https://github.com/pmd/pmd/issues/3751): \[java] Rename some node types * [#4628](https://github.com/pmd/pmd/pull/4628): \[java] Support loading classes from java runtime images * [#4753](https://github.com/pmd/pmd/issues/4753): \[java] PMD crashes while using generics and wildcards + * [#4794](https://github.com/pmd/pmd/issues/4794): \[java] Support JDK 22 * java-codestyle * [#2847](https://github.com/pmd/pmd/issues/2847): \[java] New Rule: Use Explicit Types * [#4578](https://github.com/pmd/pmd/issues/4578): \[java] CommentDefaultAccessModifier comment needs to be before annotation if present @@ -872,6 +895,7 @@ Language specific fixes: * [#4583](https://github.com/pmd/pmd/issues/4583): \[java] Support JDK 21 (LTS) * [#4628](https://github.com/pmd/pmd/pull/4628): \[java] Support loading classes from java runtime images * [#4753](https://github.com/pmd/pmd/issues/4753): \[java] PMD crashes while using generics and wildcards + * [#4794](https://github.com/pmd/pmd/issues/4794): \[java] Support JDK 22 * java-bestpractices * [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled * [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors diff --git a/docs/pages/release_notes_pmd7.md b/docs/pages/release_notes_pmd7.md index cf71d941ff..4ad03ad34b 100644 --- a/docs/pages/release_notes_pmd7.md +++ b/docs/pages/release_notes_pmd7.md @@ -218,6 +218,28 @@ module `pmd-coco`. Contributors: [Wener](https://github.com/wener-tiobe) (@wener-tiobe) +### Java 22 Support + +This release of PMD brings support for Java 22. There are the following new standard language features, +that are supported now: + +* [JEP 456: Unnamed Variables & Patterns](https://openjdk.org/jeps/456) + +PMD also supports the following preview language features: + +* [JEP 447: Statements before super(...) (Preview)](https://openjdk.org/jeps/447) +* [JEP 459: String Templates (Second Preview)](https://openjdk.org/jeps/459) +* [JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)](https://openjdk.org/jeps/463) + +In order to analyze a project with PMD that uses these language features, +you'll need to enable it via the environment variable `PMD_JAVA_OPTS` and select the new language +version `22-preview`: + + export PMD_JAVA_OPTS=--enable-preview + pmd check --use-version java-22-preview ... + +Note: Support for Java 20 preview language features have been removed. The version "20-preview" is no longer available. + ### New: Java 21 Support This release of PMD brings support for Java 21. There are the following new standard language features, From ac2c52e2201d4928a715ec5b23eae5259cf28761 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 16:33:13 +0100 Subject: [PATCH 14/39] [ant] Fix ant Formatter with Java 22 Java 22 provides a real console from System.console() even if it is non-interactive. In that case, we need to check whether we have a terminal. --- .../java/net/sourceforge/pmd/ant/Formatter.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java index 48296af944..f592c0f2ef 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -210,8 +211,21 @@ public class Formatter { private static String getConsoleEncoding() { Console console = System.console(); - // in case of pipe or redirect, no interactive console. + // in case of pipe or redirect, no interactive console, we get null if (console != null) { + // Since Java 22, this returns a console even for redirected streams. + // In that case, we need to check Console.isTerminal() + // See: JLine As The Default Console Provider (JDK-8308591) + try { + Boolean isTerminal = (Boolean) MethodUtils.invokeMethod(console, "isTerminal"); + if (!isTerminal) { + // stop here, we don't have an interactive console. + return null; + } + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + // fall-through - we use a Java Runtime < 22. + } + try { Object res = FieldUtils.readDeclaredField(console, "cs", true); if (res instanceof Charset) { From ccebca525c4768fe9271eb86d12a6dfa4b2826e6 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 17:05:07 +0100 Subject: [PATCH 15/39] Ignore empty catch block --- pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java index f592c0f2ef..865944a300 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java @@ -222,7 +222,7 @@ public class Formatter { // stop here, we don't have an interactive console. return null; } - } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException ignored) { // fall-through - we use a Java Runtime < 22. } From 0f7dff69091217e09686f636df9217e529de52bf Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 17 Feb 2024 18:38:42 +0100 Subject: [PATCH 16/39] [compat6] Support configuration errors --- pmd-compat6/src/it/pmd-for-java/config_error_ruleset.xml | 5 +++++ pmd-compat6/src/it/pmd-for-java/pom.xml | 1 + pmd-compat6/src/it/pmd-for-java/verify.bsh | 3 +++ .../src/main/java/net/sourceforge/pmd/reporting/Report.java | 5 +++++ 4 files changed, 14 insertions(+) create mode 100644 pmd-compat6/src/it/pmd-for-java/config_error_ruleset.xml diff --git a/pmd-compat6/src/it/pmd-for-java/config_error_ruleset.xml b/pmd-compat6/src/it/pmd-for-java/config_error_ruleset.xml new file mode 100644 index 0000000000..1d646a3073 --- /dev/null +++ b/pmd-compat6/src/it/pmd-for-java/config_error_ruleset.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pmd-compat6/src/it/pmd-for-java/pom.xml b/pmd-compat6/src/it/pmd-for-java/pom.xml index 55682ec03b..9ba028cf53 100644 --- a/pmd-compat6/src/it/pmd-for-java/pom.xml +++ b/pmd-compat6/src/it/pmd-for-java/pom.xml @@ -35,6 +35,7 @@ /rulesets/java/maven-pmd-plugin-default.xml ${project.basedir}/exception_ruleset.xml + ${project.basedir}/config_error_ruleset.xml diff --git a/pmd-compat6/src/it/pmd-for-java/verify.bsh b/pmd-compat6/src/it/pmd-for-java/verify.bsh index 43e010d774..5e813cab8b 100644 --- a/pmd-compat6/src/it/pmd-for-java/verify.bsh +++ b/pmd-compat6/src/it/pmd-for-java/verify.bsh @@ -36,6 +36,9 @@ if (!pmdXml.contains(mainFile + "\">")) { if (!pmdXml.contains("")) { + throw new RuntimeException("Configuration error has not been reported"); +} File pmdCsvReport = new File(basedir, "target/pmd.csv"); if (!pmdCsvReport.exists()) { diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java index 22d8b59758..39dbfd1036 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java @@ -13,6 +13,11 @@ public class Report extends net.sourceforge.pmd.Report { public ConfigurationError(Rule theRule, String theIssue) { super(theRule, theIssue); } + + @Override + public net.sourceforge.pmd.lang.rule.Rule rule() { + return (net.sourceforge.pmd.lang.rule.Rule) super.rule(); + } } public static class ProcessingError extends net.sourceforge.pmd.Report.ProcessingError { From b223b1a672439fc0707e279326b1ce3255513da0 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 17 Feb 2024 18:39:50 +0100 Subject: [PATCH 17/39] [compat6] Support other cpd languages like cs --- .../src/it/cpd-for-csharp/invoker.properties | 2 + pmd-compat6/src/it/cpd-for-csharp/pom.xml | 78 +++++++++++++++++++ .../it/cpd-for-csharp/src/main/cs/strings1.cs | 12 +++ .../it/cpd-for-csharp/src/main/cs/strings2.cs | 12 +++ pmd-compat6/src/it/cpd-for-csharp/verify.bsh | 46 +++++++++++ .../sourceforge/pmd/cpd/CPDConfiguration.java | 3 + .../sourceforge/pmd/cpd/LanguageFactory.java | 45 ++++++++++- 7 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 pmd-compat6/src/it/cpd-for-csharp/invoker.properties create mode 100644 pmd-compat6/src/it/cpd-for-csharp/pom.xml create mode 100644 pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings1.cs create mode 100644 pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings2.cs create mode 100644 pmd-compat6/src/it/cpd-for-csharp/verify.bsh diff --git a/pmd-compat6/src/it/cpd-for-csharp/invoker.properties b/pmd-compat6/src/it/cpd-for-csharp/invoker.properties new file mode 100644 index 0000000000..0d92d959f3 --- /dev/null +++ b/pmd-compat6/src/it/cpd-for-csharp/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = verify +invoker.buildResult = failure diff --git a/pmd-compat6/src/it/cpd-for-csharp/pom.xml b/pmd-compat6/src/it/cpd-for-csharp/pom.xml new file mode 100644 index 0000000000..d324ef4634 --- /dev/null +++ b/pmd-compat6/src/it/cpd-for-csharp/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + net.sourceforge.pmd.pmd-compat6.it + cpd-for-csharp + 1.0-SNAPSHOT + + + 11 + 11 + UTF-8 + + + + + + org.apache.maven.plugins + maven-pmd-plugin + @maven-pmd-plugin.version.for.integrationtest@ + + + csharp-cpd-check + + cpd-check + + + + + cs + 10 + + **/*.cs + + + ${basedir}/src/main/cs + + true + false + + + + net.sourceforge.pmd + pmd-compat6 + @project.version@ + + + net.sourceforge.pmd + pmd-core + @pmd.version.for.integrationtest@ + + + net.sourceforge.pmd + pmd-java + @pmd.version.for.integrationtest@ + + + net.sourceforge.pmd + pmd-javascript + @pmd.version.for.integrationtest@ + + + net.sourceforge.pmd + pmd-jsp + @pmd.version.for.integrationtest@ + + + net.sourceforge.pmd + pmd-cs + @pmd.version.for.integrationtest@ + + + + + + diff --git a/pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings1.cs b/pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings1.cs new file mode 100644 index 0000000000..b36845bb8a --- /dev/null +++ b/pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings1.cs @@ -0,0 +1,12 @@ +class Foo { + void bar() { + + var test = $@"test"; + var test2 = @$"test"; + + String query = + @"SELECT foo, bar + FROM table + WHERE id = 42"; + } +} diff --git a/pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings2.cs b/pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings2.cs new file mode 100644 index 0000000000..b36845bb8a --- /dev/null +++ b/pmd-compat6/src/it/cpd-for-csharp/src/main/cs/strings2.cs @@ -0,0 +1,12 @@ +class Foo { + void bar() { + + var test = $@"test"; + var test2 = @$"test"; + + String query = + @"SELECT foo, bar + FROM table + WHERE id = 42"; + } +} diff --git a/pmd-compat6/src/it/cpd-for-csharp/verify.bsh b/pmd-compat6/src/it/cpd-for-csharp/verify.bsh new file mode 100644 index 0000000000..f5db9350bd --- /dev/null +++ b/pmd-compat6/src/it/cpd-for-csharp/verify.bsh @@ -0,0 +1,46 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + +String readFile(File file) throws IOException { + StringBuilder content = new StringBuilder(); + for (String line : Files.readAllLines(file.toPath(), StandardCharsets.UTF_8)) { + content.append(line).append(System.lineSeparator()); + } + return content.toString(); +} + +File buildLogPath = new File(basedir, "build.log"); +String buildLog = readFile(buildLogPath); +if (buildLog.contains("An API incompatibility was encountered while")) { + throw new RuntimeException("Executing failed due to API incompatibility"); +} + +if (!buildLog.contains("[INFO] CPD Failure: Found 12 lines of duplicated code at locations:")) { + throw new RuntimeException("No CPD failures detected, did CPD run?"); +} +File classA = new File("cpd-for-csharp/src/main/cs/strings1.cs"); +if (!buildLog.contains(classA + " line 1")) { + throw new RuntimeException("No CPD failures detected, did CPD run?"); +} +File classB = new File("cpd-for-csharp/src/main/cs/strings2.cs"); +if (!buildLog.contains(classA + " line 1")) { + throw new RuntimeException("No CPD failures detected, did CPD run?"); +} + +File cpdXmlReport = new File(basedir, "target/cpd.xml"); +if (!cpdXmlReport.exists()) { + throw new FileNotFoundException("Could not find cpd xml report: " + cpdXmlReport); +} +String cpdXml = readFile(cpdXmlReport); +if (!cpdXml.contains("")) { + throw new RuntimeException("Expected duplication has not been reported"); +} +if (!cpdXml.contains(classA + "\"/>")) { + throw new RuntimeException("Expected duplication has not been reported"); +} +if (!cpdXml.contains(classB + "\"/>")) { + throw new RuntimeException("Expected duplication has not been reported"); +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java index a747e69b2c..133ffec71d 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java @@ -295,6 +295,9 @@ public class CPDConfiguration extends AbstractConfiguration { } else if (language instanceof JSPLanguage) { filenameFilter = language.getFileFilter(); setForceLanguageVersion(JspLanguageModule.getInstance().getDefaultVersion()); + } else if (language instanceof LanguageFactory.CpdLanguageAdapter) { + filenameFilter = language.getFileFilter(); + setForceLanguageVersion(((LanguageFactory.CpdLanguageAdapter) language).getLanguage().getDefaultVersion()); } else { throw new UnsupportedOperationException("Language " + language.getName() + " is not supported"); } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java index 09769cd57b..8191bcb298 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java @@ -10,6 +10,11 @@ package net.sourceforge.pmd.cpd; import java.util.Properties; +import java.util.stream.Collectors; + +import net.sourceforge.pmd.lang.LanguagePropertyBundle; +import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.properties.PropertyDescriptor; public final class LanguageFactory { private LanguageFactory() { @@ -17,6 +22,44 @@ public final class LanguageFactory { } public static Language createLanguage(String name, Properties properties) { - throw new UnsupportedOperationException(); + CpdCapableLanguage cpdLanguage = (CpdCapableLanguage) LanguageRegistry.CPD.getLanguageById(name); + if (cpdLanguage != null) { + return new CpdLanguageAdapter(cpdLanguage, properties); + } + throw new UnsupportedOperationException("Language " + name + " is not supported"); + } + + public static class CpdLanguageAdapter extends AbstractLanguage { + private CpdCapableLanguage language; + + public CpdLanguageAdapter(CpdCapableLanguage cpdCapableLanguage, Properties properties) { + super(cpdCapableLanguage.getName(), cpdCapableLanguage.getId(), createLexer(cpdCapableLanguage, properties), convertExtensions(cpdCapableLanguage)); + this.language = cpdCapableLanguage; + } + + private static Tokenizer createLexer(CpdCapableLanguage cpdCapableLanguage, Properties properties) { + LanguagePropertyBundle propertyBundle = cpdCapableLanguage.newPropertyBundle(); + for (String propName : properties.stringPropertyNames()) { + PropertyDescriptor propertyDescriptor = propertyBundle.getPropertyDescriptor(propName); + if (propertyDescriptor != null) { + setProperty(propertyBundle, propertyDescriptor, properties.getProperty(propName)); + } + } + CpdLexer cpdLexer = cpdCapableLanguage.createCpdLexer(propertyBundle); + return cpdLexer::tokenize; + } + + private static void setProperty(LanguagePropertyBundle propertyBundle, PropertyDescriptor propertyDescriptor, String stringValue) { + T value = propertyDescriptor.serializer().fromString(stringValue); + propertyBundle.setProperty(propertyDescriptor, value); + } + + private static String[] convertExtensions(CpdCapableLanguage cpdCapableLanguage) { + return cpdCapableLanguage.getExtensions().stream().map(s -> "." + s).collect(Collectors.toList()).toArray(new String[0]); + } + + public CpdCapableLanguage getLanguage() { + return language; + } } } From 3dd4ace6438540b97783b8242355710d6d6c14b0 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 18 Feb 2024 09:13:04 +0100 Subject: [PATCH 18/39] [compat6] add dependency to pmd-cs --- pmd-compat6/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pmd-compat6/pom.xml b/pmd-compat6/pom.xml index 10d2fc34c3..e9385ac4ff 100644 --- a/pmd-compat6/pom.xml +++ b/pmd-compat6/pom.xml @@ -39,6 +39,11 @@ pmd-jsp ${project.version} + + net.sourceforge.pmd + pmd-cs + ${project.version} + From f2aedc86e519d7aacd3db59f13eb2f6a65b18394 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 18 Feb 2024 09:15:11 +0100 Subject: [PATCH 19/39] [doc] Update release notes (#4827) --- docs/pages/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 885c20c5b0..5ca92f7686 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -204,6 +204,7 @@ The rules have been moved into categories with PMD 6. * [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 * [#4776](https://github.com/pmd/pmd/issues/4776): \[ci] Upgrade to ruby 3 * [#4796](https://github.com/pmd/pmd/pull/4796): Remove deprecated and release rulesets + * [#4827](https://github.com/pmd/pmd/pull/4827): \[compat6] Support config errors and cpd for csharp * apex-performance * [#4675](https://github.com/pmd/pmd/issues/4675): \[apex] New Rule: OperationWithHighCostInLoop * groovy @@ -726,6 +727,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7. * [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 * [#4776](https://github.com/pmd/pmd/issues/4776): \[ci] Upgrade to ruby 3 * [#4796](https://github.com/pmd/pmd/pull/4796): Remove deprecated and release rulesets + * [#4827](https://github.com/pmd/pmd/pull/4827): \[compat6] Support config errors and cpd for csharp * ant * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core From 621cd0e0137390e16d1ce6df3707575c8419fa39 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Feb 2024 09:01:55 +0100 Subject: [PATCH 20/39] Update to use renamed pmd-designer See pmd/pmd-designer#80 --- do-release.sh | 2 +- .../adding_a_new_javacc_based_language.md | 2 +- docs/pages/pmd/userdocs/extending/designer_reference.md | 6 +++--- docs/pages/release_notes.md | 2 ++ pmd-cli/pom.xml | 2 +- pmd-dist/pom.xml | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/do-release.sh b/do-release.sh index 28d9d70e4a..ac43cffdb5 100755 --- a/do-release.sh +++ b/do-release.sh @@ -281,7 +281,7 @@ echo "Then proceed with releasing pmd-designer..." echo "" echo echo "Press enter to continue when pmd-designer is available in maven-central..." -echo "." +echo "." echo echo "Note: If there is no new pmd-designer release needed, you can directly proceed." read -r diff --git a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md index fe5caf5aec..dc5981e86e 100644 --- a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md +++ b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md @@ -252,7 +252,7 @@ This can be achieved with Rule Designer: * Fork and clone the [pmd/pmd-designer](https://github.com/pmd/pmd-designer) repository. * Add a syntax highlighter implementation to `net.sourceforge.pmd.util.fxdesigner.util.codearea.syntaxhighlighting` (you could use Java as an example). * Register it in the `AvailableSyntaxHighlighters` enumeration. - * Now build your implementation and place the `target/pmd-ui--SNAPSHOT.jar` to the `lib` directory inside your `pmd-bin-...` distribution (you have to delete old `pmd-ui-*.jar` from there). + * Now build your implementation and place the `target/pmd-designer--SNAPSHOT.jar` to the `lib` directory inside your `pmd-bin-...` distribution (you have to delete old `pmd-designer-*.jar` from there). ## Optional features diff --git a/docs/pages/pmd/userdocs/extending/designer_reference.md b/docs/pages/pmd/userdocs/extending/designer_reference.md index 33af658835..c6ba0a79cf 100644 --- a/docs/pages/pmd/userdocs/extending/designer_reference.md +++ b/docs/pages/pmd/userdocs/extending/designer_reference.md @@ -3,7 +3,7 @@ title: The rule designer short_title: Rule designer tags: [extending, userdocs] summary: "Learn about the usage and features of the rule designer." -last_updated: December 2023 (7.0.0) +last_updated: February 2024 (7.0.0) permalink: pmd_userdocs_extending_designer_reference.html author: Clément Fournier --- @@ -25,7 +25,7 @@ If the bin directory of your PMD distribution is on your shell's path, then you windows="pmd.bat designer" %} -{% include note.html content="pmd-ui.jar is not a runnable jar, because it doesn't include any PMD language module, or PMD Core. " %} +{% include note.html content="pmd-designer.jar is not a runnable jar, because it doesn't include any PMD language module, or PMD Core. " %} This is to allow easy updating, and let you choose the dependencies you're interested in. @@ -36,7 +36,7 @@ standard PMD startup scripts, which setups the classpath with the available PMD ### Updating The latest version of the designer currently **works with PMD 7.0.0 and above**. You can simply replace -pmd-ui-7.X.Y.jar with the [latest build](https://github.com/pmd/pmd-designer/releases) in the installation +pmd-designer-7.X.Y.jar with the [latest build](https://github.com/pmd/pmd-designer/releases) in the installation folder of your PMD distribution, and run it normally. Note that updating may cause some persisted state to get lost, for example the code snippet. diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 6dd6099c26..81485fd438 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -264,6 +264,7 @@ The rules have been moved into categories with PMD 6. * [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 * [#4776](https://github.com/pmd/pmd/issues/4776): \[ci] Upgrade to ruby 3 * [#4796](https://github.com/pmd/pmd/pull/4796): Remove deprecated and release rulesets + * [#4823](https://github.com/pmd/pmd/pull/4823): Update to use renamed pmd-designer * apex * [#3766](https://github.com/pmd/pmd/issues/3766): \[apex] Replace Jorje with fully open source front-end * apex-performance @@ -1220,6 +1221,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7. * [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 * [#4776](https://github.com/pmd/pmd/issues/4776): \[ci] Upgrade to ruby 3 * [#4796](https://github.com/pmd/pmd/pull/4796): Remove deprecated and release rulesets + * [#4823](https://github.com/pmd/pmd/pull/4823): Update to use renamed pmd-designer * ant * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core diff --git a/pmd-cli/pom.xml b/pmd-cli/pom.xml index 81fc5d26b2..9efefa2cbc 100644 --- a/pmd-cli/pom.xml +++ b/pmd-cli/pom.xml @@ -32,7 +32,7 @@ net.sourceforge.pmd - pmd-ui + pmd-designer ${pmd-designer.version} diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index fdd6d93f97..998ed84cf8 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -146,7 +146,7 @@ net.sourceforge.pmd - pmd-ui + pmd-designer ${pmd-designer.version} From 9adf12f7bee2a8281839c4b7e6729c226f9cf9ec Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 23 Feb 2024 21:15:04 +0100 Subject: [PATCH 21/39] [doc] Fix configuring rule docu for multivalues properties Fixes #4704 --- docs/pages/pmd/userdocs/configuring_rules.md | 22 ++++++++++++++------ docs/pages/release_notes.md | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/pages/pmd/userdocs/configuring_rules.md b/docs/pages/pmd/userdocs/configuring_rules.md index 4cf888a280..d0425f1921 100644 --- a/docs/pages/pmd/userdocs/configuring_rules.md +++ b/docs/pages/pmd/userdocs/configuring_rules.md @@ -4,7 +4,7 @@ short_title: Configuring rules keywords: [property, properties, message, priority] tags: [userdocs, getting_started] summary: "Learn how to configure your rules directly from the ruleset XML." -last_updated: May 2023 (7.0.0) +last_updated: February 2024 (7.0.0) permalink: pmd_userdocs_configuring_rules.html author: Hooper Bloob , Romain Pelisse , Clément Fournier --- @@ -43,7 +43,10 @@ will cause the rule to be ignored. ## Rule properties -Properties make it easy to customise the behaviour of a rule directly from the xml. They come in several types, which correspond to the type of their values. For example, NPathComplexity declares a property "reportLevel", with an integer value type, and which corresponds to the threshold above which a method will be reported. If you believe that its default value of 200 is too high, you could lower it to e.g. 150 in the following way: +Properties make it easy to customise the behaviour of a rule directly from the xml. They come in several types, +which correspond to the type of their values. For example, NPathComplexity declares a property "reportLevel", +with an integer value type, and which corresponds to the threshold above which a method will be reported. +If you believe that its default value of 200 is too high, you could lower it to e.g. 150 in the following way: ```xml @@ -55,7 +58,9 @@ Properties make it easy to customise the behaviour of a rule directly from the x ``` -Properties are assigned a value with a `property` element, which should mention the name of a property as an attribute. The value of the property can be specified either in the content of the element, like above, or in the `value` attribute, e.g. +Properties are assigned a value with a `property` element, which should mention the name of a property as an +attribute. The value of the property can be specified either in the content of the element, like above, or +in the `value` attribute, e.g. ```xml @@ -63,12 +68,17 @@ Properties are assigned a value with a `property` element, which should mention All property assignments must be enclosed in a `properties` element, which is itself inside a `rule` element. -{%include tip.html content="The properties of a rule are documented with the rule, e.g. [here](pmd_rules_java_design.html#npathcomplexity) for NPathComplexity. Note that **assigning a value to a property that does not exist throws an error!**" %} +{% capture tip_content %} +The properties of a rule are documented with the rule, e.g. [here](pmd_rules_java_design.html#npathcomplexity) +for NPathComplexity. Note that **assigning a value to a property that does not exist throws an error!** +{% endcapture %} +{%include tip.html content=tip_content %} -Some properties take multiple values (a list), in which case you can provide them all by delimiting them with a delimiter character. It is usually a pipe ('\|'), or a comma (',') for numeric properties, e.g. +Some properties take multiple values (a list), in which case you can provide them all by delimiting them with +a comma (','), e.g. ```xml + value="java.util.ArrayList,java.util.Vector,java.util.HashMap"/> ``` These properties are referred to as **multivalued properties** in this documentation. diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 6dd6099c26..3bfa1a48aa 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -255,6 +255,7 @@ The rules have been moved into categories with PMD 6. * [#4659](https://github.com/pmd/pmd/pull/4659): \[doc] Improve ant documentation * [#4669](https://github.com/pmd/pmd/pull/4669): \[doc] Add bld PMD Extension to Tools / Integrations * [#4676](https://github.com/pmd/pmd/issues/4676): \[doc] Clarify how CPD `--ignore-literals` and `--ignore-identifiers` work + * [#4704](https://github.com/pmd/pmd/issues/4704): \[doc] Multivalued properties do not accept | as a separator * miscellaneous * [#4699](https://github.com/pmd/pmd/pull/4699): Make PMD buildable with java 21 * [#4586](https://github.com/pmd/pmd/pull/4586): Use explicit encoding in ruleset xml files @@ -1305,6 +1306,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7. * [#4676](https://github.com/pmd/pmd/issues/4676): \[doc] Clarify how CPD `--ignore-literals` and `--ignore-identifiers` work * [#4659](https://github.com/pmd/pmd/pull/4659): \[doc] Improve ant documentation * [#4669](https://github.com/pmd/pmd/pull/4669): \[doc] Add bld PMD Extension to Tools / Integrations + * [#4704](https://github.com/pmd/pmd/issues/4704): \[doc] Multivalued properties do not accept | as a separator * testing * [#2435](https://github.com/pmd/pmd/issues/2435): \[test] Remove duplicated Dummy language module * [#4234](https://github.com/pmd/pmd/issues/4234): \[test] Tests that change the logging level do not work From 53323de95143c1616ee0a67e6dc18562903079d4 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 26 Feb 2024 19:25:56 +0100 Subject: [PATCH 22/39] [apex] MethodNamingConventions: Remove prop skipTestMethodUnderscores This property was deprecated since PMD 6.15.0. --- docs/pages/release_notes.md | 9 +++++ docs/pages/release_notes_pmd7.md | 6 ++++ .../MethodNamingConventionsRule.java | 15 +------- .../codestyle/xml/MethodNamingConventions.xml | 35 ------------------- 4 files changed, 16 insertions(+), 49 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 6dd6099c26..7f30add175 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -138,6 +138,9 @@ Experimental Kotlin support has been promoted as stable API now. * {% rule java/codestyle/EmptyControlStatement %}: The rule has a new property to allow empty blocks when they contain a comment (`allowCommentedBlocks`). +* {% rule apex/codestyle/MethodNamingConventions %}: The deprecated rule property `skipTestMethodUnderscores` has + been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes + back then. Use the property `testPattern` instead to configure valid names for test methods. **Removed Rules** @@ -1083,6 +1086,12 @@ Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-g from all rules. These properties have been deprecated since PMD 6.13.0. See [issue #1648](https://github.com/pmd/pmd/issues/1648) for more details. +**Apex Codestyle** + +* {% rule apex/codestyle/MethodNamingConventions %}: The deprecated rule property `skipTestMethodUnderscores` has + been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes + back then. Use the property `testPattern` instead to configure valid names for test methods. + **Java General changes** * Violations reported on methods or classes previously reported the line range of the entire method diff --git a/docs/pages/release_notes_pmd7.md b/docs/pages/release_notes_pmd7.md index 444cdd1232..ce28426448 100644 --- a/docs/pages/release_notes_pmd7.md +++ b/docs/pages/release_notes_pmd7.md @@ -343,6 +343,12 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0 from all rules. These properties have been deprecated since PMD 6.13.0. See [issue #1648](https://github.com/pmd/pmd/issues/1648) for more details. +**Apex Codestyle** + +* {% rule apex/codestyle/MethodNamingConventions %}: The deprecated rule property `skipTestMethodUnderscores` has + been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes + back then. Use the property `testPattern` instead to configure valid names for test methods. + **Java General changes** * Violations reported on methods or classes previously reported the line range of the entire method diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java index e338090048..de3ae0a330 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; -import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty; - import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; @@ -30,14 +28,7 @@ public class MethodNamingConventionsRule extends AbstractNamingConventionsRule { private static final PropertyDescriptor INSTANCE_REGEX = prop("instancePattern", "instance method", DESCRIPTOR_TO_DISPLAY_NAME).defaultValue(CAMEL_CASE).build(); - private static final PropertyDescriptor SKIP_TEST_METHOD_UNDERSCORES_DESCRIPTOR - = booleanProperty("skipTestMethodUnderscores") - .desc("deprecated! Skip underscores in test methods") - .defaultValue(false) - .build(); - public MethodNamingConventionsRule() { - definePropertyDescriptor(SKIP_TEST_METHOD_UNDERSCORES_DESCRIPTOR); definePropertyDescriptor(TEST_REGEX); definePropertyDescriptor(STATIC_REGEX); definePropertyDescriptor(INSTANCE_REGEX); @@ -65,11 +56,7 @@ public class MethodNamingConventionsRule extends AbstractNamingConventionsRule { } if (node.getModifiers().isTest()) { - if (getProperty(SKIP_TEST_METHOD_UNDERSCORES_DESCRIPTOR)) { - checkMatches(TEST_REGEX, CAMEL_CASE_WITH_UNDERSCORES, node, data); - } else { - checkMatches(TEST_REGEX, node, data); - } + checkMatches(TEST_REGEX, node, data); } else if (node.getModifiers().isStatic()) { checkMatches(STATIC_REGEX, node, data); } else { diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/MethodNamingConventions.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/MethodNamingConventions.xml index 71e3f5f12f..4e22a60804 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/MethodNamingConventions.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/MethodNamingConventions.xml @@ -64,41 +64,6 @@ public class Foo { ]]> - - #1573 method names should not contain underscores, but skip test methods 1 - true - 0 - - - - - #1573 method names should not contain underscores, but skip test methods 2 - true - 0 - - - - - #1573 method names should not contain underscores, but skip test methods 3 - false - 1 - - - all is well 0 From fb4f4888c99d4cec2ad1e2dfe574b6e4b3426280 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 26 Feb 2024 19:26:45 +0100 Subject: [PATCH 23/39] [doc] Fix release notes, add missing change in EmptyControlStatement Refs #4754 --- docs/pages/release_notes_pmd7.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes_pmd7.md b/docs/pages/release_notes_pmd7.md index ce28426448..e051c28c08 100644 --- a/docs/pages/release_notes_pmd7.md +++ b/docs/pages/release_notes_pmd7.md @@ -390,6 +390,8 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0 not necessary are allowed, if they separate expressions of different precedence. The other property `ignoreBalancing` (default: true) is similar, in that it allows parentheses that help reading and understanding the expressions. +* {% rule java/codestyle/EmptyControlStatement %}: The rule has a new property to allow empty blocks when + they contain a comment (`allowCommentedBlocks`). **Java Design** From 504fc3e967b3c4acc63644c74863a7fe5192581d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 26 Feb 2024 19:33:00 +0100 Subject: [PATCH 24/39] [java] CommentRequired: Remove property headerCommentRequirement This property has been deprecated since PMD 6.21.0 --- docs/pages/release_notes.md | 4 +++ docs/pages/release_notes_pmd7.md | 2 ++ .../documentation/CommentRequiredRule.java | 26 ++----------------- .../documentation/CommentRequiredTest.java | 3 --- .../documentation/xml/CommentRequired.xml | 12 +-------- 5 files changed, 9 insertions(+), 38 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7f30add175..7f543baeaa 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -141,6 +141,8 @@ Experimental Kotlin support has been promoted as stable API now. * {% rule apex/codestyle/MethodNamingConventions %}: The deprecated rule property `skipTestMethodUnderscores` has been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes back then. Use the property `testPattern` instead to configure valid names for test methods. +* {% rule java/documentation/CommentRequired %}: The deprecated property `headerCommentRequirement` has been removed. + Use the property `classCommentRequirement` instead. **Removed Rules** @@ -1162,6 +1164,8 @@ Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-g See also [pull request #3757](https://github.com/pmd/pmd/pull/3757). * Elements in annotation types are now detected as well. This might lead to an increased number of violations for missing public method comments. + * The deprecated property `headerCommentRequirement` has been removed. Use the property `classCommentRequirement` + instead. * {% rule java/documentation/CommentSize %}: When determining the line-length of a comment, the leading comment prefix markers (e.g. `*` or `//`) are ignored and don't add up to the line-length. See also [pull request #4369](https://github.com/pmd/pmd/pull/4369). diff --git a/docs/pages/release_notes_pmd7.md b/docs/pages/release_notes_pmd7.md index e051c28c08..349b5acbf7 100644 --- a/docs/pages/release_notes_pmd7.md +++ b/docs/pages/release_notes_pmd7.md @@ -419,6 +419,8 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0 See also [pull request #3757](https://github.com/pmd/pmd/pull/3757). * Elements in annotation types are now detected as well. This might lead to an increased number of violations for missing public method comments. + * The deprecated property `headerCommentRequirement` has been removed. Use the property `classCommentRequirement` + instead. * {% rule java/documentation/CommentSize %}: When determining the line-length of a comment, the leading comment prefix markers (e.g. `*` or `//`) are ignored and don't add up to the line-length. See also [pull request #4369](https://github.com/pmd/pmd/pull/4369). diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java index 00a92e335e..8992970ec6 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java @@ -9,9 +9,6 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import net.sourceforge.pmd.lang.java.ast.ASTBodyDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTClassDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; @@ -35,8 +32,6 @@ import net.sourceforge.pmd.util.CollectionUtil; * @author Brian Remedios */ public class CommentRequiredRule extends AbstractJavaRulechainRule { - private static final Logger LOG = LoggerFactory.getLogger(CommentRequiredRule.class); - // Used to pretty print a message private static final Map DESCRIPTOR_NAME_TO_COMMENT_TYPE = new HashMap<>(); @@ -46,8 +41,6 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule { private static final PropertyDescriptor OVERRIDE_CMT_DESCRIPTOR = requirementPropertyBuilder("methodWithOverrideCommentRequirement", "Comments on @Override methods") .defaultValue(CommentRequirement.Ignored).build(); - private static final PropertyDescriptor HEADER_CMT_REQUIREMENT_DESCRIPTOR - = requirementPropertyBuilder("headerCommentRequirement", "Deprecated! Header comments. Please use the property \"classCommentRequired\" instead.").build(); private static final PropertyDescriptor CLASS_CMT_REQUIREMENT_DESCRIPTOR = requirementPropertyBuilder("classCommentRequirement", "Class comments").build(); private static final PropertyDescriptor FIELD_CMT_REQUIREMENT_DESCRIPTOR @@ -73,7 +66,6 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule { definePropertyDescriptor(OVERRIDE_CMT_DESCRIPTOR); definePropertyDescriptor(ACCESSOR_CMT_DESCRIPTOR); definePropertyDescriptor(CLASS_CMT_REQUIREMENT_DESCRIPTOR); - definePropertyDescriptor(HEADER_CMT_REQUIREMENT_DESCRIPTOR); definePropertyDescriptor(FIELD_CMT_REQUIREMENT_DESCRIPTOR); definePropertyDescriptor(PUB_METHOD_CMT_REQUIREMENT_DESCRIPTOR); definePropertyDescriptor(PROT_METHOD_CMT_REQUIREMENT_DESCRIPTOR); @@ -94,20 +86,7 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule { getProperty(SERIAL_VERSION_UID_CMT_REQUIREMENT_DESCRIPTOR)); propertyValues.put(SERIAL_PERSISTENT_FIELDS_CMT_REQUIREMENT_DESCRIPTOR, getProperty(SERIAL_PERSISTENT_FIELDS_CMT_REQUIREMENT_DESCRIPTOR)); - - CommentRequirement headerCommentRequirementValue = getProperty(HEADER_CMT_REQUIREMENT_DESCRIPTOR); - boolean headerCommentRequirementValueOverridden = headerCommentRequirementValue != CommentRequirement.Required; - CommentRequirement classCommentRequirementValue = getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR); - boolean classCommentRequirementValueOverridden = classCommentRequirementValue != CommentRequirement.Required; - - if (headerCommentRequirementValueOverridden && !classCommentRequirementValueOverridden) { - LOG.warn("Rule CommentRequired uses deprecated property 'headerCommentRequirement'. " - + "Future versions of PMD will remove support for this property. " - + "Please use 'classCommentRequirement' instead!"); - propertyValues.put(CLASS_CMT_REQUIREMENT_DESCRIPTOR, headerCommentRequirementValue); - } else { - propertyValues.put(CLASS_CMT_REQUIREMENT_DESCRIPTOR, classCommentRequirementValue); - } + propertyValues.put(CLASS_CMT_REQUIREMENT_DESCRIPTOR, getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR)); } private void checkCommentMeetsRequirement(Object data, JavadocCommentOwner node, @@ -203,8 +182,7 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule { return getProperty(OVERRIDE_CMT_DESCRIPTOR) == CommentRequirement.Ignored && getProperty(ACCESSOR_CMT_DESCRIPTOR) == CommentRequirement.Ignored - && (getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored - || getProperty(HEADER_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored) + && getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored && getProperty(FIELD_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored && getProperty(PUB_METHOD_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored && getProperty(PROT_METHOD_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java index 4c026b25c3..c0eefbb589 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java @@ -23,9 +23,6 @@ class CommentRequiredTest extends PmdRuleTst { assertNull(rule.dysfunctionReason(), "By default, the rule should be functional"); List> propertyDescriptors = getProperties(rule); - // remove deprecated properties - propertyDescriptors.removeIf(property -> property.description().startsWith("Deprecated!")); - for (PropertyDescriptor property : propertyDescriptors) { setPropertyValue(rule, property, "Ignored"); } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentRequired.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentRequired.xml index b8328ba236..6f4158572f 100755 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentRequired.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentRequired.xml @@ -514,17 +514,7 @@ public class CommentRequired { - #1683 [java] CommentRequired property names are inconsistent - use deprecated property - Unwanted - 1 - - - - - #1683 [java] CommentRequired property names are inconsistent - use new property + #1683 [java] CommentRequired property names are inconsistent Unwanted 1 Date: Mon, 26 Feb 2024 19:36:51 +0100 Subject: [PATCH 25/39] [java] NonSerializableClass: Remove property prefix This property has been deprecated since PMD 6.52.0 --- docs/pages/release_notes.md | 4 ++++ docs/pages/release_notes_pmd7.md | 2 ++ .../lang/java/rule/errorprone/NonSerializableClassRule.java | 4 ---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7f543baeaa..a6ad31ca1e 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -143,6 +143,8 @@ Experimental Kotlin support has been promoted as stable API now. back then. Use the property `testPattern` instead to configure valid names for test methods. * {% rule java/documentation/CommentRequired %}: The deprecated property `headerCommentRequirement` has been removed. Use the property `classCommentRequirement` instead. +* {% rule java/errorprone/NonSerializableClass %}: The deprecated property `prefix` has been removed + without replacement. In a serializable class all fields have to be serializable regardless of the name. **Removed Rules** @@ -1179,6 +1181,8 @@ Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-g special-cased anymore. Rename the exception parameter to `ignored` to ignore them. * {% rule java/errorprone/ImplicitSwitchFallThrough %}: Violations are now reported on the case statements rather than on the switch statements. This is more accurate but might result in more violations now. +* {% rule java/errorprone/NonSerializableClass %}: The deprecated property `prefix` has been removed + without replacement. In a serializable class all fields have to be serializable regardless of the name. #### Removed Rules diff --git a/docs/pages/release_notes_pmd7.md b/docs/pages/release_notes_pmd7.md index 349b5acbf7..f269965bf0 100644 --- a/docs/pages/release_notes_pmd7.md +++ b/docs/pages/release_notes_pmd7.md @@ -434,6 +434,8 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0 special-cased anymore. Rename the exception parameter to `ignored` to ignore them. * {% rule java/errorprone/ImplicitSwitchFallThrough %}: Violations are now reported on the case statements rather than on the switch statements. This is more accurate but might result in more violations now. +* {% rule java/errorprone/NonSerializableClass %}: The deprecated property `prefix` has been removed + without replacement. In a serializable class all fields have to be serializable regardless of the name. ### Deprecated Rules diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java index 136a68799c..31e5c53f2f 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java @@ -5,7 +5,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone; import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty; -import static net.sourceforge.pmd.properties.PropertyFactory.stringProperty; import java.io.Externalizable; import java.io.ObjectInputStream; @@ -45,8 +44,6 @@ import net.sourceforge.pmd.reporting.RuleContext; // Note: This rule has been formerly known as "BeanMembersShouldSerialize". public class NonSerializableClassRule extends AbstractJavaRulechainRule { - private static final PropertyDescriptor PREFIX_DESCRIPTOR = stringProperty("prefix") - .desc("deprecated! A variable prefix to skip, i.e., m_").defaultValue("").build(); private static final PropertyDescriptor CHECK_ABSTRACT_TYPES = booleanProperty("checkAbstractTypes") .desc("Enable to verify fields with abstract types like abstract classes, interfaces, generic types " + "or java.lang.Object. Enabling this might lead to more false positives, since the concrete " @@ -62,7 +59,6 @@ public class NonSerializableClassRule extends AbstractJavaRulechainRule { public NonSerializableClassRule() { super(ASTVariableId.class, ASTClassDeclaration.class, ASTEnumDeclaration.class, ASTRecordDeclaration.class); - definePropertyDescriptor(PREFIX_DESCRIPTOR); definePropertyDescriptor(CHECK_ABSTRACT_TYPES); } From b036931995f6841f54384c9f6b0e450a6e185abb Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 27 Feb 2024 19:49:23 +0100 Subject: [PATCH 26/39] Fix javadoc/dokka configuration --- pmd-ant/pom.xml | 18 ++++++++++++++++++ pmd-core/pom.xml | 9 +++++++++ pmd-lang-test/pom.xml | 13 +++++++++++++ pmd-test-schema/pom.xml | 17 +++++++++++++++++ pmd-test/pom.xml | 18 ++++++++++++++++++ pom.xml | 23 ++++++++++++++++++----- 6 files changed, 93 insertions(+), 5 deletions(-) diff --git a/pmd-ant/pom.xml b/pmd-ant/pom.xml index f8c867276c..f41b68a635 100644 --- a/pmd-ant/pom.xml +++ b/pmd-ant/pom.xml @@ -15,6 +15,24 @@ PMD Ant Integration Apache Ant integration for PMD. + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + ${project.basedir}/../pmd-core/target/apidocs + ../../pmd-core/${project.version} + + + + + + + net.sourceforge.pmd diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index 12d73daa38..7bce749567 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -33,6 +33,15 @@ + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index 61ae292f4d..fd7521f1fe 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -45,6 +45,19 @@ org.jetbrains.dokka dokka-maven-plugin + + + + + https://docs.pmd-code.org/apidocs/pmd-core/${project.version}/ + file://${project.basedir}/../pmd-core/target/apidocs/element-list + + + https://docs.pmd-code.org/apidocs/pmd-test/${project.version}/ + file://${project.basedir}/../pmd-test/target/apidocs/element-list + + + diff --git a/pmd-test-schema/pom.xml b/pmd-test-schema/pom.xml index 044b0c5e2b..c81c7b26dc 100644 --- a/pmd-test-schema/pom.xml +++ b/pmd-test-schema/pom.xml @@ -19,6 +19,23 @@ 8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + ${project.basedir}/../pmd-core/target/apidocs + ../../pmd-core/${project.version} + + + + + + diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml index 296651078d..3313f25111 100644 --- a/pmd-test/pom.xml +++ b/pmd-test/pom.xml @@ -16,6 +16,24 @@ 8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + ${project.basedir}/../pmd-core/target/apidocs + ../../pmd-core/${project.version} + + + + + + + - ${project.basedir}/../pmd-core/target/apidocs - ../../pmd-core/${project.version} + ${project.basedir}/../pmd-lang-test/target/dokkaJavadocJar + ../../pmd-lang-test/${project.version} @@ -397,6 +396,20 @@ ${dokka.version} ${dokka.skip} + + + https://docs.pmd-code.org/apidocs/pmd-core/${project.version}/ + file://${project.basedir}/../pmd-core/target/apidocs/element-list + + + https://docs.pmd-code.org/apidocs/pmd-test/${project.version}/ + file://${project.basedir}/../pmd-test/target/apidocs/element-list + + + https://docs.pmd-code.org/apidocs/pmd-lang-test/${project.version}/ + file:///${project.basedir}/../pmd-lang-test/target/dokkaJavadocJar/element-list + + From 2b70986f09a0a0ec90a1c35d3e92719470e59de2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 29 Feb 2024 08:37:01 +0100 Subject: [PATCH 27/39] [java] Verify UnnecessaryFullyQualifiedName #4631 Fixes #4631 --- docs/pages/release_notes.md | 2 ++ .../xml/UnnecessaryFullyQualifiedName.xml | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 6dd6099c26..15279cecfb 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -278,6 +278,7 @@ The rules have been moved into categories with PMD 6. * java-codestyle * [#2847](https://github.com/pmd/pmd/issues/2847): \[java] New Rule: Use Explicit Types * [#4578](https://github.com/pmd/pmd/issues/4578): \[java] CommentDefaultAccessModifier comment needs to be before annotation if present + * [#4631](https://github.com/pmd/pmd/issues/4631): \[java] UnnecessaryFullyQualifiedName fails to recognize illegal self reference in enums * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest * [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property * java-design @@ -1433,6 +1434,7 @@ Language specific fixes: * [#4512](https://github.com/pmd/pmd/issues/4512): \[java] MethodArgumentCouldBeFinal shouldn't report unused parameters * [#4557](https://github.com/pmd/pmd/issues/4557): \[java] UnnecessaryImport FP with static imports of overloaded methods * [#4578](https://github.com/pmd/pmd/issues/4578): \[java] CommentDefaultAccessModifier comment needs to be before annotation if present + * [#4631](https://github.com/pmd/pmd/issues/4631): \[java] UnnecessaryFullyQualifiedName fails to recognize illegal self reference in enums * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest * [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property * java-design diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryFullyQualifiedName.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryFullyQualifiedName.xml index 02afbeb2e0..ed66a0033c 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryFullyQualifiedName.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryFullyQualifiedName.xml @@ -1067,6 +1067,37 @@ class Scratch { @java.lang.Deprecated int aField; } +]]> + + + + [java] UnnecessaryFullyQualifiedName fails to recognize illegal self reference in enums #4631 + 0 + From ce8ca0652dac7fb4f53279180b92ac489b448a1a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 29 Feb 2024 08:40:22 +0100 Subject: [PATCH 28/39] [java] Verify UnusedPrivateMethod #4625 Fixes #4625 --- docs/pages/release_notes.md | 3 +++ .../bestpractices/xml/UnusedPrivateMethod.xml | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 15279cecfb..b98cb2f910 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -275,6 +275,8 @@ The rules have been moved into categories with PMD 6. * [#3751](https://github.com/pmd/pmd/issues/3751): \[java] Rename some node types * [#4628](https://github.com/pmd/pmd/pull/4628): \[java] Support loading classes from java runtime images * [#4753](https://github.com/pmd/pmd/issues/4753): \[java] PMD crashes while using generics and wildcards +* java-bestpractives + * [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number * java-codestyle * [#2847](https://github.com/pmd/pmd/issues/2847): \[java] New Rule: Use Explicit Types * [#4578](https://github.com/pmd/pmd/issues/4578): \[java] CommentDefaultAccessModifier comment needs to be before annotation if present @@ -1403,6 +1405,7 @@ Language specific fixes: * [#4516](https://github.com/pmd/pmd/issues/4516): \[java] UnusedLocalVariable: false-negative with try-with-resources * [#4517](https://github.com/pmd/pmd/issues/4517): \[java] UnusedLocalVariable: false-negative with compound assignments * [#4518](https://github.com/pmd/pmd/issues/4518): \[java] UnusedLocalVariable: false-positive with multiple for-loop indices + * [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number * [#4634](https://github.com/pmd/pmd/issues/4634): \[java] JUnit4TestShouldUseTestAnnotation false positive with TestNG * java-codestyle * [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml index 2a7e09a935..b4e3494aca 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml @@ -1788,4 +1788,22 @@ public class UnusedAssignmentRule { } ]]> + + + [java] UnusedPrivateMethod false positive: Autoboxing into Number #4625 + 0 + + From 87f2241f3a3c94f2c2fa539c756ebd613cd2c28c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 29 Feb 2024 08:51:13 +0100 Subject: [PATCH 29/39] [java] Verify UnnecessaryLocalBeforeReturn #4239 Fixes #4239 --- docs/pages/release_notes.md | 2 ++ .../xml/UnnecessaryLocalBeforeReturn.xml | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b98cb2f910..5848d4a8a3 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -279,6 +279,7 @@ The rules have been moved into categories with PMD 6. * [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number * java-codestyle * [#2847](https://github.com/pmd/pmd/issues/2847): \[java] New Rule: Use Explicit Types + * [#4239](https://github.com/pmd/pmd/issues/4239): \[java] UnnecessaryLocalBeforeReturn - false positive with catch clause * [#4578](https://github.com/pmd/pmd/issues/4578): \[java] CommentDefaultAccessModifier comment needs to be before annotation if present * [#4631](https://github.com/pmd/pmd/issues/4631): \[java] UnnecessaryFullyQualifiedName fails to recognize illegal self reference in enums * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest @@ -1427,6 +1428,7 @@ Language specific fixes: * [#3221](https://github.com/pmd/pmd/issues/3221): \[java] PrematureDeclaration false positive for unused variables * [#3238](https://github.com/pmd/pmd/issues/3238): \[java] Improve ExprContext, fix FNs of UnnecessaryCast * [#3500](https://github.com/pmd/pmd/pull/3500): \[java] UnnecessaryBoxing - check for Integer.valueOf(String) calls + * [#4239](https://github.com/pmd/pmd/issues/4239): \[java] UnnecessaryLocalBeforeReturn - false positive with catch clause * [#4268](https://github.com/pmd/pmd/issues/4268): \[java] CommentDefaultAccessModifier: false positive with TestNG annotations * [#4273](https://github.com/pmd/pmd/issues/4273): \[java] CommentDefaultAccessModifier ignoredAnnotations should include "org.junit.jupiter.api.extension.RegisterExtension" by default * [#4357](https://github.com/pmd/pmd/pull/4357): \[java] Fix IllegalStateException in UseDiamondOperator rule diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryLocalBeforeReturn.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryLocalBeforeReturn.xml index 33d74c14c6..5f227de94a 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryLocalBeforeReturn.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryLocalBeforeReturn.xml @@ -314,4 +314,29 @@ public class UnnecessaryLocal { } ]]> + + + [java] UnnecessaryLocalBeforeReturn - false positive with catch clause + 0 + {}); + if (result != null) { + throw new RuntimeException(result); + } + } + + private Exception attempt(Runnable task) { + try { + task.run(); + return null; + } catch (Exception e) { + // src/Example.java:15: UnnecessaryLocalBeforeReturn: Consider simply returning the value vs storing it in local variable 'e' + return e; + } + } +} +]]> + From 3b0dd7a82bdf9aba39e37ef5612cd61a5290d50f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 29 Feb 2024 08:58:22 +0100 Subject: [PATCH 30/39] Add @enexusde as a contributor --- .all-contributorsrc | 9 +++ docs/pages/pmd/projectdocs/credits.md | 99 ++++++++++++++------------- 2 files changed, 59 insertions(+), 49 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 40eff73d4c..b7f0ddc431 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7361,6 +7361,15 @@ "bug", "code" ] + }, + { + "login": "enexusde", + "name": "Peter Rader", + "avatar_url": "https://avatars.githubusercontent.com/u/6880636?v=4", + "profile": "http://www.e-nexus.de./", + "contributions": [ + "bug" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 1371698b85..b57caee7d6 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -601,445 +601,446 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Peter Kofler

🐛
Peter Paul Bakker

💻 +
Peter Rader

🐛
Pham Hai Trung

🐛
Philip Graf

💻 🐛
Philip Hachey

🐛
Philippe Ozil

🐛 -
Phinehas Artemix

🐛 +
Phinehas Artemix

🐛
Phokham Nonava

🐛
Pim van der Loos

💻 ⚠️
Piotr Szymański

🐛
Piotrek Żygieło

💻 🐛 📖
Pranay Jaiswal

🐛
Prasad Kamath

🐛 -
Prasanna

🐛 +
Prasanna

🐛
Presh-AR

🐛
Puneet1726

🐛
Rafael Cortês

🐛
RaheemShaik999

🐛
RajeshR

💻 🐛
Ramachandra Mohan

🐛 -
Ramel0921

🐛 +
Ramel0921

🐛
Raquel Pau

🐛
Ravikiran Janardhana

🐛
Reda Benhemmouche

🐛
Renato Oliveira

💻 🐛
Rich DiCroce

🐛
Richard Corfield

💻 -
Richard Corfield

🐛 💻 +
Richard Corfield

🐛 💻
Riot R1cket

🐛
Rishabh Jain

🐛
RishabhDeep Singh

🐛
Robbie Martinus

💻 🐛
Robert Henry

🐛
Robert Mihaly

🐛 -
Robert Painsi

🐛 +
Robert Painsi

🐛
Robert Russell

🐛
Robert Sösemann

💻 📖 📢 🐛
Robert Whitebit

🐛
Robin Richtsfeld

🐛
Robin Stocker

💻 🐛
Robin Wils

🐛 -
RochusOest

🐛 +
RochusOest

🐛
Rodolfo Noviski

🐛
Rodrigo Casara

🐛
Rodrigo Fernandes

🐛
Roman Salvador

💻 🐛
Ronald Blaschke

🐛
Róbert Papp

🐛 -
Saikat Sengupta

🐛 +
Saikat Sengupta

🐛
Saksham Handu

🐛
Saladoc

🐛
Salesforce Bob Lightning

🐛
Sam Carlberg

🐛
Satoshi Kubo

🐛
Scott Kennedy

🐛 -
Scott Wells

🐛 💻 +
Scott Wells

🐛 💻
Scrates1

🐛
Scrsloota

💻
Sebastian Bögl

🐛
Sebastian Schuberth

🐛
Sebastian Schwarz

🐛
Seren

🐛 💻 -
Sergey Gorbaty

🐛 +
Sergey Gorbaty

🐛
Sergey Kozlov

🐛
Sergey Yanzin

💻 🐛
Seth Wilcox

💻
Shai Bennathan

🐛 💻
Shubham

💻 🐛
Simon Abykov

💻 🐛 -
Simon Xiao

🐛 +
Simon Xiao

🐛
Srinivasan Venkatachalam

🐛
Stanislav Gromov

🐛
Stanislav Myachenkov

💻
Stefan Birkner

🐛
Stefan Bohn

🐛
Stefan Endrullis

🐛 -
Stefan Klöss-Schuster

🐛 +
Stefan Klöss-Schuster

🐛
Stefan Wolf

🐛
Stephan H. Wissel

🐛
Stephen

🐛
Stephen Friedrich

🐛
Steve Babula

💻
Steven Stearns

🐛 💻 -
Stexxe

🐛 +
Stexxe

🐛
Stian Lågstad

🐛
StuartClayton5

🐛
Supun Arunoda

🐛
Suren Abrahamyan

🐛
Suvashri

📖
SwatiBGupta1110

🐛 -
SyedThoufich

🐛 +
SyedThoufich

🐛
Szymon Sasin

🐛
T-chuangxin

🐛
TERAI Atsuhiro

🐛
TIOBE Software

💻 🐛
Tarush Singh

💻
Taylor Smock

🐛 -
Techeira Damián

💻 🐛 +
Techeira Damián

💻 🐛
Ted Husted

🐛
TehBakker

🐛
The Gitter Badger

🐛
Theodoor

🐛
Thiago Henrique Hüpner

🐛
Thibault Meyer

🐛 -
Thomas Güttler

🐛 +
Thomas Güttler

🐛
Thomas Jones-Low

🐛
Thomas Smith

💻 🐛
ThrawnCA

🐛
Thunderforge

💻 🐛
Tim van der Lippe

🐛
Tobias Weimer

💻 🐛 -
Tom Copeland

🐛 💻 📖 +
Tom Copeland

🐛 💻 📖
Tom Daly

🐛
Tomer Figenblat

🐛
Tomi De Lucca

💻 🐛
Torsten Kleiber

🐛
TrackerSB

🐛
Tyson Stewart

🐛 -
Ullrich Hafner

🐛 +
Ullrich Hafner

🐛
Utku Cuhadaroglu

💻 🐛
Valentin Brandl

🐛
Valeria

🐛
Valery Yatsynovich

📖
Vasily Anisimov

🐛
Vibhor Goyal

🐛 -
Vickenty Fesunov

🐛 +
Vickenty Fesunov

🐛
Victor Noël

🐛
Vincent Galloy

💻
Vincent HUYNH

🐛
Vincent Maurin

🐛
Vincent Privat

🐛
Vishhwas

🐛 -
Vitaly

🐛 +
Vitaly

🐛
Vitaly Polonetsky

🐛
Vojtech Polivka

🐛
Vsevolod Zholobov

🐛
Vyom Yadav

💻
Wang Shidong

🐛
Waqas Ahmed

🐛 -
Wayne J. Earl

🐛 +
Wayne J. Earl

🐛
Wchenghui

🐛
Wener

💻
Will Winder

🐛
William Brockhus

💻 🐛
Wilson Kurniawan

🐛
Wim Deblauwe

🐛 -
Woongsik Choi

🐛 +
Woongsik Choi

🐛
XenoAmess

💻 🐛
Yang

💻
YaroslavTER

🐛
Yasar Shaikh

💻
Young Chan

💻 🐛
YuJin Kim

🐛 -
Yuri Dolzhenko

🐛 +
Yuri Dolzhenko

🐛
Yurii Dubinka

🐛
Zoltan Farkas

🐛
Zustin

🐛
aaronhurst-google

🐛 💻
alexmodis

🐛
andreoss

🐛 -
andrey81inmd

💻 🐛 +
andrey81inmd

💻 🐛
anicoara

🐛
arunprasathav

🐛
asiercamara

🐛
astillich-igniti

💻
avesolovksyy

🐛
avishvat

🐛 -
avivmu

🐛 +
avivmu

🐛
axelbarfod1

🐛
b-3-n

🐛
balbhadra9

🐛
base23de

🐛
bergander

🐛 💻
berkam

💻 🐛 -
breizh31

🐛 +
breizh31

🐛
caesarkim

🐛
carolyujing

🐛
cbfiddle

🐛
cesares-basilico

🐛
chrite

🐛
ciufudean

📖 -
cobratbq

🐛 +
cobratbq

🐛
coladict

🐛
cosmoJFH

🐛
cristalp

🐛
crunsk

🐛
cwholmes

🐛
cyberjj999

🐛 -
cyw3

🐛 📖 +
cyw3

🐛 📖
d1ss0nanz

🐛
dague1

📖
dalizi007

💻
danbrycefairsailcom

🐛
dariansanity

🐛
darrenmiliband

🐛 -
davidburstrom

🐛 +
davidburstrom

🐛
dbirkman-paloalto

🐛
deepak-patra

🐛
dependabot[bot]

💻 🐛
dinesh150

🐛
diziaq

🐛
dreaminpast123

🐛 -
duanyanan

🐛 +
duanyanan

🐛
dutt-sanjay

🐛
dylanleung

🐛
dzeigler

🐛
eant60

🐛
ekkirala

🐛
emersonmoura

🐛 -
eugenepugach

🐛 +
eugenepugach

🐛
fairy

🐛
filiprafalowicz

💻
foxmason

🐛
frankegabor

🐛
frankl

🐛
freafrea

🐛 -
fsapatin

🐛 +
fsapatin

🐛
gracia19

🐛
guo fei

🐛
gurmsc5

🐛
gwilymatgearset

💻 🐛
haigsn

🐛
hemanshu070

🐛 -
henrik242

🐛 +
henrik242

🐛
hongpuwu

🐛
hvbtup

💻 🐛
igniti GmbH

🐛
ilovezfs

🐛
itaigilo

🐛
jakivey32

🐛 -
jbennett2091

🐛 +
jbennett2091

🐛
jcamerin

🐛
jkeener1

🐛
jmetertea

🐛
johnra2

💻
josemanuelrolon

💻 🐛
kabroxiko

💻 🐛 -
karwer

🐛 +
karwer

🐛
kaulonline

🐛
kdaemonv

🐛
kdebski85

🐛 💻
kenji21

💻 🐛
kfranic

🐛
khalidkh

🐛 -
koalalam

🐛 +
koalalam

🐛
krzyk

🐛
lasselindqvist

🐛
lgemeinhardt

🐛
lihuaib

🐛
lonelyma1021

🐛
lpeddy

🐛 -
lujiefsi

💻 +
lujiefsi

💻
lukelukes

💻
lyriccoder

🐛
marcelmore

🐛
matchbox

🐛
matthiaskraaz

🐛
meandonlyme

🐛 -
mikesive

🐛 +
mikesive

🐛
milossesic

🐛
mluckam

💻
mohan-chinnappan-n

💻
mriddell95

🐛
mrlzh

🐛
msloan

🐛 -
mucharlaravalika

🐛 +
mucharlaravalika

🐛
mvenneman

🐛
nareshl119

🐛
nicolas-harraudeau-sonarsource

🐛
noerremark

🐛
novsirion

🐛
nwcm

📖 🐛 -
oggboy

🐛 +
oggboy

🐛
oinume

🐛
orimarko

💻 🐛
pacvz

💻
pallavi agarwal

🐛
parksungrin

🐛
patpatpat123

🐛 -
patriksevallius

🐛 +
patriksevallius

🐛
pbrajesh1

🐛
phoenix384

🐛
piotrszymanski-sc

💻
plan3d

🐛
poojasix

🐛
prabhushrikant

🐛 -
pujitha8783

🐛 +
pujitha8783

🐛
r-r-a-j

🐛
raghujayjunk

🐛
rajeshveera

🐛
rajeswarreddy88

🐛
recdevs

🐛
reudismam

💻 🐛 -
rijkt

🐛 +
rijkt

🐛
rillig-tk

🐛
rmohan20

💻 🐛
rnveach

🐛
rxmicro

🐛
ryan-gustafson

💻 🐛
sabi0

🐛 -
scais

🐛 +
scais

🐛
sebbASF

🐛
sergeygorbaty

💻
shilko2013

🐛
shiomiyan

📖
simeonKondr

🐛
snajberk

🐛 -
sniperrifle2004

🐛 +
sniperrifle2004

🐛
snuyanzin

🐛 💻
soyodream

🐛
sratz

🐛
stonio

🐛
sturton

💻 🐛
sudharmohan

🐛 -
suruchidawar

🐛 +
suruchidawar

🐛
svenfinitiv

🐛
tashiscool

🐛
test-git-hook

🐛
testation21

💻 🐛
thanosa

🐛
tiandiyixian

🐛 -
tobwoerk

🐛 +
tobwoerk

🐛
tprouvot

🐛 💻
trentchilders

🐛
triandicAnt

🐛
trishul14

🐛
tsui

🐛
winhkey

🐛 -
witherspore

🐛 +
witherspore

🐛
wjljack

🐛
wuchiuwong

🐛
xingsong

🐛
xioayuge

🐛
xnYi9wRezm

💻 🐛
xuanuy

🐛 -
xyf0921

🐛 +
xyf0921

🐛
yalechen-cyw3

🐛
yasuharu-sato

🐛
zenglian

🐛
zgrzyt93

💻 🐛
zh3ng

🐛
zt_soft

🐛 -
ztt79

🐛 +
ztt79

🐛
zzzzfeng

🐛
Árpád Magosányi

🐛
任贵杰

🐛 From f0cbbddcfc19cdaf006a86606ce19b088e52e990 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 29 Feb 2024 10:06:27 +0100 Subject: [PATCH 31/39] [java] UnusedAssignment false positive in record compact constructor Fixes #4603 --- docs/pages/release_notes.md | 4 +- .../lang/java/rule/internal/DataflowPass.java | 18 +++++++++ .../bestpractices/xml/UnusedAssignment.xml | 39 +++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5848d4a8a3..cceb97f6e4 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -275,7 +275,8 @@ The rules have been moved into categories with PMD 6. * [#3751](https://github.com/pmd/pmd/issues/3751): \[java] Rename some node types * [#4628](https://github.com/pmd/pmd/pull/4628): \[java] Support loading classes from java runtime images * [#4753](https://github.com/pmd/pmd/issues/4753): \[java] PMD crashes while using generics and wildcards -* java-bestpractives +* java-bestpractices + * [#4603](https://github.com/pmd/pmd/issues/4603): \[java] UnusedAssignment false positive in record compact constructor * [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number * java-codestyle * [#2847](https://github.com/pmd/pmd/issues/2847): \[java] New Rule: Use Explicit Types @@ -1406,6 +1407,7 @@ Language specific fixes: * [#4516](https://github.com/pmd/pmd/issues/4516): \[java] UnusedLocalVariable: false-negative with try-with-resources * [#4517](https://github.com/pmd/pmd/issues/4517): \[java] UnusedLocalVariable: false-negative with compound assignments * [#4518](https://github.com/pmd/pmd/issues/4518): \[java] UnusedLocalVariable: false-positive with multiple for-loop indices + * [#4603](https://github.com/pmd/pmd/issues/4603): \[java] UnusedAssignment false positive in record compact constructor * [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number * [#4634](https://github.com/pmd/pmd/issues/4634): \[java] JUnit4TestShouldUseTestAnnotation false positive with TestNG * java-codestyle diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPass.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPass.java index a088cc4207..94f75d64d9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPass.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/DataflowPass.java @@ -54,6 +54,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTLocalVariableDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTLoopStatement; import net.sourceforge.pmd.lang.java.ast.ASTMethodCall; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; +import net.sourceforge.pmd.lang.java.ast.ASTRecordComponent; import net.sourceforge.pmd.lang.java.ast.ASTResourceList; import net.sourceforge.pmd.lang.java.ast.ASTReturnStatement; import net.sourceforge.pmd.lang.java.ast.ASTStatement; @@ -818,6 +819,23 @@ public final class DataflowPass { return data; } + @Override + public SpanInfo visit(ASTCompactConstructorDeclaration node, SpanInfo data) { + super.visit(node, data); + + // mark any write to a variable that is named like a record component as usage + // record compact constructors do an implicit assignment at the end. + for (ASTRecordComponent component : node.getEnclosingType().getRecordComponents()) { + node.descendants(ASTAssignmentExpression.class) + .descendants(ASTVariableAccess.class) + .filter(v -> v.getAccessType() == AccessType.WRITE) + .filter(v -> v.getName().equals(component.getVarId().getName())) + .forEach(varAccess -> data.use(varAccess.getReferencedSym(), null)); + } + + return data; + } + /** * Whether the variable has an implicit initializer, that is not * an expression. For instance, formal parameters have a value diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedAssignment.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedAssignment.xml index d9aad8af15..161433fd1a 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedAssignment.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedAssignment.xml @@ -3543,4 +3543,43 @@ public class UnusedAssignmentUnusedVariableFP { } ]]> + + + [java] UnusedAssignment false positive in record compact constructor #4603 + 0 + + + + + [java] Verify explicit canonical record constructor #4603 + 0 + + From ef18609309629e34ecc42f8eb3698d4a6b285f57 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 29 Feb 2024 13:33:04 +0100 Subject: [PATCH 32/39] [java] UnnecessaryImport - keep analyzing with failed overload selection Fixes #4816 --- docs/pages/release_notes.md | 2 ++ .../rule/codestyle/UnnecessaryImportRule.java | 3 ++- .../unnecessaryimport/item/Item.java | 11 ++++++++ .../unnecessaryimport/item/ItemProducer.java | 13 +++++++++ .../rule/codestyle/xml/UnnecessaryImport.xml | 27 +++++++++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/Item.java create mode 100644 pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/ItemProducer.java diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5848d4a8a3..c3f2b10779 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -284,6 +284,7 @@ The rules have been moved into categories with PMD 6. * [#4631](https://github.com/pmd/pmd/issues/4631): \[java] UnnecessaryFullyQualifiedName fails to recognize illegal self reference in enums * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest * [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property + * [#4816](https://github.com/pmd/pmd/issues/4816): \[java] UnnecessaryImport false-positive on generic method call with on lambda * java-design * [#174](https://github.com/pmd/pmd/issues/174): \[java] SingularField false positive with switch in method that both assigns and reads field * java-errorprone @@ -1442,6 +1443,7 @@ Language specific fixes: * [#4631](https://github.com/pmd/pmd/issues/4631): \[java] UnnecessaryFullyQualifiedName fails to recognize illegal self reference in enums * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest * [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property + * [#4816](https://github.com/pmd/pmd/issues/4816): \[java] UnnecessaryImport false-positive on generic method call with on lambda * java-design * [#174](https://github.com/pmd/pmd/issues/174): \[java] SingularField false positive with switch in method that both assigns and reads field * [#1014](https://github.com/pmd/pmd/issues/1014): \[java] LawOfDemeter: False positive with lambda expression diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java index cc04576bc5..e20a38c825 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java @@ -235,7 +235,8 @@ public class UnnecessaryImportRule extends AbstractJavaRule { if (node.getQualifier() == null) { OverloadSelectionResult overload = node.getOverloadSelectionInfo(); if (overload.isFailed()) { - return null; // todo we're erring towards FPs + // don't try further, but still visit all ASTClassType nodes in the AST. + return super.visit(node, data); // todo we're erring towards FPs } ShadowChainIterator scopeIter = diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/Item.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/Item.java new file mode 100644 index 0000000000..a01d5065db --- /dev/null +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/Item.java @@ -0,0 +1,11 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.item; + +public class Item { + public String getValue() { + return ""; + } +} diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/ItemProducer.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/ItemProducer.java new file mode 100644 index 0000000000..51a3a7ec8c --- /dev/null +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/item/ItemProducer.java @@ -0,0 +1,13 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.item; + +import java.util.stream.Stream; + +public class ItemProducer { + public Stream stream() { + return null; + } +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml index e22a37a6b3..42000d89e8 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml @@ -1168,4 +1168,31 @@ public class Sample { } ]]> + + + [java] UnnecessaryImport false-positive on generic method call with on lambda #4816 + 0 + X run(Function f) { return null; } + + public Set sample() { + return run((producer) -> producer + .stream() + .map(Item::getValue) + .collect(Collectors.toCollection(TreeSet::new))); + } +} +]]> + From a24bc9be1a73c5244cc0b704a6abb68a94a73a99 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Mar 2024 12:45:02 +0100 Subject: [PATCH 33/39] Add @liqingjun123 as a contributor --- .all-contributorsrc | 9 +++++++++ docs/pages/pmd/projectdocs/credits.md | 29 ++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index b7f0ddc431..99907c2d17 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7370,6 +7370,15 @@ "contributions": [ "bug" ] + }, + { + "login": "liqingjun123", + "name": "liqingjun123", + "avatar_url": "https://avatars.githubusercontent.com/u/12873992?v=4", + "profile": "https://github.com/liqingjun123", + "contributions": [ + "bug" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index b57caee7d6..5a9a8aea08 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -919,127 +919,128 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
lasselindqvist

🐛
lgemeinhardt

🐛
lihuaib

🐛 +
liqingjun123

🐛
lonelyma1021

🐛 -
lpeddy

🐛 +
lpeddy

🐛
lujiefsi

💻
lukelukes

💻
lyriccoder

🐛
marcelmore

🐛
matchbox

🐛
matthiaskraaz

🐛 -
meandonlyme

🐛 +
meandonlyme

🐛
mikesive

🐛
milossesic

🐛
mluckam

💻
mohan-chinnappan-n

💻
mriddell95

🐛
mrlzh

🐛 -
msloan

🐛 +
msloan

🐛
mucharlaravalika

🐛
mvenneman

🐛
nareshl119

🐛
nicolas-harraudeau-sonarsource

🐛
noerremark

🐛
novsirion

🐛 -
nwcm

📖 🐛 +
nwcm

📖 🐛
oggboy

🐛
oinume

🐛
orimarko

💻 🐛
pacvz

💻
pallavi agarwal

🐛
parksungrin

🐛 -
patpatpat123

🐛 +
patpatpat123

🐛
patriksevallius

🐛
pbrajesh1

🐛
phoenix384

🐛
piotrszymanski-sc

💻
plan3d

🐛
poojasix

🐛 -
prabhushrikant

🐛 +
prabhushrikant

🐛
pujitha8783

🐛
r-r-a-j

🐛
raghujayjunk

🐛
rajeshveera

🐛
rajeswarreddy88

🐛
recdevs

🐛 -
reudismam

💻 🐛 +
reudismam

💻 🐛
rijkt

🐛
rillig-tk

🐛
rmohan20

💻 🐛
rnveach

🐛
rxmicro

🐛
ryan-gustafson

💻 🐛 -
sabi0

🐛 +
sabi0

🐛
scais

🐛
sebbASF

🐛
sergeygorbaty

💻
shilko2013

🐛
shiomiyan

📖
simeonKondr

🐛 -
snajberk

🐛 +
snajberk

🐛
sniperrifle2004

🐛
snuyanzin

🐛 💻
soyodream

🐛
sratz

🐛
stonio

🐛
sturton

💻 🐛 -
sudharmohan

🐛 +
sudharmohan

🐛
suruchidawar

🐛
svenfinitiv

🐛
tashiscool

🐛
test-git-hook

🐛
testation21

💻 🐛
thanosa

🐛 -
tiandiyixian

🐛 +
tiandiyixian

🐛
tobwoerk

🐛
tprouvot

🐛 💻
trentchilders

🐛
triandicAnt

🐛
trishul14

🐛
tsui

🐛 -
winhkey

🐛 +
winhkey

🐛
witherspore

🐛
wjljack

🐛
wuchiuwong

🐛
xingsong

🐛
xioayuge

🐛
xnYi9wRezm

💻 🐛 -
xuanuy

🐛 +
xuanuy

🐛
xyf0921

🐛
yalechen-cyw3

🐛
yasuharu-sato

🐛
zenglian

🐛
zgrzyt93

💻 🐛
zh3ng

🐛 -
zt_soft

🐛 +
zt_soft

🐛
ztt79

🐛
zzzzfeng

🐛
Árpád Magosányi

🐛 From a96b6016af9ce4c66dfb5882d7a50fcb92028b70 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Mar 2024 12:47:15 +0100 Subject: [PATCH 34/39] [apex] Verify ApexDoc with annotated classes Fixes #4774 --- docs/pages/release_notes.md | 4 ++ .../pmd/lang/apex/ast/ApexCommentTest.java | 41 +++++++++++++++++-- .../apex/rule/documentation/xml/ApexDoc.xml | 17 ++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 9dd9ca8b80..66634a03e2 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -274,6 +274,8 @@ The rules have been moved into categories with PMD 6. * [#4796](https://github.com/pmd/pmd/pull/4796): Remove deprecated and release rulesets * apex * [#3766](https://github.com/pmd/pmd/issues/3766): \[apex] Replace Jorje with fully open source front-end +* apex-documentation + * [#4774](https://github.com/pmd/pmd/issues/4774): \[apex] ApexDoc false-positive for the first method of an annotated Apex class * apex-performance * [#4675](https://github.com/pmd/pmd/issues/4675): \[apex] New Rule: OperationWithHighCostInLoop * groovy @@ -1349,6 +1351,8 @@ Language specific fixes: * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule * [#4509](https://github.com/pmd/pmd/issues/4509): \[apex] ExcessivePublicCount doesn't consider inner classes correctly * [#4596](https://github.com/pmd/pmd/issues/4596): \[apex] ExcessivePublicCount ignores properties +* apex-documentation + * [#4774](https://github.com/pmd/pmd/issues/4774): \[apex] ApexDoc false-positive for the first method of an annotated Apex class * apex-performance * [#4675](https://github.com/pmd/pmd/issues/4675): \[apex] New Rule: OperationWithHighCostInLoop * apex-security diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java index f2df308ce9..728cce6253 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java @@ -10,6 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; class ApexCommentTest extends ApexParserTestBase { + private static final String FORMAL_COMMENT_CONTENT = "/** formal comment */"; @Test void testContainsComment1() { @@ -24,13 +25,45 @@ class ApexCommentTest extends ApexParserTestBase { @Test void fieldDeclarationHasFormalComment() { - final String commentContent = "/** formal comment */"; ASTApexFile file = apex.parse("class MyClass {\n" - + " " + commentContent + "\n" + + " " + FORMAL_COMMENT_CONTENT + "\n" + " Integer field;\n" + "}\n"); - ASTFormalComment comment = file.descendants(ASTFieldDeclaration.class).crossFindBoundaries() + ASTFormalComment comment = file.descendants(ASTUserClass.class) + .children(ASTFieldDeclarationStatements.class) + .children(ASTFieldDeclaration.class) .children(ASTFormalComment.class).first(); - assertEquals(commentContent, comment.getImage()); + assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); + } + + @Test + void methodHasFormalComment() { + ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n" + + "class MyClass {\n" + + " " + FORMAL_COMMENT_CONTENT + "\n" + + " public void bar() {}\n" + + "}"); + ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTMethod.class).children(ASTFormalComment.class).first(); + assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); + } + + @Test + void methodHasFormalCommentAnnotatedClass() { + ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n" + + "@RestResource(urlMapping='/api/v1/get/*')\n" + + "class MyClass {\n" + + " " + FORMAL_COMMENT_CONTENT + "\n" + + " public void bar() {}\n" + + "}"); + ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTMethod.class).children(ASTFormalComment.class).first(); + assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); + } + + @Test + void classHasFormalComment() { + ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n" + + "class MyClass {}"); + ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTFormalComment.class).first(); + assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); } } diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml index 69e879b3ed..800b8632e6 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml @@ -728,6 +728,23 @@ public class MyClass { Test = 1; } } +]]> + + + + [apex] ApexDoc false-positive for the first method of an annotated Apex class #4774 + 0 + From 150c0c88a466011a4fdc8ffb1228ca279c028814 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Mar 2024 14:37:17 +0100 Subject: [PATCH 35/39] [apex] Update doc about apex parser [skip ci] --- docs/pages/pmd/languages/apex.md | 10 ++++++---- docs/pages/release_notes.md | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/pages/pmd/languages/apex.md b/docs/pages/pmd/languages/apex.md index f6904aa7a8..1c5b19e64f 100644 --- a/docs/pages/pmd/languages/apex.md +++ b/docs/pages/pmd/languages/apex.md @@ -33,8 +33,10 @@ See [Apex language properties](pmd_languages_configuration.html#apex-language-pr ## Parser -We use Jorje, the Apex parsers that is shipped within the Apex Language Server. This is part of -the [Salesforce Extensions for VS Code](https://github.com/forcedotcom/salesforcedx-vscode). +Since PMD 7.0.0 we use the open source [apex-parser](https://github.com/apex-dev-tools/apex-parser), +together with [Summit AST](https://github.com/google/summit-ast) which translates the ANTLR parse tree +into an AST. -We take the binary from -and provide it as a maven dependency (see [pmd-apex-jorje](https://github.com/pmd/pmd/tree/master/pmd-apex-jorje)). +When PMD added Apex support with version 5.5.0, it utilized the Apex Jorje library to parse Apex source +and generate an AST. This library is however a binary-blob provided as part of the +[Salesforce Extensions for VS Code](https://github.com/forcedotcom/salesforcedx-vscode), and it is closed-source. diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 66634a03e2..83b0a63859 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -102,7 +102,8 @@ Also having access to the source code, enhancements and modifications are easier Under the hood, we use two open source libraries instead: -* [apex-parser](https://github.com/nawforce/apex-parser) by [Kevin Jones](https://github.com/nawforce) (@nawforce) +* [apex-parser](https://github.com/apex-dev-tools/apex-parser) originally by + [Kevin Jones](https://github.com/nawforce) (@nawforce). This project provides the grammar for a ANTLR based parser. * [Summit-AST](https://github.com/google/summit-ast) by [Google](https://github.com/google) (@google) This project translates the ANTLR parse tree into an AST, that is similar to the AST Jorje provided. From 5e277c8211b932c6fbe1755516eca0a548d430cc Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Mar 2024 14:50:35 +0100 Subject: [PATCH 36/39] [core] Fix NPE in AbstractAnalysisCache in case of processing errors --- .../cache/internal/AbstractAnalysisCache.java | 7 ++++- .../cache/internal/FileAnalysisCacheTest.java | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java index 7108a368b7..0d12db7d7c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java @@ -215,13 +215,18 @@ abstract class AbstractAnalysisCache implements AnalysisCache { final FileId fileName = file.getFileId(); return new FileAnalysisListener() { + private boolean failed = false; + @Override public void onRuleViolation(RuleViolation violation) { - updatedResultsCache.get(fileName).addViolation(violation); + if (!failed) { + updatedResultsCache.get(fileName).addViolation(violation); + } } @Override public void onError(ProcessingError error) { + failed = true; analysisFailed(file); } }; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java index 2f11170415..253abd19dd 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java @@ -48,6 +48,7 @@ import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.InternalApiBridge; +import net.sourceforge.pmd.reporting.Report; import net.sourceforge.pmd.reporting.RuleViolation; class FileAnalysisCacheTest { @@ -146,6 +147,35 @@ class FileAnalysisCacheTest { assertEquals(textLocation.getEndColumn(), cachedViolation.getEndColumn()); } + @Test + void testStorePersistsFilesWithViolationsAndProcessingErrors() throws IOException { + final FileAnalysisCache cache = new FileAnalysisCache(newCacheFile); + cache.checkValidity(mock(RuleSets.class), mock(ClassLoader.class), setOf(sourceFileBackend)); + final FileAnalysisListener cacheListener = cache.startFileAnalysis(sourceFile); + + cache.isUpToDate(sourceFile); + + cacheListener.onError(new Report.ProcessingError(new RuntimeException("some rule failed"), sourceFile.getFileId())); + + final RuleViolation rv = mock(RuleViolation.class); + final TextRange2d textLocation = TextRange2d.range2d(1, 2, 3, 4); + when(rv.getLocation()).thenReturn(FileLocation.range(sourceFile.getFileId(), textLocation)); + final Rule rule = mock(Rule.class, Mockito.RETURNS_SMART_NULLS); + when(rule.getLanguage()).thenReturn(mock(Language.class)); + when(rv.getRule()).thenReturn(rule); + + // the next rule wants to report a violation + cacheListener.onRuleViolation(rv); + cache.persist(); + + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); + reloadedCache.checkValidity(mock(RuleSets.class), mock(ClassLoader.class), setOf(sourceFileBackend)); + assertFalse(reloadedCache.isUpToDate(sourceFile), + "Cache believes file is up to date although processing errors happened earlier"); + + final List cachedViolations = reloadedCache.getCachedViolations(sourceFile); + assertTrue(cachedViolations.isEmpty(), "There should be no cached rule violations"); + } @Test void testDisplayNameIsRespected() throws Exception { From cc3da7b21e3b407c191ff81c67a9d66394ab4da8 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Mar 2024 16:16:49 +0100 Subject: [PATCH 37/39] Fix kotlin compiler warnings --- .../pmd/lang/apex/ast/ApexTreeBuilder.kt | 21 +++++++--------- .../lang/java/ast/ASTCastExpressionTest.kt | 1 - .../pmd/lang/java/ast/ASTFieldAccessTest.kt | 3 +-- .../pmd/lang/java/ast/ASTMethodCallTest.kt | 2 +- .../lang/java/ast/ASTMethodDeclarationTest.kt | 2 +- .../pmd/lang/java/ast/ASTPatternTest.kt | 1 - .../lang/java/ast/ASTSuperExpressionTest.kt | 2 +- .../lang/java/ast/ASTThisExpressionTest.kt | 2 +- .../pmd/lang/java/ast/ASTTypeTest.kt | 4 ++-- .../lang/java/ast/ASTUnaryExpressionTest.kt | 2 +- .../pmd/lang/java/ast/Java11Test.kt | 2 -- .../pmd/lang/java/ast/KotlinTestingDsl.kt | 15 +++++------- .../pmd/lang/java/ast/NodeParsingCtx.kt | 3 ++- .../pmd/lang/java/ast/ParenthesesTest.kt | 4 ++-- .../pmd/lang/java/ast/TestExtensions.kt | 24 +++++++++---------- .../lang/java/ast/TypeDisambiguationTest.kt | 16 ++++++------- .../pmd/lang/java/ast/UsageResolutionTest.kt | 8 +++---- .../lang/java/ast/VarDisambiguationTest.kt | 1 - .../java/symbols/internal/AstSymbolTests.kt | 4 ++-- .../symbols/internal/PrimitiveSymbolTests.kt | 2 +- .../internal/ReflectedClassSymbolTests.kt | 2 +- .../internal/ReflectedFieldSymbolTest.kt | 16 +++++++++---- .../pmd/lang/java/symbols/internal/Utils.kt | 3 +-- .../internal/asm/BrokenClasspathTest.kt | 2 +- .../symbols/internal/asm/SigParserTest.kt | 2 -- .../table/internal/HeaderScopesTest.kt | 14 +++++------ .../table/internal/LocalTypeScopesTest.kt | 2 +- .../table/internal/MemberInheritanceTest.kt | 10 ++++---- .../symbols/table/internal/VarScopingTest.kt | 10 ++++---- .../pmd/lang/java/types/ArraySymbolTests.kt | 2 +- .../pmd/lang/java/types/BoxingTest.kt | 1 - .../pmd/lang/java/types/CaptureTest.kt | 3 +-- .../pmd/lang/java/types/SubtypingTest.kt | 17 +++++++------ .../lang/java/types/TestUtilitiesForTypes.kt | 6 ++--- .../pmd/lang/java/types/TypeCreationDsl.kt | 6 ++--- .../pmd/lang/java/types/TypeEqualityTest.kt | 4 +--- .../pmd/lang/java/types/TypeGenerationUtil.kt | 13 +++++----- .../java/types/TypesFromReflectionTest.kt | 1 + .../java/types/ast/ConversionContextTests.kt | 4 ++-- .../internal/infer/BranchingExprsTestCases.kt | 1 - .../internal/infer/CaptureInferenceTest.kt | 1 - .../types/internal/infer/CtorInferenceTest.kt | 6 ++--- .../internal/infer/Java7InferenceTest.kt | 4 ++-- .../types/internal/infer/OverridingTest.kt | 1 - .../internal/infer/SpecialMethodsTest.kt | 5 ++-- .../internal/infer/StandaloneTypesTest.kt | 3 --- .../java/types/internal/infer/StressTest.kt | 2 +- .../infer/TypeAnnotationsInferenceTest.kt | 2 -- .../types/internal/infer/TypeInferenceTest.kt | 2 +- .../infer/UnresolvedTypesRecoveryTest.kt | 2 +- .../pmd/cpd/test/CpdTextComparisonTest.kt | 14 +++++------ .../pmd/lang/ast/test/NodeExtensions.kt | 2 -- .../pmd/lang/ast/test/NodePrinters.kt | 6 ++--- .../pmd/lang/ast/test/TestUtils.kt | 7 +++--- .../pmd/test/BaseTextComparisonTest.kt | 8 +++---- 55 files changed, 141 insertions(+), 162 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt index c48f2ad0cd..5c9728c01c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt @@ -76,10 +76,9 @@ import com.google.summit.ast.statement.WhileLoopStatement import kotlin.reflect.KClass -@Suppress("DEPRECATION") -class ApexTreeBuilder(val task: ParserTask, val proc: ApexLanguageProcessor) { - private val sourceCode = task.getTextDocument() - private val commentBuilder = ApexCommentBuilder(sourceCode, proc.getProperties().getSuppressMarker()) +class ApexTreeBuilder(private val task: ParserTask, private val proc: ApexLanguageProcessor) { + private val sourceCode = task.textDocument + private val commentBuilder = ApexCommentBuilder(sourceCode, proc.properties.suppressMarker) /** Builds and returns an [ASTApexFile] corresponding to the given [CompilationUnit]. */ fun buildTree(compilationUnit: CompilationUnit): ASTApexFile { @@ -87,7 +86,7 @@ class ApexTreeBuilder(val task: ParserTask, val proc: ApexLanguageProcessor) { val baseClass = build(compilationUnit, parent = null) as? BaseApexClass<*> ?: throw ParseException("Unable to build tree") - val result = ASTApexFile(task, compilationUnit, commentBuilder.getSuppressMap(), proc) + val result = ASTApexFile(task, compilationUnit, commentBuilder.suppressMap, proc) baseClass.setParent(result) // Post-processing passes @@ -759,8 +758,8 @@ class ApexTreeBuilder(val task: ParserTask, val proc: ApexLanguageProcessor) { } } - for(i in 0..node.getNumChildren()-1) { - node.setChild(children.get(i) as AbstractApexNode, i) + for(i in 0 until node.getNumChildren()) { + node.setChild(children[i] as AbstractApexNode, i) } } @@ -794,12 +793,10 @@ class ApexTreeBuilder(val task: ParserTask, val proc: ApexLanguageProcessor) { } /** - * If [parent] is not null, adds this [ApexNode] as a [child][ApexNode.jjtAddChild] and sets - * [parent] as the [parent][ApexNode.jjtSetParent]. + * If [parent] is not null, adds this [ApexNode] as a [child][AbstractApexNode.addChild] and sets + * [parent] as the [parent][AbstractApexNode.setParent]. */ private fun AbstractApexNode.setParent(parent: AbstractApexNode?) { - if (parent != null) { - parent.addChild(this, parent.numChildren) - } + parent?.addChild(this, parent.numChildren) } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCastExpressionTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCastExpressionTest.kt index ed3cb48cea..acb334402a 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCastExpressionTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTCastExpressionTest.kt @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.ast import net.sourceforge.pmd.lang.ast.test.shouldBe import net.sourceforge.pmd.lang.java.ast.JavaVersion.Companion.Earliest import net.sourceforge.pmd.lang.java.ast.JavaVersion.Companion.Latest -import net.sourceforge.pmd.lang.java.ast.ExpressionParsingCtx import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind.* class ASTCastExpressionTest : ParserTestSpec({ diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt index b259b9c1bc..8be8683fdd 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotest.matchers.shouldBe import net.sourceforge.pmd.lang.ast.test.shouldBe /** @@ -12,7 +11,7 @@ import net.sourceforge.pmd.lang.ast.test.shouldBe */ class ASTFieldAccessTest : ParserTestSpec({ - parserTest("Field access exprs") { + parserTest("Field access expressions") { inContext(ExpressionParsingCtx) { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodCallTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodCallTest.kt index e22d343589..5fe7339255 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodCallTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodCallTest.kt @@ -13,7 +13,7 @@ import net.sourceforge.pmd.lang.ast.test.shouldBe class ASTMethodCallTest : ParserTestSpec({ - parserTest("Method call exprs") { + parserTest("Method call expressions") { inContext(ExpressionParsingCtx) { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodDeclarationTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodDeclarationTest.kt index ff47a82431..0f621ebb93 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodDeclarationTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTMethodDeclarationTest.kt @@ -138,7 +138,7 @@ class ASTMethodDeclarationTest : ParserTestSpec({ } } - // default abstract is an invalid combination of modifiers so we won't encounter it in real analysis + // default abstract is an invalid combination of modifiers, so we won't encounter it in real analysis } parserTest("Throws list") { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTPatternTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTPatternTest.kt index 80549663cd..b9ba5114a4 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTPatternTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTPatternTest.kt @@ -5,7 +5,6 @@ package net.sourceforge.pmd.lang.java.ast import io.kotest.matchers.shouldBe -import io.kotest.matchers.shouldNot import net.sourceforge.pmd.lang.java.ast.JavaVersion.J16 import java.io.IOException diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTSuperExpressionTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTSuperExpressionTest.kt index bd2bd9096f..067756e2fe 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTSuperExpressionTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTSuperExpressionTest.kt @@ -31,7 +31,7 @@ class ASTSuperExpressionTest : ParserTestSpec({ // a method call, field access, or method reference "super" shouldNot parse() - // type arguments and annots are disallowed on the qualifier + // type arguments and annotations are disallowed on the qualifier "T.B.super::foo" shouldNot parse() "T.B.super.foo()" shouldNot parse() "T.@F B.super.foo()" shouldNot parse() diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTThisExpressionTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTThisExpressionTest.kt index dc49ff18d4..f3e0b7209a 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTThisExpressionTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTThisExpressionTest.kt @@ -47,7 +47,7 @@ class ASTThisExpressionTest : ParserTestSpec({ parserTest("Neg cases") { inContext(ExpressionParsingCtx) { - // type arguments and annots are disallowed on the qualifier + // type arguments and annotations are disallowed on the qualifier "T.B.this" shouldNot parse() "T.@F B.this" shouldNot parse() } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTTypeTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTTypeTest.kt index bee2963f29..2f85f2ceaf 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTTypeTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTTypeTest.kt @@ -59,9 +59,9 @@ class ASTTypeTest : ParserTestSpec({ // So @B binds to "java" // If the annotation is not applicable to TYPE_USE then it doesn't compile - // this happens in type context, eg in a cast, or in an extends list + // this happens in type context, e.g. in a cast, or in an extends list - // TYPE_USE annotations are prohibited eg before a declaration + // TYPE_USE annotations are prohibited e.g. before a declaration inContext(TypeParsingCtx) { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTUnaryExpressionTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTUnaryExpressionTest.kt index fd2bb913fc..d13cb2483c 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTUnaryExpressionTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTUnaryExpressionTest.kt @@ -84,7 +84,7 @@ class ASTUnaryExpressionTest : ParserTestSpec({ parserTest("Unary expression ambiguity corner cases") { - // the following cases test ambiguity between cast of unary, and eg parenthesized additive expr + // the following cases test ambiguity between cast of unary, and e.g. parenthesized additive expr // see https://docs.oracle.com/javase/specs/jls/se9/html/jls-15.html#jls-UnaryExpressionNotPlusMinus // comments about ambiguity are below grammar diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt index 8a0e225520..5626dba682 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt @@ -4,9 +4,7 @@ package net.sourceforge.pmd.lang.java.ast -import io.kotest.matchers.shouldBe import net.sourceforge.pmd.lang.ast.test.shouldBe -import net.sourceforge.pmd.lang.java.ast.* import net.sourceforge.pmd.lang.java.ast.JavaVersion.* import net.sourceforge.pmd.lang.java.ast.JavaVersion.Companion.Latest diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt index 791df7c2a3..aa4260bdc3 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt @@ -14,7 +14,6 @@ import io.kotest.matchers.MatcherResult import io.kotest.matchers.collections.shouldContainAll import net.sourceforge.pmd.lang.ast.* import net.sourceforge.pmd.lang.ast.test.* -import net.sourceforge.pmd.lang.java.JavaLanguageModule import net.sourceforge.pmd.lang.java.JavaParsingHelper import net.sourceforge.pmd.lang.java.JavaParsingHelper.* import java.beans.PropertyDescriptor @@ -40,8 +39,6 @@ enum class JavaVersion : Comparable { /** Name suitable for use with e.g. [JavaParsingHelper.parse] */ val pmdName: String = name.removePrefix("J").replaceFirst("__", "-").replace('_', '.').lowercase() - val pmdVersion get() = JavaLanguageModule.getInstance().getVersion(pmdName) - val parser: JavaParsingHelper = DEFAULT.withDefaultVersion(pmdName) operator fun not(): List = values().toList() - this @@ -64,9 +61,9 @@ enum class JavaVersion : Comparable { fun since(v: JavaVersion) = v.rangeTo(Latest) fun except(v1: JavaVersion, vararg versions: JavaVersion) = - values().toList() - v1 - versions + values().toList() - v1 - versions.toSet() - fun except(versions: List) = values().toList() - versions + fun except(versions: List) = values().toList() - versions.toSet() } } @@ -151,8 +148,8 @@ inline fun JavaNode?.shouldMatchNode(ignoreChildren: Boolean * Can be used inside of a [ParserTestSpec] with [ParserTestSpec.parserTest]. * * Parsing contexts allow to parse a string containing only the node you're interested - * in instead of writing up a full class that the parser can handle. See [parseExpression], - * [parseStatement]. + * in instead of writing up a full class that the parser can handle. See [ExpressionParsingCtx], + * [StatementParsingCtx]. * * These are implicitly used by [matchExpr] and [matchStmt], which specify a matcher directly * on the strings, using their type parameter and the info in this test context to parse, find @@ -169,7 +166,7 @@ inline fun JavaNode?.shouldMatchNode(ignoreChildren: Boolean * Import statements in the parsing contexts can be configured by adding types to [importedTypes], * or strings to [otherImports]. * - * Technically the utilities provided by this class may be used outside of [io.kotest.specs.FunSpec]s, + * Technically the utilities provided by this class may be used outside of [io.kotest.core.spec.Spec]s, * e.g. in regular JUnit tests, but I think we should strive to uniformize our testing style, * especially since KotlinTest defines so many. * @@ -224,7 +221,7 @@ open class ParserTestCtx(testScope: TestScope, /** * Places all node parsing contexts inside the declaration of the given class * of the given class. - * It's like you were writing eg expressions inside the class, with the method + * It's like you were writing e.g. expressions inside the class, with the method * declarations around it and all. * * LIMITATIONS: diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt index 2bf63f7669..cecc164d17 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt @@ -5,6 +5,7 @@ package net.sourceforge.pmd.lang.java.ast import net.sourceforge.pmd.lang.ast.Node +import net.sourceforge.pmd.lang.ast.ParseException import net.sourceforge.pmd.lang.java.JavaParsingHelper /** @@ -139,7 +140,7 @@ $construct } override fun retrieveNode(acu: ASTCompilationUnit): ASTBodyDeclaration = - acu.typeDeclarations.firstOrThrow().getDeclarations().firstOrThrow() + acu.typeDeclarations.firstOrThrow().declarations.firstOrThrow() } object TopLevelTypeDeclarationParsingCtx : NodeParsingCtx("top-level declaration") { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParenthesesTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParenthesesTest.kt index d5a59df21a..12efd016a2 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParenthesesTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ParenthesesTest.kt @@ -73,7 +73,7 @@ class ParenthesesTest : ParserTestSpec({ it::getParenthesisDepth shouldBe 2 it::isParenthesized shouldBe true - it.tokenList().map { it.image } shouldBe listOf("(", "(", "a", ")", ")") + it.tokenList().map { token -> token.image } shouldBe listOf("(", "(", "a", ")", ")") } } } @@ -95,7 +95,7 @@ class ParenthesesTest : ParserTestSpec({ it::getParenthesisDepth shouldBe 1 it::isParenthesized shouldBe true - it.tokenList().map { it.image } shouldBe listOf("(", "a", ")") + it.tokenList().map { token -> token.image } shouldBe listOf("(", "a", ")") } } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt index 1759e7c91b..de4ae950d9 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt @@ -256,8 +256,8 @@ fun TreeNodeWrapper.returnStatement(contents: ValuedNodeSpec.forLoop(body: ValuedNodeSpec = { null }) = child { - val body = body() - if (body != null) it::getBody shouldBe body + val expectedBody = body() + if (expectedBody != null) it::getBody shouldBe expectedBody else unspecifiedChildren(it.numChildren) } @@ -280,22 +280,22 @@ fun TreeNodeWrapper.statementExprList(body: NodeSpec.foreachLoop(body: ValuedNodeSpec = { null }) = child { - val body = body() - if (body != null) it::getBody shouldBe body + val expectedBody = body() + if (expectedBody != null) it::getBody shouldBe expectedBody else unspecifiedChildren(it.numChildren) } fun TreeNodeWrapper.doLoop(body: ValuedNodeSpec = { null }) = child { - val body = body() - if (body != null) it::getBody shouldBe body + val expectedBody = body() + if (expectedBody != null) it::getBody shouldBe expectedBody else unspecifiedChildren(it.numChildren) } fun TreeNodeWrapper.whileLoop(body: ValuedNodeSpec = { null }) = child { - val body = body() - if (body != null) it::getBody shouldBe body + val expectedBody = body() + if (expectedBody != null) it::getBody shouldBe expectedBody else unspecifiedChildren(it.numChildren) } @@ -398,7 +398,7 @@ fun TreeNodeWrapper.unionType(contents: NodeSpec = EmptyA contents() } -fun TreeNodeWrapper.voidType() = child() {} +fun TreeNodeWrapper.voidType() = child {} fun TreeNodeWrapper.typeExpr(contents: ValuedNodeSpec) = @@ -425,7 +425,7 @@ fun TreeNodeWrapper.arrayType(contents: NodeSpec = EmptyA fun TreeNodeWrapper.primitiveType(type: PrimitiveTypeKind, assertions: NodeSpec = EmptyAssertions) = child { it::getKind shouldBe type - PrettyPrintingUtil.prettyPrintType(it) shouldBe type.toString(); + PrettyPrintingUtil.prettyPrintType(it) shouldBe type.toString() assertions() } @@ -586,8 +586,8 @@ fun TreeNodeWrapper.switchStmt(assertions: NodeSpec fun TreeNodeWrapper.switchArrow(rhs: ValuedNodeSpec = { null }) = child { - val rhs = rhs() - if (rhs != null) it::getRightHandSide shouldBe rhs + val expectedRhs = rhs() + if (expectedRhs != null) it::getRightHandSide shouldBe expectedRhs else unspecifiedChildren(2) // label + rhs } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TypeDisambiguationTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TypeDisambiguationTest.kt index 7cf336cf72..3fcc73d62f 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TypeDisambiguationTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TypeDisambiguationTest.kt @@ -246,18 +246,18 @@ class TypeDisambiguationTest : ParserTestSpec({ val outerUnresolved = m0.qualifier!! val outerT = outerUnresolved.typeMirror.shouldBeA { - it.symbol.shouldBeA { - it::isUnresolved shouldBe true - it::getSimpleName shouldBe "OuterUnresolved" + it.symbol.shouldBeA { classSymbol -> + classSymbol::isUnresolved shouldBe true + classSymbol::getSimpleName shouldBe "OuterUnresolved" } } val innerT = m0.typeMirror.shouldBeA { it::getEnclosingType shouldBe outerT - it.symbol.shouldBeA { - it::isUnresolved shouldBe true - it::getSimpleName shouldBe "InnerUnresolved" - it.enclosingClass.shouldBeSameInstanceAs(outerT.symbol) + it.symbol.shouldBeA { classSymbol -> + classSymbol::isUnresolved shouldBe true + classSymbol::getSimpleName shouldBe "InnerUnresolved" + classSymbol.enclosingClass.shouldBeSameInstanceAs(outerT.symbol) } } @@ -314,7 +314,7 @@ class TypeDisambiguationTest : ParserTestSpec({ // before all classes of the CU have been visited enableProcessing() - val acu = parser.parse(""" + @Suppress("UNUSED_VARIABLE") val acu = parser.parse(""" package p; import static p.Assert2.*; diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/UsageResolutionTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/UsageResolutionTest.kt index bf332c059f..b6f3e05e0e 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/UsageResolutionTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/UsageResolutionTest.kt @@ -65,13 +65,13 @@ class UsageResolutionTest : ProcessorTestSpec({ p::isRecordComponent shouldBe true p.localUsages.shouldHaveSize(2) p.localUsages[0].shouldBeA { - it.referencedSym!!.shouldBeA { - it.tryGetNode() shouldBe p + it.referencedSym!!.shouldBeA { symbol -> + symbol.tryGetNode() shouldBe p } } p.localUsages[1].shouldBeA { - it.referencedSym!!.shouldBeA { - it.tryGetNode() shouldBe p + it.referencedSym!!.shouldBeA { symbol -> + symbol.tryGetNode() shouldBe p } } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/VarDisambiguationTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/VarDisambiguationTest.kt index d890ddd97d..a96b9b9077 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/VarDisambiguationTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/VarDisambiguationTest.kt @@ -11,7 +11,6 @@ import net.sourceforge.pmd.lang.ast.test.shouldMatchN import net.sourceforge.pmd.lang.java.JavaParsingHelper import net.sourceforge.pmd.lang.java.symbols.JClassSymbol import net.sourceforge.pmd.lang.java.symbols.JTypeParameterSymbol -import net.sourceforge.pmd.lang.java.symbols.table.internal.JavaSemanticErrors import net.sourceforge.pmd.lang.java.symbols.table.internal.JavaSemanticErrors.* class VarDisambiguationTest : ParserTestSpec({ diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/AstSymbolTests.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/AstSymbolTests.kt index cb8c48b9c8..7933491035 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/AstSymbolTests.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/AstSymbolTests.kt @@ -386,7 +386,7 @@ class AstSymbolTests : ParserTestSpec({ val (canonCtor1, canonCtor2) = acu.descendants(ASTRecordComponentList::class.java).toList { it.symbol } val (auxCtor) = acu.descendants(ASTConstructorDeclaration::class.java).toList { it.symbol } val (xAccessor) = acu.descendants(ASTMethodDeclaration::class.java).toList { it.symbol } - val (xComp, yComp, x2Comp, y2Comp, x2Formal) = acu.descendants(ASTVariableId::class.java).toList { it.symbol } + val (xComp, yComp, _, y2Comp, _) = acu.descendants(ASTVariableId::class.java).toList { it.symbol } doTest("should reflect their modifiers") { @@ -550,7 +550,7 @@ class AstSymbolTests : ParserTestSpec({ } // all others are Runnable - (allAnons - anonsWithSuperClass).forEach { + (allAnons - anonsWithSuperClass.toSet()).forEach { it::getSuperclass shouldBe it.typeSystem.OBJECT.symbol it::getSuperInterfaces shouldBe listOf(it.typeSystem.getClassSymbol(Runnable::class.java)) } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/PrimitiveSymbolTests.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/PrimitiveSymbolTests.kt index fae15094cd..676f0ffb01 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/PrimitiveSymbolTests.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/PrimitiveSymbolTests.kt @@ -17,7 +17,7 @@ import net.sourceforge.pmd.lang.java.types.testTypeSystem */ class PrimitiveSymbolTests : WordSpec({ - fun primitives(): List = testTypeSystem.allPrimitives.map { it.symbol!! } + fun primitives(): List = testTypeSystem.allPrimitives.map { it.symbol } "A primitive symbol" should { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedClassSymbolTests.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedClassSymbolTests.kt index 5051b1396e..51ab28b726 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedClassSymbolTests.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedClassSymbolTests.kt @@ -40,7 +40,7 @@ class ReflectedClassSymbolTests : IntelliMarker, WordSpec({ "reflect its superinterfaces correctly" { TestClassesGen.forAllEqual { - classSym(it)!!.superInterfaces to it.interfaces.toList().map { classSym(it) } + classSym(it)!!.superInterfaces to it.interfaces.toList().map { clazz -> classSym(clazz) } } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedFieldSymbolTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedFieldSymbolTest.kt index bf09835375..4e5e07f00f 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedFieldSymbolTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/ReflectedFieldSymbolTest.kt @@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.java.symbols.internal import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.WordSpec +import io.kotest.matchers.ints.shouldBeExactly import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.kotest.property.arbitrary.filterNot @@ -39,8 +40,8 @@ class ReflectedFieldSymbolTest : IntelliMarker, WordSpec({ "reflect its modifiers properly" { TestClassesGen.filterNot { it.isArray }.forAllEqual { Pair( - classSym(it)!!.declaredFields.map { it.simpleName to it.modifiers }, - it.declaredFields.map { it.name to it.modifiers } + classSym(it)!!.declaredFields.map { fieldSymbol -> fieldSymbol.simpleName to fieldSymbol.modifiers }, + it.declaredFields.map { field -> field.name to field.modifiers } ) } } @@ -56,9 +57,14 @@ class ReflectedFieldSymbolTest : IntelliMarker, WordSpec({ } "be unmodifiable" { - shouldThrow { - classSym(SomeFields::class.java)!!.getDeclaredField("foo")!!.declaredAnnotations.add(null) - } + val declaredAnnotations = classSym(SomeFields::class.java)!!.getDeclaredField("foo")!!.declaredAnnotations + declaredAnnotations.size shouldBeExactly 1 + val annot = declaredAnnotations.first() + declaredAnnotations.plus(annot) + declaredAnnotations.size shouldBeExactly 1 + + // still unmodified + classSym(SomeFields::class.java)!!.getDeclaredField("foo")!!.declaredAnnotations.size shouldBeExactly 1 } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/Utils.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/Utils.kt index d83b1cafbc..549db7c9e8 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/Utils.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/Utils.kt @@ -8,7 +8,6 @@ import io.kotest.assertions.withClue import io.kotest.matchers.collections.haveSize import io.kotest.matchers.should import io.kotest.property.* -import io.kotest.property.arbitrary.arbitrary import net.sourceforge.pmd.lang.java.symbols.JClassSymbol import net.sourceforge.pmd.lang.java.symbols.SymbolResolver import net.sourceforge.pmd.lang.java.types.testTypeSystem @@ -80,7 +79,7 @@ object TestClassesGen : Arb>() { return } val files = directory.listFiles() - for (file in files) { + for (file in files!!) { if (file.isDirectory) { assert(!file.name.contains(".")) findClasses(file, packageName + "." + file.name) diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/BrokenClasspathTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/BrokenClasspathTest.kt index 85f988420c..adce5714d8 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/BrokenClasspathTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/BrokenClasspathTest.kt @@ -59,7 +59,7 @@ class BrokenClasspathTest : FunSpec({ // since we're loading things lazily this type hasn't tried to populate its superinterfaces val superItfType = ts.declaration(unresolvedItfSym) as JClassType val subclassType = ts.declaration(subclassSym) as JClassType - val (tvarC, tvarD) = subclassType.formalTypeParams + val (_, tvarD) = subclassType.formalTypeParams // and now since the super interface *type* is parameterized, we'll try to create SuperItf // Except SuperItf is unresolved. diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/SigParserTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/SigParserTest.kt index 4d16fdc868..70732ce819 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/SigParserTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/internal/asm/SigParserTest.kt @@ -7,9 +7,7 @@ package net.sourceforge.pmd.lang.java.symbols.internal.asm import io.kotest.assertions.throwables.shouldThrow import io.kotest.assertions.withClue import io.kotest.core.spec.style.FunSpec -import io.kotest.matchers.Matcher import io.kotest.matchers.collections.shouldHaveSize -import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain import javasymbols.testdata.impls.SomeInnerClasses diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/HeaderScopesTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/HeaderScopesTest.kt index e580ec1ceb..2275d89510 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/HeaderScopesTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/HeaderScopesTest.kt @@ -7,8 +7,6 @@ package net.sourceforge.pmd.lang.java.symbols.table.internal import io.kotest.matchers.collections.* -import io.kotest.matchers.maps.shouldBeEmpty -import io.kotest.matchers.maps.shouldContain import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.should import io.kotest.matchers.shouldBe @@ -252,8 +250,8 @@ class HeaderScopesTest : ProcessorTestSpec({ it.apply { scopeTag shouldBe SINGLE_IMPORT results should haveSize(2) - results.forEach { - it.symbol.enclosingClass.canonicalName shouldBe "javasymbols.testdata.StaticNameCollision" + results.forEach { methodSig -> + methodSig.symbol.enclosingClass.canonicalName shouldBe "javasymbols.testdata.StaticNameCollision" } } @@ -261,8 +259,8 @@ class HeaderScopesTest : ProcessorTestSpec({ it.apply { scopeTag shouldBe IMPORT_ON_DEMAND results should haveSize(2) - results.forEach { - it.symbol.enclosingClass.canonicalName shouldBe "javasymbols.testdata.Statics" + results.forEach { methodSig -> + methodSig.symbol.enclosingClass.canonicalName shouldBe "javasymbols.testdata.Statics" } } } @@ -276,8 +274,8 @@ class HeaderScopesTest : ProcessorTestSpec({ it.apply { scopeTag shouldBe IMPORT_ON_DEMAND results should haveSize(1) - results.forEach { - it.symbol.enclosingClass.canonicalName shouldBe "javasymbols.testdata.Statics" + results.forEach { methodSig -> + methodSig.symbol.enclosingClass.canonicalName shouldBe "javasymbols.testdata.Statics" } } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/LocalTypeScopesTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/LocalTypeScopesTest.kt index eb874dca5e..e069eacc04 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/LocalTypeScopesTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/LocalTypeScopesTest.kt @@ -112,7 +112,7 @@ class LocalTypeScopesTest : ParserTestSpec({ } """) - val (foo, inner, other) = + val (foo, inner, _) = acu.descendants(ASTClassDeclaration::class.java).toList() val (insideFoo, insideInner, insideOther) = diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/MemberInheritanceTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/MemberInheritanceTest.kt index 47f9947c13..425d703d0b 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/MemberInheritanceTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/MemberInheritanceTest.kt @@ -261,26 +261,26 @@ class MemberInheritanceTest : ParserTestSpec({ } """) - val (t_Scratch, t_Inner) = + val (typeScratch, typeInner) = acu.descendants(ASTClassDeclaration::class.java).toList { it.typeMirror } val insideFoo = acu.descendants(ASTClassBody::class.java) .crossFindBoundaries().get(2)!! - val `t_Scratch{String}Inner` = with (acu.typeDsl) { - t_Scratch[gen.t_String].selectInner(t_Inner.symbol, emptyList()) + val `typeScratch{String}Inner` = with (acu.typeDsl) { + typeScratch[gen.t_String].selectInner(typeInner.symbol, emptyList()) } insideFoo.symbolTable.types().resolve("Inner").shouldBeSingleton { - it.shouldBe(`t_Scratch{String}Inner`) + it.shouldBe(`typeScratch{String}Inner`) } val typeNode = acu.descendants(ASTClassType::class.java).first { it.simpleName == "Inner" }!! typeNode.shouldMatchN { classType("Inner") { - it shouldHaveType `t_Scratch{String}Inner` + it shouldHaveType `typeScratch{String}Inner` } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/VarScopingTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/VarScopingTest.kt index 2435e576d5..6018dc47d8 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/VarScopingTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/symbols/table/internal/VarScopingTest.kt @@ -426,7 +426,7 @@ class VarScopingTest : ProcessorTestSpec({ """.trimIndent()) - val (_, t_SomeEnum) = acu.descendants(ASTTypeDeclaration::class.java).toList { it.typeMirror } + val (_, typeSomeEnum) = acu.descendants(ASTTypeDeclaration::class.java).toList { it.typeMirror } val (enumA, enumB) = acu.descendants(ASTEnumDeclaration::class.java) @@ -443,17 +443,17 @@ class VarScopingTest : ProcessorTestSpec({ qualifiedA.referencedSym shouldBe enumA.symbol qualifiedA.referencedSym!!.tryGetNode() shouldBe enumA - qualifiedA shouldHaveType t_SomeEnum + qualifiedA shouldHaveType typeSomeEnum caseA.referencedSym shouldBe enumA.symbol caseA.referencedSym!!.tryGetNode() shouldBe enumA - caseA shouldHaveType t_SomeEnum + caseA shouldHaveType typeSomeEnum caseB.referencedSym shouldBe enumB.symbol caseB.referencedSym!!.tryGetNode() shouldBe enumB - caseB shouldHaveType t_SomeEnum + caseB shouldHaveType typeSomeEnum - e shouldHaveType t_SomeEnum + e shouldHaveType typeSomeEnum // symbol tables don't carry that info, this is documented on JSymbolTable#variables() caseB.symbolTable.variables().resolve("A").shouldBeEmpty() diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ArraySymbolTests.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ArraySymbolTests.kt index 34d72f2690..c3fbed8538 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ArraySymbolTests.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ArraySymbolTests.kt @@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.java.symbols.internal.getDeclaredMethods */ class ArraySymbolTests : WordSpec({ - val INT_SYM = testTypeSystem.getClassSymbol(java.lang.Integer.TYPE) + val INT_SYM = testTypeSystem.getClassSymbol(Integer.TYPE) val STRING_SYM = testTypeSystem.getClassSymbol(java.lang.String::class.java) fun makeArraySym(comp: JTypeDeclSymbol?) = ArraySymbolImpl(testTypeSystem, comp) diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/BoxingTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/BoxingTest.kt index f061b0050a..2d0739dda1 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/BoxingTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/BoxingTest.kt @@ -10,7 +10,6 @@ import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldNotBe import io.kotest.matchers.types.shouldBeInstanceOf import io.kotest.matchers.types.shouldBeSameInstanceAs -import io.kotest.property.forAll import net.sourceforge.pmd.lang.java.symbols.internal.forAllEqual /** diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/CaptureTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/CaptureTest.kt index 951f12c671..03125a0a58 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/CaptureTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/CaptureTest.kt @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.types import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe -import net.sourceforge.pmd.lang.java.symbols.JClassSymbol import net.sourceforge.pmd.lang.java.symbols.internal.asm.createUnresolvedAsmSymbol import net.sourceforge.pmd.lang.java.types.TypeConversion.* @@ -58,7 +57,7 @@ class CaptureTest : FunSpec({ } test("Capture of malformed types") { - val sym = ts.createUnresolvedAsmSymbol("does.not.Exist") as JClassSymbol + val sym = ts.createUnresolvedAsmSymbol("does.not.Exist") val matcher = captureMatcher(`?` extends t_String).also { capture(sym[t_String, `?` extends t_String]) shouldBe sym[t_String, it] diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/SubtypingTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/SubtypingTest.kt index 1fdb1affa0..e370ca9112 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/SubtypingTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/SubtypingTest.kt @@ -15,7 +15,6 @@ import io.kotest.property.exhaustive.ints import io.kotest.property.forAll import net.sourceforge.pmd.lang.ast.test.shouldBeA import net.sourceforge.pmd.lang.java.ast.ParserTestCtx -import net.sourceforge.pmd.lang.java.symbols.JClassSymbol import net.sourceforge.pmd.lang.java.symbols.internal.UnresolvedClassStore import net.sourceforge.pmd.lang.java.symbols.internal.asm.createUnresolvedAsmSymbol import net.sourceforge.pmd.lang.java.types.TypeConversion.* @@ -157,10 +156,10 @@ class SubtypingTest : FunSpec({ test("Test raw type is convertible to wildcard parameterized type without unchecked conversion") { val `Class{String}` = Class::class[ts.STRING] - val `Class{?}` = Class::class[`?`] + val `Class{Wildcard}` = Class::class[`?`] val Class = Class::class.raw - val `Comparable{?}` = java.lang.Comparable::class[`?`] + val `Comparable{Wildcard}` = java.lang.Comparable::class[`?`] /* Class raw = String.class; @@ -179,15 +178,15 @@ class SubtypingTest : FunSpec({ `Class{String}` shouldBeSubtypeOf Class - `Class{?}` shouldBeSubtypeOf Class + `Class{Wildcard}` shouldBeSubtypeOf Class - `Class{String}` shouldBeSubtypeOf `Class{?}` - `Class{?}` shouldNotBeSubtypeOf `Class{String}` + `Class{String}` shouldBeSubtypeOf `Class{Wildcard}` + `Class{Wildcard}` shouldNotBeSubtypeOf `Class{String}` - assertSubtype(Class, `Class{?}`) { this == UNCHECKED_NO_WARNING } + assertSubtype(Class, `Class{Wildcard}`) { this == UNCHECKED_NO_WARNING } Class shouldBeUncheckedSubtypeOf `Class{String}` - ts.STRING shouldBeSubtypeOf `Comparable{?}` + ts.STRING shouldBeSubtypeOf `Comparable{Wildcard}` } test("Test wildcard subtyping") { @@ -319,7 +318,7 @@ class SubtypingTest : FunSpec({ } test("Test non well-formed types") { - val sym = ts.createUnresolvedAsmSymbol("does.not.Exist") as JClassSymbol + val sym = ts.createUnresolvedAsmSymbol("does.not.Exist") sym[t_String, t_String] shouldBeUnrelatedTo sym[t_String] sym[t_String] shouldBeSubtypeOf sym[t_String] sym[t_String] shouldBeSubtypeOf sym[`?` extends t_String] // containment diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TestUtilitiesForTypes.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TestUtilitiesForTypes.kt index 90482a9828..ae87d1890e 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TestUtilitiesForTypes.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TestUtilitiesForTypes.kt @@ -8,7 +8,6 @@ package net.sourceforge.pmd.lang.java.types import io.kotest.assertions.* -import io.kotest.assertions.print.Printed import io.kotest.assertions.print.print import io.kotest.matchers.shouldBe import net.sourceforge.pmd.lang.ast.test.shouldBe @@ -18,8 +17,8 @@ import net.sourceforge.pmd.lang.java.ast.* import net.sourceforge.pmd.lang.java.symbols.internal.asm.AsmSymbolResolver import net.sourceforge.pmd.lang.java.types.TypeOps.* import org.hamcrest.Description +import java.util.stream.Collectors import kotlin.String -import kotlin.streams.toList import kotlin.test.assertTrue /* @@ -45,7 +44,7 @@ val TypeSystem.STRING get() = declaration(getClassSymbol(String::class.java)) as typealias TypePair = Pair -fun JTypeMirror.getMethodsByName(name: String) = streamMethods { it.simpleName == name }.toList() +fun JTypeMirror.getMethodsByName(name: String): List = streamMethods { it.simpleName == name }.collect(Collectors.toList()) fun JTypeMirror.shouldBeUnresolvedClass(canonicalName: String) = this.shouldBeA { @@ -225,6 +224,7 @@ val JTypeMirror.isExlusiveIntersectionBound /** * Was added in java 12. */ +@Suppress("UNCHECKED_CAST") val Class.arrayType: Class> get() { val arr = java.lang.reflect.Array.newInstance(this, 0) diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeCreationDsl.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeCreationDsl.kt index f274fd9122..e0afd0284a 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeCreationDsl.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeCreationDsl.kt @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.types import net.sourceforge.pmd.lang.java.ast.JavaNode -import net.sourceforge.pmd.lang.java.ast.ParserTestSpec import net.sourceforge.pmd.lang.java.symbols.JClassSymbol import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot import net.sourceforge.pmd.lang.java.symbols.internal.FakeSymAnnot @@ -26,7 +25,7 @@ val JavaNode.typeDsl get() = TypeDslOf(this.typeSystem) * int[][]: int.toArray(2) * List: List::class[`?` extends Number::class] * - * Use [typeDsl] (eg `with(node.typeDsl) { ... }`, + * Use [typeDsl] (eg `with(node.typeDsl) { ... }`), * or [TypeDslOf] (eg `with(TypeDslOf(ts)) { ... }`) * * to bring it into scope. @@ -125,13 +124,14 @@ interface TypeDslMixin { * List::class[`?` super String::class] * */ + @Suppress("DANGEROUS_CHARACTERS") val `?`: WildcardDsl get() = WildcardDsl(ts) } /** See [TypeDslMixin.@A]. */ -val ParserTestSpec.GroupTestCtx.VersionedTestCtx.ImplicitNodeParsingCtx<*>.AnnotA +val AnnotA get() = "@" + ClassWithTypeAnnotationsInside.A::class.java.canonicalName class TypeDslOf(override val ts: TypeSystem) : TypeDslMixin diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeEqualityTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeEqualityTest.kt index 99e363d56e..439fb9a03e 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeEqualityTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeEqualityTest.kt @@ -10,9 +10,7 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.kotest.property.checkAll import io.kotest.property.forAll -import net.sourceforge.pmd.lang.java.symbols.JClassSymbol import net.sourceforge.pmd.lang.java.symbols.internal.asm.createUnresolvedAsmSymbol -import net.sourceforge.pmd.lang.java.symbols.internal.forAllEqual /** * @author Clément Fournier @@ -83,7 +81,7 @@ class TypeEqualityTest : FunSpec({ test("Test non well-formed types") { - val sym = ts.createUnresolvedAsmSymbol("does.not.Exist") as JClassSymbol + val sym = ts.createUnresolvedAsmSymbol("does.not.Exist") // not equal sym[t_String, t_String] shouldNotBe sym[t_String] sym[t_String] shouldNotBe sym[t_String, t_String] diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeGenerationUtil.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeGenerationUtil.kt index 455c7ba3fd..69260414da 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeGenerationUtil.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypeGenerationUtil.kt @@ -10,7 +10,9 @@ import io.kotest.property.Arb import io.kotest.property.Exhaustive import io.kotest.property.RandomSource import io.kotest.property.Sample -import io.kotest.property.arbitrary.* +import io.kotest.property.arbitrary.arbitrary +import io.kotest.property.arbitrary.filter +import io.kotest.property.arbitrary.pair import io.kotest.property.exhaustive.exhaustive import net.sourceforge.pmd.lang.java.JavaParsingHelper import net.sourceforge.pmd.lang.java.ast.ASTTypeParameter @@ -18,8 +20,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTTypeParameters import net.sourceforge.pmd.lang.java.ast.ParserTestCtx import net.sourceforge.pmd.lang.java.symbols.internal.TestClassesGen import net.sourceforge.pmd.lang.java.symbols.internal.asm.createUnresolvedAsmSymbol -import javax.lang.model.type.TypeMirror -import kotlin.streams.toList +import java.util.stream.Collectors val TypeSystem.primitiveGen: Exhaustive get() = exhaustive(this.allPrimitives.toList()) @@ -48,7 +49,7 @@ class RefTypeGenArb(val ts: TypeSystem) : Arb() { // we exclude the null type because it's not ok as an array component ts.SERIALIZABLE, ts.CLONEABLE - ); + ) override fun edgecase(rs: RandomSource): JTypeMirror { return allEdgecases.random(rs.random) @@ -105,7 +106,7 @@ class RefTypeGenArb(val ts: TypeSystem) : Arb() { -@Suppress("ObjectPropertyName", "MemberVisibilityCanBePrivate") +@Suppress("MemberVisibilityCanBePrivate", "DANGEROUS_CHARACTERS") class RefTypeConstants(override val ts: TypeSystem) : TypeDslMixin { val t_String: JClassType get() = java.lang.String::class.decl @@ -192,7 +193,7 @@ fun JavaParsingHelper.makeDummyTVars(vararg names: String): List { .toStream() .map { it.typeMirror - }.toList() + }.collect(Collectors.toList()) } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypesFromReflectionTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypesFromReflectionTest.kt index 0e8c5a6cc3..9785fc2669 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypesFromReflectionTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/TypesFromReflectionTest.kt @@ -90,6 +90,7 @@ class TypesFromReflectionTest : FunSpec({ } + @Suppress("unused") private class GenericKlass /** diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ast/ConversionContextTests.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ast/ConversionContextTests.kt index b17eeae84e..c7ddf6d271 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ast/ConversionContextTests.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/ast/ConversionContextTests.kt @@ -49,7 +49,7 @@ class ConversionContextTests : ProcessorTestSpec({ } """) - val (ternary, _, num1, shortCast, num5) = acu.descendants(ASTExpression::class.java).toList() + val (ternary, _, num1, shortCast, _) = acu.descendants(ASTExpression::class.java).toList() spy.shouldBeOk { // ternary is in double assignment context @@ -80,7 +80,7 @@ class ConversionContextTests : ProcessorTestSpec({ } """) - val (ternary, _, integerCast, nullLit, num4) = acu.descendants(ASTExpression::class.java).toList() + val (ternary, _, integerCast, _, num4) = acu.descendants(ASTExpression::class.java).toList() spy.shouldBeOk { // ternary is in double assignment context diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/BranchingExprsTestCases.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/BranchingExprsTestCases.kt index 3810efe856..54d7834c04 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/BranchingExprsTestCases.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/BranchingExprsTestCases.kt @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.java.types.internal.infer -import io.kotest.matchers.shouldBe import net.sourceforge.pmd.lang.ast.test.shouldBe import net.sourceforge.pmd.lang.ast.test.shouldMatchN import net.sourceforge.pmd.lang.java.ast.* diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CaptureInferenceTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CaptureInferenceTest.kt index b4f84781af..f9b36667de 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CaptureInferenceTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CaptureInferenceTest.kt @@ -476,7 +476,6 @@ public class SubClass { """.trimIndent() ) - val cvar = acu.typeVar("C") val tvar = acu.typeVar("T") spy.shouldBeOk { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CtorInferenceTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CtorInferenceTest.kt index ce73c75bfb..8719732856 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CtorInferenceTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/CtorInferenceTest.kt @@ -215,7 +215,7 @@ class CtorInferenceTest : ProcessorTestSpec({ """) - val (t_Outer, t_Inner, t_Scratch) = acu.declaredTypeSignatures() + val (t_Outer, t_Inner, _) = acu.declaredTypeSignatures() val (innerCtor) = acu.ctorDeclarations().toList() val (ctor) = acu.descendants(ASTExplicitConstructorInvocation::class.java).toList() @@ -260,7 +260,7 @@ class CtorInferenceTest : ProcessorTestSpec({ """) - val (t_Outer, t_Inner, t_Scratch) = acu.declaredTypeSignatures() + val (t_Outer, t_Inner, _) = acu.declaredTypeSignatures() val (innerCtor) = acu.ctorDeclarations().toList() val (ctor) = acu.descendants(ASTExplicitConstructorInvocation::class.java).toList() @@ -335,7 +335,7 @@ class CtorInferenceTest : ProcessorTestSpec({ parserTest("Mapping of type params doesn't fail") { - val (acu, spy) = parser.parseWithTypeInferenceSpy( + val (acu, _) = parser.parseWithTypeInferenceSpy( """ class Gen { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/Java7InferenceTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/Java7InferenceTest.kt index bb2778d52c..c67186fe28 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/Java7InferenceTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/Java7InferenceTest.kt @@ -193,7 +193,7 @@ class Java7InferenceTest : ProcessorTestSpec({ }) -private fun TypeDslMixin.ctorInfersTo( +private fun ctorInfersTo( call: ASTConstructorCall, inferredType: JClassType ) { @@ -204,7 +204,7 @@ private fun TypeDslMixin.ctorInfersTo( ) } -private fun TypeDslMixin.methodInfersTo(call: ASTMethodCall, returnType: JClassType) { +private fun methodInfersTo(call: ASTMethodCall, returnType: JClassType) { call.methodType.shouldMatchMethod( named = call.methodName, declaredIn = null, // not asserted diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/OverridingTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/OverridingTest.kt index 4265682cfc..c7f41da2b8 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/OverridingTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/OverridingTest.kt @@ -10,7 +10,6 @@ import io.kotest.matchers.shouldBe import net.sourceforge.pmd.lang.java.ast.* import net.sourceforge.pmd.lang.java.types.* import net.sourceforge.pmd.util.OptionalBool -import org.intellij.lang.annotations.Language import kotlin.test.assertFalse import kotlin.test.assertTrue diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/SpecialMethodsTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/SpecialMethodsTest.kt index 05ae0ee19a..1c3d7feb0e 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/SpecialMethodsTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/SpecialMethodsTest.kt @@ -5,6 +5,7 @@ package net.sourceforge.pmd.lang.java.types.internal.infer import io.kotest.matchers.shouldBe +import io.kotest.matchers.shouldNotBe import net.sourceforge.pmd.lang.ast.test.shouldBeA import net.sourceforge.pmd.lang.ast.test.shouldMatchN import net.sourceforge.pmd.lang.java.ast.* @@ -44,7 +45,7 @@ class SpecialMethodsTest : ProcessorTestSpec({ val t_Scratch = acu.declaredTypeSignatures()[0] val kvar = acu.typeVar("K") - val (k, k2, raw, call) = acu.methodCalls().toList() + val (k, k2, _, call) = acu.methodCalls().toList() doTest("Test this::getClass") { spy.shouldBeOk { @@ -137,7 +138,7 @@ class SpecialMethodsTest : ProcessorTestSpec({ """.trimIndent()) - val t_Scratch = acu.descendants(ASTTypeDeclaration::class.java).firstOrThrow().typeMirror + acu.descendants(ASTTypeDeclaration::class.java).firstOrThrow().typeMirror shouldNotBe null val call = acu.descendants(ASTMethodCall::class.java).firstOrThrow() diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StandaloneTypesTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StandaloneTypesTest.kt index 51729be664..ada89eb28b 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StandaloneTypesTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StandaloneTypesTest.kt @@ -8,10 +8,7 @@ package net.sourceforge.pmd.lang.java.types.internal.infer import io.kotest.assertions.withClue import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe -import io.kotest.property.arbitrary.filterNot -import io.kotest.property.checkAll import net.sourceforge.pmd.lang.ast.test.shouldBe -import net.sourceforge.pmd.lang.ast.test.shouldBeA import net.sourceforge.pmd.lang.ast.test.shouldMatchN import net.sourceforge.pmd.lang.java.ast.* import net.sourceforge.pmd.lang.java.ast.BinaryOp.* diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StressTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StressTest.kt index 587e564fd7..2af70e82aa 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StressTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/StressTest.kt @@ -39,7 +39,7 @@ class StressTest : ProcessorTestSpec({ fun TreeNodeWrapper.typeIs(value: Boolean) { it.typeMirror.shouldBeA { it.symbol.binaryName shouldBe "net.sourceforge.pmd.lang.java.types.testdata.BoolLogic\$${value.toString() - .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}" + .replaceFirstChar { char -> if (char.isLowerCase()) char.titlecase(Locale.getDefault()) else char.toString() }}" } } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeAnnotationsInferenceTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeAnnotationsInferenceTest.kt index b43cc4be6f..05ecc933b9 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeAnnotationsInferenceTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeAnnotationsInferenceTest.kt @@ -8,8 +8,6 @@ package net.sourceforge.pmd.lang.java.types.internal.infer import net.sourceforge.pmd.lang.java.ast.* import net.sourceforge.pmd.lang.java.types.* -import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger.VerboseLogger -import java.util.* /** */ diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeInferenceTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeInferenceTest.kt index 8a1e246d74..27d8af4949 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeInferenceTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/TypeInferenceTest.kt @@ -248,7 +248,7 @@ class Scratch { } """.trimIndent()) - val (t_I, t_C) = acu.declaredTypeSignatures() + val (_, t_C) = acu.declaredTypeSignatures() val tParam = acu.typeVariables().first { it.name == "T" } spy.shouldBeOk { diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/UnresolvedTypesRecoveryTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/UnresolvedTypesRecoveryTest.kt index 9c2b3e147d..99ca3b5dd2 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/UnresolvedTypesRecoveryTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/UnresolvedTypesRecoveryTest.kt @@ -261,7 +261,7 @@ class C { val (fooM, idM) = acu.descendants(ASTMethodDeclaration::class.java).toList { it.symbol } val t_Foo = fooM.getReturnType(Substitution.EMPTY).shouldBeUnresolvedClass("ooo.Foo") - val t_Bound = idM.typeParameters[0].upperBound.shouldBeUnresolvedClass("ooo.Bound") + idM.typeParameters[0].upperBound.shouldBeUnresolvedClass("ooo.Bound") val call = acu.descendants(ASTMethodCall::class.java).firstOrThrow() diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt index 7e462d2c99..abf42e6d75 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/cpd/test/CpdTextComparisonTest.kt @@ -130,9 +130,9 @@ abstract class CpdTextComparisonTest( private fun StringBuilder.formatLine(escapedImage: String, bcol: Any, ecol: Any): StringBuilder { var colStart = length - colStart = append(Indent).append(escapedImage).padCol(colStart, Col0Width) + colStart = append(INDENT).append(escapedImage).padCol(colStart, COL_0_WIDTH) @Suppress("UNUSED_VALUE") - colStart = append(Indent).append(bcol).padCol(colStart, Col1Width) + colStart = append(INDENT).append(bcol).padCol(colStart, COL_1_WIDTH) return append(ecol) } @@ -152,7 +152,7 @@ abstract class CpdTextComparisonTest( .replace(Regex("\\u000D\\u000A|[\\u000A\\u000B\\u000C\\u000D\\u0085\\u2028\\u2029]"), "\\\\n") // escape other newlines (normalizing), use \\R with java8+ .replace(Regex("[]\\[]"), "\\\\$0") // escape [] - var truncated = StringUtils.truncate(escaped, ImageSize) + var truncated = StringUtils.truncate(escaped, IMAGE_SIZE) if (truncated.endsWith('\\') && !truncated.endsWith("\\\\")) truncated = truncated.substring(0, truncated.length - 1) // cut inside an escape @@ -176,10 +176,10 @@ abstract class CpdTextComparisonTest( CpdLexer.tokenize(cpdLexer, sourceCodeOf(fileData)) private companion object { - const val Indent = " " - const val Col0Width = 40 - const val Col1Width = 10 + Indent.length - val ImageSize = Col0Width - Indent.length - 2 // -2 is for the "[]" + const val INDENT = " " + const val COL_0_WIDTH = 40 + const val COL_1_WIDTH = 10 + INDENT.length + const val IMAGE_SIZE = COL_0_WIDTH - INDENT.length - 2 // -2 is for the "[]" } } diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodeExtensions.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodeExtensions.kt index 2a132ce149..a6d0ea0892 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodeExtensions.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodeExtensions.kt @@ -20,8 +20,6 @@ val TextAvailableNode.textStr: String infix fun TextAvailableNode.shouldHaveText(str: String) { this::textStr shouldBe str } -inline fun Node.getDescendantsOfType(): List = descendants(T::class.java).toList() -inline fun Node.getFirstDescendantOfType(): T = descendants(T::class.java).firstOrThrow() fun Node.textOfReportLocation(): String? = reportLocation.regionInFile?.let(textDocument::sliceOriginalText)?.toString() diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt index 709b18c115..9d3dad1d49 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/NodePrinters.kt @@ -27,10 +27,10 @@ val SimpleNodePrinter = TextTreeRenderer(true, -1) open class RelevantAttributePrinter : BaseNodeAttributePrinter() { - private val Ignored = setOf("BeginLine", "EndLine", "BeginColumn", "EndColumn", "FindBoundary", "SingleLine") + private val defaultIgnoredAttributes = setOf("BeginLine", "EndLine", "BeginColumn", "EndColumn", "FindBoundary", "SingleLine") override fun ignoreAttribute(node: Node, attribute: Attribute): Boolean = - Ignored.contains(attribute.name) || attribute.name == "Image" && attribute.value == null + defaultIgnoredAttributes.contains(attribute.name) || attribute.name == "Image" && attribute.value == null } @@ -102,7 +102,7 @@ open class BaseNodeAttributePrinter : TextTreeRenderer(true, -1) { get() = this.javaClass.let { when { it.isEnum -> it - else -> it.enclosingClass.takeIf { it.isEnum } + else -> it.enclosingClass.takeIf { clazz -> clazz.isEnum } ?: throw IllegalStateException() } } diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt index e037138889..b7d9a5127e 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt @@ -12,6 +12,7 @@ import net.sourceforge.pmd.reporting.Report import net.sourceforge.pmd.reporting.RuleViolation import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.document.Chars +import java.util.* import kotlin.reflect.KCallable import kotlin.reflect.jvm.isAccessible import kotlin.test.assertEquals @@ -29,9 +30,9 @@ infix fun KCallable.shouldEqual(expected: V?) = n.should(equalityMatcher(v) as Matcher) } -private fun assertWrapper(callable: KCallable, right: V, asserter: (N, V) -> Unit) { +private fun assertWrapper(callable: KCallable, expected: V, asserter: (N, V) -> Unit) { - fun formatName() = "::" + callable.name.removePrefix("get").decapitalize() + fun formatName() = "::" + callable.name.removePrefix("get").replaceFirstChar { it.lowercase(Locale.getDefault()) } val value: N = try { callable.isAccessible = true @@ -41,7 +42,7 @@ private fun assertWrapper(callable: KCallable, right: V, asserter: (N, } try { - asserter(value, right) + asserter(value, expected) } catch (e: AssertionError) { if (e.message?.contains("expected:") == true) { diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/test/BaseTextComparisonTest.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/test/BaseTextComparisonTest.kt index 635a85655c..9c67e29a9a 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/test/BaseTextComparisonTest.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/test/BaseTextComparisonTest.kt @@ -31,8 +31,8 @@ abstract class BaseTextComparisonTest { data class FileData(val fileName: FileId, val fileText:String) /** - * Executes the test. The test files are looked up using the [parser]. - * The reference test file must be named [fileBaseName] + [ExpectedExt]. + * Executes the test. The test files are looked up using the [resourceLoader]. + * The reference test file must be named [fileBaseName] + [EXPECTED_EXTENSION]. * The source file to parse must be named [fileBaseName] + [extensionIncludingDot]. * * @param transformTextContent Function that maps the contents of the source file to the @@ -41,7 +41,7 @@ abstract class BaseTextComparisonTest { internal fun doTest(fileBaseName: String, expectedSuffix: String = "", transformTextContent: (FileData) -> String) { - val expectedFile = findTestFile(resourceLoader, "${resourcePrefix}/$fileBaseName$expectedSuffix$ExpectedExt").toFile() + val expectedFile = findTestFile(resourceLoader, "${resourcePrefix}/$fileBaseName$expectedSuffix$EXPECTED_EXTENSION").toFile() val actual = transformTextContent(sourceText(fileBaseName)) @@ -97,7 +97,7 @@ abstract class BaseTextComparisonTest { } companion object { - const val ExpectedExt = ".txt" + const val EXPECTED_EXTENSION = ".txt" } From dc92c64135a80c49ca4ba5bd7f5ff692a258346b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Mar 2024 17:06:58 +0100 Subject: [PATCH 38/39] [core] NodeStreamBlanketTest - prefilter the test data in order to avoid many ignored unit tests. E.g. before this change, we had: Tests passed: 5,417, ignored: 2,539 of 7,956 tests meaning about 30% of the tests were ignored. --- .../ast/internal/NodeStreamBlanketTest.java | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java index d8a0f3a496..755f948c7c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java @@ -68,7 +68,7 @@ class NodeStreamBlanketTest { ); @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("allNodeStreamVariants") void testToListConsistency(NodeStream stream) { List toList = stream.toList(); List collected = stream.collect(Collectors.toList()); @@ -81,7 +81,7 @@ class NodeStreamBlanketTest { } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("allNodeStreamVariants") void testToListSize(NodeStream stream) { List toList = stream.toList(); @@ -90,7 +90,7 @@ class NodeStreamBlanketTest { @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("nodeStreamVariantsNonEmpty") void testLast(NodeStream stream) { assertImplication( stream, @@ -100,7 +100,7 @@ class NodeStreamBlanketTest { } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("nodeStreamVariantsNonEmpty") void testFirst(NodeStream stream) { assertImplication( stream, @@ -111,7 +111,7 @@ class NodeStreamBlanketTest { @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("nodeStreamVariantsNonEmpty") void testDrop(NodeStream stream) { assertImplication( stream, @@ -123,7 +123,7 @@ class NodeStreamBlanketTest { } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("nodeStreamVariantsNonEmpty") void testDropLast(NodeStream stream) { assertImplication( stream, @@ -135,7 +135,7 @@ class NodeStreamBlanketTest { } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("nodeStreamVariantsMoreThanOne") void testDropMoreThan1(NodeStream stream) { assertImplication( stream, @@ -146,7 +146,7 @@ class NodeStreamBlanketTest { } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("nodeStreamVariantsNonEmpty") void testTake(NodeStream stream) { assertImplication( stream, @@ -158,7 +158,7 @@ class NodeStreamBlanketTest { } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("allNodeStreamVariants") void testGet(NodeStream stream) { for (int i = 0; i < 100; i++) { assertSame(stream.get(i), stream.drop(i).first(), "stream.get(i) == stream.drop(i).first()"); @@ -166,25 +166,25 @@ class NodeStreamBlanketTest { } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("allNodeStreamVariants") void testGetNegative(NodeStream stream) { assertThrows(IllegalArgumentException.class, () -> stream.get(-1)); } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("allNodeStreamVariants") void testDropNegative(NodeStream stream) { assertThrows(IllegalArgumentException.class, () -> stream.drop(-1)); } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("allNodeStreamVariants") void testTakeNegative(NodeStream stream) { assertThrows(IllegalArgumentException.class, () -> stream.take(-1)); } @ParameterizedTest - @MethodSource("primeNumbers") + @MethodSource("allNodeStreamVariants") void testEmpty(NodeStream stream) { assertEquivalence( stream, @@ -201,11 +201,21 @@ class NodeStreamBlanketTest { ); } - static Collection primeNumbers() { + static Collection> nodeStreamVariantsNonEmpty() { + return allNodeStreamVariants().stream().filter(NodeStream::nonEmpty).collect(Collectors.toList()); + } + + static Collection> nodeStreamVariantsMoreThanOne() { + return allNodeStreamVariants().stream().filter(n -> n.count() > 1).collect(Collectors.toList()); + } + + + static Collection> allNodeStreamVariants() { return ASTS.stream().flatMap( root -> Stream.of( root.asStream(), root.children().first().asStream(), + // keep this, so that transformation are tested on empty node streams as well NodeStream.empty() ) ).flatMap( @@ -261,10 +271,10 @@ class NodeStreamBlanketTest { private static void assertImplication(T input, Prop precond, Prop... properties) { assumeTrue(precond.test(input)); - for (Prop prop2 : properties) { + for (Prop prop : properties) { assertTrue( - prop2.test(input), - "Expected (" + precond.description + ") to entail (" + prop2.description + prop.test(input), + "Expected (" + precond.description + ") to entail (" + prop.description + "), but the latter was false" ); } From 6593a902d07f8e59fd9896cbf85bcf022c83cade Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 4 Mar 2024 18:50:11 +0100 Subject: [PATCH 39/39] [java] Fix AstTreeDumpTests after merge MethodDeclaration doesn't have @Image attribute anymore. --- .../Jep456_UnnamedPatternsAndVariables.txt | 20 +++++++++---------- .../java22p/Jep459_StringTemplates.txt | 16 +++++++-------- .../java22p/Jep463_UnnamedClasses1.txt | 2 +- .../java22p/Jep463_UnnamedClasses2.txt | 4 ++-- .../java22p/Jep463_UnnamedClasses3.txt | 2 +- .../Jep463_UnnamedClasses4WithImports.txt | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt index 8ade7f7fcc..ae94a215f0 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt @@ -42,7 +42,7 @@ | | +- 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] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "unnamedPatterns1", @Name = "unnamedPatterns1", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "unnamedPatterns1", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -158,7 +158,7 @@ | | +- 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 = "content", @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 = "unnamedPatterns2", @Name = "unnamedPatterns2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "unnamedPatterns2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -294,7 +294,7 @@ | | +- UnnamedPattern[] | +- MethodCall[@CompileTimeConstant = false, @Image = "pickAnotherBox", @MethodName = "pickAnotherBox", @ParenthesisDepth = 0, @Parenthesized = false] | +- ArgumentList[@Empty = true, @Size = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "processBox", @Name = "processBox", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Name = "processBox", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] | +- VoidType[] | +- FormalParameters[@Empty = false, @Size = 1] @@ -306,12 +306,12 @@ | | | +- ClassType[@FullyQualified = false, @SimpleName = "Ball"] | | +- 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 = "b", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | +- Block[@Empty = true, @Size = 0, @containsComment = false] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "stopProcessing", @Name = "stopProcessing", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Name = "stopProcessing", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] | +- Block[@Empty = true, @Size = 0, @containsComment = false] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "pickAnotherBox", @Name = "pickAnotherBox", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Name = "pickAnotherBox", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -325,14 +325,14 @@ | +- VariableDeclarator[@Initializer = true, @Name = "LIMIT"] | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PRIVATE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = true, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "LIMIT", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE] | +- 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] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Image = "sideEffect", @Name = "sideEffect", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Name = "sideEffect", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = false] | +- ModifierList[@EffectiveModifiers = "{private}", @ExplicitModifiers = "{private}"] | +- PrimitiveType[@Kind = PrimitiveTypeKind.INT] | +- FormalParameters[@Empty = true, @Size = 0] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- ReturnStatement[] | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "unnamedVariables", @Name = "unnamedVariables", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "unnamedVariables", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- VoidType[] | +- FormalParameters[@Empty = false, @Size = 1] @@ -496,14 +496,14 @@ | +- ImplementsList[@Empty = false, @Size = 1] | | +- ClassType[@FullyQualified = false, @SimpleName = "AutoCloseable"] | +- ClassBody[@Empty = false, @Size = 2] - | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "close", @Name = "close", @Overridden = true, @Static = false, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true] + | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "close", @Overridden = true, @Static = false, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = true] | | +- ModifierList[@EffectiveModifiers = "{public}", @ExplicitModifiers = "{public}"] | | | +- Annotation[@SimpleName = "Override"] | | | +- ClassType[@FullyQualified = false, @SimpleName = "Override"] | | +- VoidType[] | | +- FormalParameters[@Empty = true, @Size = 0] | | +- Block[@Empty = true, @Size = 0, @containsComment = false] - | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "acquire", @Name = "acquire", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = false] + | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "acquire", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PUBLIC, @Void = false] | +- ModifierList[@EffectiveModifiers = "{public, static}", @ExplicitModifiers = "{public, static}"] | +- ClassType[@FullyQualified = false, @SimpleName = "ScopedContext"] | +- FormalParameters[@Empty = true, @Size = 0] @@ -512,7 +512,7 @@ | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] | +- ClassType[@FullyQualified = false, @SimpleName = "ScopedContext"] | +- ArgumentList[@Empty = true, @Size = 0] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "unusedVariables2", @Name = "unusedVariables2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "unusedVariables2", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] +- VoidType[] +- FormalParameters[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt index 7ac8614246..73aced4fc5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep459_StringTemplates.txt @@ -23,7 +23,7 @@ | | +- ClassType[@FullyQualified = false, @SimpleName = "String"] | | +- 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 = "ipAddress", @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 = "STRTemplateProcessor", @Name = "STRTemplateProcessor", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "STRTemplateProcessor", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -297,14 +297,14 @@ | | | +- 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] | | +- TemplateFragment[@Content = "}\""] | +- TemplateFragment[@Content = "}\""] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "getOfferType", @Name = "getOfferType", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "getOfferType", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- ClassType[@FullyQualified = false, @SimpleName = "String"] | +- FormalParameters[@Empty = true, @Size = 0] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- ReturnStatement[] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "_getOfferType_", @Empty = false, @Image = "\"_getOfferType_\"", @Length = 14, @LiteralText = "\"_getOfferType_\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "multilineTemplateExpressions", @Name = "multilineTemplateExpressions", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "multilineTemplateExpressions", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -448,7 +448,7 @@ | | | +- 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] | | +- ArgumentList[@Empty = true, @Size = 0] | +- TemplateFragment[@Content = "}\n \"\"\""] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "FMTTemplateProcessor", @Name = "FMTTemplateProcessor", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "FMTTemplateProcessor", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -470,7 +470,7 @@ | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.DOUBLE] | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = true, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "height", @PatternBinding = false, @RecordComponent = true, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PRIVATE] | | +- RecordBody[@Empty = false, @Size = 1] - | | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Image = "area", @Name = "area", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] + | | +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Name = "area", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] | | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | | +- PrimitiveType[@Kind = PrimitiveTypeKind.DOUBLE] | | +- FormalParameters[@Empty = true, @Size = 0] @@ -607,7 +607,7 @@ | | | +- 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] | | +- ArgumentList[@Empty = true, @Size = 0] | +- TemplateFragment[@Content = "}\n \"\"\""] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "ensuringSafety", @Name = "ensuringSafety", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "ensuringSafety", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -650,7 +650,7 @@ | | +- 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 = "accountNumber", @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 = "literalsInsideTemplateExpressions", @Name = "literalsInsideTemplateExpressions", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "literalsInsideTemplateExpressions", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] | +- VoidType[] | +- FormalParameters[@Empty = true, @Size = 0] @@ -690,7 +690,7 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "user", @Name = "user", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] | +- TemplateFragment[@Content = "}\""] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "emptyEmbeddedExpression", @Name = "emptyEmbeddedExpression", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "emptyEmbeddedExpression", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] +- ModifierList[@EffectiveModifiers = "{static}", @ExplicitModifiers = "{static}"] +- VoidType[] +- FormalParameters[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.txt index 7b2ceabde1..8bafb59ab5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses1.txt @@ -1,5 +1,5 @@ +- CompilationUnit[@PackageName = ""] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] +- VoidType[] +- FormalParameters[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.txt index 4b147ea7bf..200582f309 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses2.txt @@ -1,12 +1,12 @@ +- CompilationUnit[@PackageName = ""] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "greeting", @Name = "greeting", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "greeting", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = false] | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] | +- ClassType[@FullyQualified = false, @SimpleName = "String"] | +- FormalParameters[@Empty = true, @Size = 0] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- ReturnStatement[] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Hello, World!", @Empty = false, @Image = "\"Hello, World!\"", @Length = 13, @LiteralText = "\"Hello, World!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] +- VoidType[] +- FormalParameters[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.txt index 5e04a358e1..2c78364825 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses3.txt @@ -5,7 +5,7 @@ | +- VariableDeclarator[@Initializer = true, @Name = "greeting"] | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_PACKAGE, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = true, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "greeting", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @TypeInferred = false, @Visibility = Visibility.V_PACKAGE] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Hello, World!", @Empty = false, @Image = "\"Hello, World!\"", @Length = 13, @LiteralText = "\"Hello, World!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] +- VoidType[] +- FormalParameters[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt index 6324eadc34..ab0ba4f8de 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep463_UnnamedClasses4WithImports.txt @@ -21,7 +21,7 @@ | | +- ClassType[@FullyQualified = false, @SimpleName = "Collectors"] | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = ", ", @Empty = false, @Image = "\", \"", @Length = 2, @LiteralText = "\", \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] - +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Image = "main", @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] + +- MethodDeclaration[@Abstract = false, @Arity = 0, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @MainMethod = true, @Name = "main", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"] +- VoidType[] +- FormalParameters[@Empty = true, @Size = 0]