diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 34eaf84fc0e..325ad6b74a2 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1131,15 +1131,15 @@ void RecordDeclaration(int modifiers): } t= {checkForBadTypeIdentifierUsage(t.image); jjtThis.setImage(t.image);} [ TypeParameters() ] - "(" RecordComponents() ")" + RecordComponentList() [ ImplementsList() ] RecordBody() } -void RecordComponents() : +void RecordComponentList() : {} { - RecordComponent() ("," RecordComponent())* + "(" RecordComponent() ("," RecordComponent())* ")" } void RecordComponent(): diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordComponents.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordComponentList.java similarity index 62% rename from pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordComponents.java rename to pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordComponentList.java index 527ad8c2e76..ca3108235ca 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordComponents.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordComponentList.java @@ -12,17 +12,18 @@ * *
  *
- * RecordComponents ::= {@linkplain ASTRecordComponent RecordComponent} ( "," {@linkplain ASTRecordComponent RecordComponent} )*
+ * RecordComponentList ::= "("       {@linkplain ASTRecordComponent RecordComponent}
+ *                             ( "," {@linkplain ASTRecordComponent RecordComponent} )* ")"
  *
  * 
*/ @Experimental -public class ASTRecordComponents extends AbstractJavaNode { - ASTRecordComponents(int id) { +public class ASTRecordComponentList extends AbstractJavaNode { + ASTRecordComponentList(int id) { super(id); } - ASTRecordComponents(JavaParser p, int id) { + ASTRecordComponentList(JavaParser p, int id) { super(p, id); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordDeclaration.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordDeclaration.java index 924b95a8188..ddc805d6010 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordDeclaration.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRecordDeclaration.java @@ -19,7 +19,7 @@ * RecordDeclaration ::= "record" * <IDENTIFIER> * {@linkplain ASTTypeParameters TypeParameters}? - * "(" {@linkplain ASTRecordComponents RecordComponents} ")" + * {@linkplain ASTRecordComponentList RecordComponents} * {@linkplain ASTImplementsList ImplementsList}? * {@linkplain ASTRecordBody RecordBody} * 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 cc67518b6a4..a7f99ff1a3a 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 @@ -917,7 +917,7 @@ public Object visit(ASTRecordDeclaration node, Object data) { @Override @Experimental - public Object visit(ASTRecordComponents node, Object data) { + public Object visit(ASTRecordComponentList 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 608caecc6a7..dd25b22a72e 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 @@ -642,7 +642,7 @@ public Object visit(ASTRecordDeclaration node, Object data) { @Override @Experimental - public Object visit(ASTRecordComponents node, Object data) { + public Object visit(ASTRecordComponentList 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 6833b148699..3aeb67f59a8 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 @@ -774,7 +774,7 @@ public Object visit(ASTRecordDeclaration node, Object data) { @Override @Experimental - public Object visit(ASTRecordComponents node, Object data) { + public Object visit(ASTRecordComponentList 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 e54b54800e5..37557fef305 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 @@ -99,7 +99,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTRecordBody; import net.sourceforge.pmd.lang.java.ast.ASTRecordBodyDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTRecordComponent; -import net.sourceforge.pmd.lang.java.ast.ASTRecordComponents; +import net.sourceforge.pmd.lang.java.ast.ASTRecordComponentList; import net.sourceforge.pmd.lang.java.ast.ASTRecordConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTRecordDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTReferenceType; @@ -857,7 +857,7 @@ public Object visit(ASTRecordDeclaration node, Object data) { @Override @Experimental - public Object visit(ASTRecordComponents node, Object data) { + public Object visit(ASTRecordComponentList node, Object data) { return visit((JavaNode) node, data); } diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java index 0478d23a7e0..163cfee6738 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java @@ -96,7 +96,7 @@ public void recordPoint() { ASTCompilationUnit compilationUnit = java14p.parseResource("Point.java"); ASTRecordDeclaration recordDecl = compilationUnit.getFirstDescendantOfType(ASTRecordDeclaration.class); Assert.assertEquals("Point", recordDecl.getImage()); - List components = recordDecl.getFirstChildOfType(ASTRecordComponents.class) + List components = recordDecl.getFirstChildOfType(ASTRecordComponentList.class) .findChildrenOfType(ASTRecordComponent.class); Assert.assertEquals(2, components.size()); Assert.assertEquals("x", components.get(0).getImage());