diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index df95511897..7affad5bd6 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -60,9 +60,9 @@ Being based on a proper Antlr grammar, CPD can: * To support the Java preview language features "Pattern Matching for Switch" and "Record Patterns", the following AST nodes have been introduced as experimental: - * {% jdoc java::lang.java.ast.ASTGuard %} + * {% jdoc java::lang.java.ast.ASTSwitchGuard %} * {% jdoc java::lang.java.ast.ASTRecordPattern %} - * {% jdoc java::lang.java.ast.ASTRecordStructurePattern %} + * {% jdoc java::lang.java.ast.ASTComponentPatternList %} ### External Contributions * [#3984](https://github.com/pmd/pmd/pull/3984): \[java] Fix AddEmptyString false-negative issue - [@LiGaOg](https://github.com/LiGaOg) diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 7ade381d06..3d4765cd61 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,8 +1,9 @@ /** * Support "JEP 427: Pattern Matching for switch (Third Preview)" for Java 19 Preview * Note: GuardedPattern is deprecated and only valid for 17-preview and 18-preview - * New AST node: Guard - used within switch case labels for refining a pattern + * New AST node: ASTSwitchGuard (production "Guard") - used within switch case labels for refining a pattern * Support "JEP 405: Record Patterns (Preview)" for Java 19 Preview + * New AST node: ASTRecordPattern and ASTComponentPatternList (production "RecordStructurePattern") * Remove support for Java 17 preview language features * Andreas Dangel 07/2022 *==================================================================== @@ -1817,7 +1818,7 @@ void RecordPattern(): ReferenceType() RecordStructurePattern() [ VariableDeclaratorId() ] } -void RecordStructurePattern(): +void RecordStructurePattern() #ComponentPatternList: {} { "(" [ RecordComponentPatternList() ] ")" @@ -2331,7 +2332,7 @@ void CaseLabelElement(ASTSwitchLabel label) #void: } } -void Guard() : +void Guard() #SwitchGuard: { Token t; checkForGuard(); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordStructurePattern.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTComponentPatternList.java similarity index 70% rename from pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordStructurePattern.java rename to pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTComponentPatternList.java index f74c2eb1d6..6fded4c6ab 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordStructurePattern.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTComponentPatternList.java @@ -12,19 +12,19 @@ import net.sourceforge.pmd.annotation.Experimental; * *
* - * RecordStructurePattern ::= "(" {@linkplain ASTPattern Pattern} ( "," {@linkplain ASTPattern pattern} ) ")" + * ComponentPatternList ::= "(" {@linkplain ASTPattern Pattern} ( "," {@linkplain ASTPattern pattern} ) ")" * ** * @see JEP 405: Record Patterns (Preview) */ @Experimental -public final class ASTRecordStructurePattern extends AbstractJavaNode { - ASTRecordStructurePattern(int id) { +public final class ASTComponentPatternList extends AbstractJavaNode { + ASTComponentPatternList(int id) { super(id); } - ASTRecordStructurePattern(JavaParser p, int id) { + ASTComponentPatternList(JavaParser p, int id) { super(p, id); } 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 43a05873a9..d31b1522f6 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 @@ -10,7 +10,7 @@ import net.sourceforge.pmd.annotation.Experimental; * A pattern (for pattern matching constructs like {@link ASTInstanceOfExpression InstanceOfExpression} * or within a {@link ASTSwitchLabel}). This is a JDK 16 feature. * - *
This interface will be implemented by all forms of patterns. + *
This interface is implemented by all forms of patterns. * *
* 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 229f3e7a28..6db0e82d6b 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 @@ -7,12 +7,11 @@ package net.sourceforge.pmd.lang.java.ast; import net.sourceforge.pmd.annotation.Experimental; /** - * A record pattern (JDK19). This can be found on - * the right-hand side of an {@link ASTInstanceOfExpression InstanceOfExpression}. + * A record pattern (JDK19). * ** - * RecordPattern ::= {@linkplain ASTReferenceType ReferenceType} {@linkplain ASTRecordStructurePattern RecordStructurePattern} [ {@linkplain ASTVariableDeclaratorId} VariableDeclaratorId ] + * RecordPattern ::= {@linkplain ASTReferenceType ReferenceType} {@linkplain ASTComponentPatternList ComponentPatternList} [ {@linkplain ASTVariableDeclaratorId VariableDeclaratorId} ] * ** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTGuard.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchGuard.java similarity index 72% rename from pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTGuard.java rename to pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchGuard.java index ea0253dd2f..b59332f2a1 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTGuard.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchGuard.java @@ -11,21 +11,21 @@ import net.sourceforge.pmd.annotation.Experimental; * ** - * SwitchLabel := "case" {@linkplain ASTPattern Pattern} "when" {@linkplain ASTGuard Guard} - * Guard ::= {@linkplain ASTExpression Expression} + * SwitchLabel := "case" {@linkplain ASTPattern Pattern} SwitchGuard? + * SwitchGuard ::= "when" {@linkplain ASTExpression Expression} * ** * @see JEP 427: Pattern Matching for switch (Third Preview) */ @Experimental -public final class ASTGuard extends AbstractJavaNode { +public final class ASTSwitchGuard extends AbstractJavaNode { - ASTGuard(int id) { + ASTSwitchGuard(int id) { super(id); } - ASTGuard(JavaParser p, int id) { + ASTSwitchGuard(JavaParser p, int id) { super(p, id); } 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 beef16084a..7c467a4c43 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 @@ -13,11 +13,15 @@ final class AstImplUtil { } static void bumpParenDepth(ASTPattern pattern) { - assert pattern instanceof ASTTypePattern || pattern instanceof ASTGuardedPattern + assert pattern instanceof ASTTypePattern + || pattern instanceof ASTRecordPattern + || pattern instanceof ASTGuardedPattern : pattern.getClass() + " doesn't have parenDepth attribute!"; if (pattern instanceof ASTTypePattern) { ((ASTTypePattern) pattern).bumpParenDepth(); + } else if (pattern instanceof ASTRecordPattern) { + ((ASTRecordPattern) pattern).bumpParenDepth(); } else if (pattern instanceof ASTGuardedPattern) { ((ASTGuardedPattern) pattern).bumpParenDepth(); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java index dd5fdefbc4..68cc6d02bc 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java @@ -953,7 +953,7 @@ public class JavaParserDecoratedVisitor implements JavaParserVisitor { @Experimental @Override - public Object visit(ASTGuard node, Object data) { + public Object visit(ASTSwitchGuard node, Object data) { visitor.visit(node, data); return visit((JavaNode) node, data); } @@ -967,7 +967,7 @@ public class JavaParserDecoratedVisitor implements JavaParserVisitor { @Experimental @Override - public Object visit(ASTRecordStructurePattern node, Object data) { + public Object visit(ASTComponentPatternList node, Object data) { visitor.visit(node, data); return visit((JavaNode) node, data); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java index 3e50ae884c..d1e64f15fb 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java @@ -672,7 +672,7 @@ public class JavaParserVisitorAdapter implements JavaParserVisitor { @Experimental @Override - public Object visit(ASTGuard node, Object data) { + public Object visit(ASTSwitchGuard node, Object data) { return visit((JavaNode) node, data); } @@ -684,7 +684,7 @@ public class JavaParserVisitorAdapter implements JavaParserVisitor { @Experimental @Override - public Object visit(ASTRecordStructurePattern node, Object data) { + public Object visit(ASTComponentPatternList node, Object data) { return visit((JavaNode) node, data); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java index 3df4e0b744..8f558ae61e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java @@ -804,7 +804,7 @@ public class JavaParserVisitorDecorator implements JavaParserControllessVisitor @Experimental @Override - public Object visit(ASTGuard node, Object data) { + public Object visit(ASTSwitchGuard node, Object data) { return visitor.visit(node, data); } @@ -816,7 +816,7 @@ public class JavaParserVisitorDecorator implements JavaParserControllessVisitor @Experimental @Override - public Object visit(ASTRecordStructurePattern node, Object data) { + public Object visit(ASTComponentPatternList node, Object data) { return visitor.visit(node, data); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java index 95231e21ef..eaf3b33470 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java @@ -37,6 +37,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType; import net.sourceforge.pmd.lang.java.ast.ASTCompactConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; +import net.sourceforge.pmd.lang.java.ast.ASTComponentPatternList; import net.sourceforge.pmd.lang.java.ast.ASTConditionalAndExpression; import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression; import net.sourceforge.pmd.lang.java.ast.ASTConditionalOrExpression; @@ -60,7 +61,6 @@ import net.sourceforge.pmd.lang.java.ast.ASTForStatement; import net.sourceforge.pmd.lang.java.ast.ASTForUpdate; import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; import net.sourceforge.pmd.lang.java.ast.ASTFormalParameters; -import net.sourceforge.pmd.lang.java.ast.ASTGuard; import net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern; import net.sourceforge.pmd.lang.java.ast.ASTIfStatement; import net.sourceforge.pmd.lang.java.ast.ASTImplementsList; @@ -105,7 +105,6 @@ import net.sourceforge.pmd.lang.java.ast.ASTRecordComponent; import net.sourceforge.pmd.lang.java.ast.ASTRecordComponentList; import net.sourceforge.pmd.lang.java.ast.ASTRecordDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTRecordPattern; -import net.sourceforge.pmd.lang.java.ast.ASTRecordStructurePattern; import net.sourceforge.pmd.lang.java.ast.ASTReferenceType; import net.sourceforge.pmd.lang.java.ast.ASTRelationalExpression; import net.sourceforge.pmd.lang.java.ast.ASTResource; @@ -119,6 +118,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTStatement; import net.sourceforge.pmd.lang.java.ast.ASTStatementExpression; import net.sourceforge.pmd.lang.java.ast.ASTStatementExpressionList; import net.sourceforge.pmd.lang.java.ast.ASTSwitchExpression; +import net.sourceforge.pmd.lang.java.ast.ASTSwitchGuard; import net.sourceforge.pmd.lang.java.ast.ASTSwitchLabel; import net.sourceforge.pmd.lang.java.ast.ASTSwitchLabeledBlock; import net.sourceforge.pmd.lang.java.ast.ASTSwitchLabeledExpression; @@ -887,7 +887,7 @@ public abstract class AbstractJavaRule extends AbstractRule implements JavaParse @Experimental @Override - public Object visit(ASTGuard node, Object data) { + public Object visit(ASTSwitchGuard node, Object data) { return visit((JavaNode) node, data); } @@ -899,7 +899,7 @@ public abstract class AbstractJavaRule extends AbstractRule implements JavaParse @Experimental @Override - public Object visit(ASTRecordStructurePattern node, Object data) { + public Object visit(ASTComponentPatternList node, Object data) { return visit((JavaNode) node, data); } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/GuardedAndParenthesizedPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/GuardedAndParenthesizedPatterns.txt index bd16c77251..a0d0d48d5b 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/GuardedAndParenthesizedPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/GuardedAndParenthesizedPatterns.txt @@ -27,7 +27,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "s", @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "s"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- EqualityExpression[@Image = "==", @Operator = "=="] | | | +- PrimaryExpression[] @@ -74,7 +74,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Integer", @ReferenceToClassSameCompilationUnit = false] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "i", @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "i"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- EqualityExpression[@Image = "==", @Operator = "=="] | | | +- PrimaryExpression[] @@ -103,7 +103,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Long", @ReferenceToClassSameCompilationUnit = false] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "l", @LambdaParameter = false, @LocalVariable = false, @Name = "l", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "l"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- EqualityExpression[@Image = "==", @Operator = "=="] | | | +- PrimaryExpression[] @@ -235,7 +235,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "s", @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "s"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- PrimaryExpression[] | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false] @@ -285,7 +285,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Integer", @ReferenceToClassSameCompilationUnit = false] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "i", @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "i"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- EqualityExpression[@Image = "==", @Operator = "=="] | | | +- PrimaryExpression[] @@ -314,7 +314,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Long", @ReferenceToClassSameCompilationUnit = false] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "l", @LambdaParameter = false, @LocalVariable = false, @Name = "l", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "l"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- PrimaryExpression[] | | | +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RecordPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RecordPatterns.txt index 01325687e6..1141e09861 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RecordPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RecordPatterns.txt @@ -139,7 +139,7 @@ | | +- RecordPattern[@ParenthesisDepth = 0] | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Point", @ReferenceToClassSameCompilationUnit = false] - | | +- RecordStructurePattern[] + | | +- ComponentPatternList[] | | +- TypePattern[@ParenthesisDepth = 0] | | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "int"] | | | | +- PrimitiveType[@Array = false, @ArrayDepth = 0, @Boolean = false, @Image = "int"] @@ -189,7 +189,7 @@ | | +- RecordPattern[@ParenthesisDepth = 0] | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Rectangle", @ReferenceToClassSameCompilationUnit = false] - | | +- RecordStructurePattern[] + | | +- ComponentPatternList[] | | +- TypePattern[@ParenthesisDepth = 0] | | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "ColoredPoint"] | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] @@ -239,11 +239,11 @@ | | +- RecordPattern[@ParenthesisDepth = 0] | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Rectangle", @ReferenceToClassSameCompilationUnit = false] - | | +- RecordStructurePattern[] + | | +- ComponentPatternList[] | | +- RecordPattern[@ParenthesisDepth = 0] | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "ColoredPoint", @ReferenceToClassSameCompilationUnit = false] - | | | +- RecordStructurePattern[] + | | | +- ComponentPatternList[] | | | +- TypePattern[@ParenthesisDepth = 0] | | | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "Point"] | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] @@ -296,15 +296,15 @@ | | +- RecordPattern[@ParenthesisDepth = 0] | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Rectangle", @ReferenceToClassSameCompilationUnit = false] - | | +- RecordStructurePattern[] + | | +- ComponentPatternList[] | | +- RecordPattern[@ParenthesisDepth = 0] | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "ColoredPoint", @ReferenceToClassSameCompilationUnit = false] - | | | +- RecordStructurePattern[] + | | | +- ComponentPatternList[] | | | +- RecordPattern[@ParenthesisDepth = 0] | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Point", @ReferenceToClassSameCompilationUnit = false] - | | | | +- RecordStructurePattern[] + | | | | +- ComponentPatternList[] | | | | +- TypePattern[@ParenthesisDepth = 0] | | | | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "var"] | | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] @@ -385,7 +385,7 @@ | | | +- TypeArgument[@Wildcard = false] | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Object", @ReferenceToClassSameCompilationUnit = false] - | | +- RecordStructurePattern[] + | | +- ComponentPatternList[] | | +- TypePattern[@ParenthesisDepth = 0] | | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "String"] | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] @@ -440,7 +440,7 @@ | | +- TypeArgument[@Wildcard = false] | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "String", @ReferenceToClassSameCompilationUnit = false] - | +- RecordStructurePattern[] + | +- ComponentPatternList[] | +- TypePattern[@ParenthesisDepth = 0] | +- Type[@Array = false, @ArrayDepth = 0, @ArrayType = false, @TypeImage = "var"] | | +- ReferenceType[@Array = false, @ArrayDepth = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RefiningPatternsInSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RefiningPatternsInSwitch.txt index a95d067730..74f5d9dc3e 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RefiningPatternsInSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java19p/RefiningPatternsInSwitch.txt @@ -157,7 +157,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Triangle", @ReferenceToClassSameCompilationUnit = true] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "t", @LambdaParameter = false, @LocalVariable = false, @Name = "t", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "t"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- RelationalExpression[@Image = ">"] | | | +- PrimaryExpression[] @@ -217,7 +217,7 @@ | | | | | +- ReferenceType[@Array = false, @ArrayDepth = 0] | | | | | +- ClassOrInterfaceType[@AnonymousClass = false, @Array = false, @ArrayDepth = 0, @Image = "Triangle", @ReferenceToClassSameCompilationUnit = true] | | | | +- VariableDeclaratorId[@Array = false, @ArrayDepth = 0, @ArrayType = false, @ExceptionBlockParameter = false, @ExplicitReceiverParameter = false, @Field = false, @Final = false, @ForeachVariable = false, @FormalParameter = false, @Image = "t", @LambdaParameter = false, @LocalVariable = false, @Name = "t", @PatternBinding = true, @ResourceDeclaration = false, @TypeInferred = false, @VariableName = "t"] - | | | +- Guard[] + | | | +- SwitchGuard[] | | | +- Expression[@StandAlonePrimitive = false] | | | +- RelationalExpression[@Image = ">"] | | | +- PrimaryExpression[]