diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 311abf5f12..794293b75c 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -132,6 +132,7 @@ implementations, and their corresponding Parser if it exists (in the same packag * {% jdoc !!core::cpd.token.AntlrToken#getType() %} - use `getKind()` instead. * {% jdoc core::lang.rule.ImmutableLanguage %} * {% jdoc core::lang.rule.MockRule %} +* {% jdoc !!java::lang.java.ast.ASTRecordDeclaration#getComponentList() %} * Multiple fields, constructors and methods in {% jdoc core::lang.rule.XPathRule %}. See javadoc for details. ### External Contributions 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 553190dd74..925425f8f5 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 @@ -57,7 +57,18 @@ public final class ASTRecordDeclaration extends AbstractAnyTypeDeclaration { return isNested(); } + /** + * @deprecated Renamed to {@link #getRecordComponents()} + */ + @Deprecated public ASTRecordComponentList getComponentList() { + return getRecordComponents(); + } + + /** Returns the record component list. */ + // @NonNull + @Override + public ASTRecordComponentList getRecordComponents() { return getFirstChildOfType(ASTRecordComponentList.class); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractAnyTypeDeclaration.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractAnyTypeDeclaration.java index fbdacd93bc..4bd5fc0607 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractAnyTypeDeclaration.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractAnyTypeDeclaration.java @@ -53,6 +53,16 @@ public abstract class AbstractAnyTypeDeclaration extends AbstractJavaAccessTypeN return getImage(); } + + /** + * Returns the record component list, or null if this is not a record + * declaration. + */ + // @Nullable // TODO pull up to ASTAnyTypeDecl on 7.0.x + public ASTRecordComponentList getRecordComponents() { + return getFirstChildOfType(ASTRecordComponentList.class); + } + /** * Returns true if the enclosing type of this type declaration * is any of the given kinds. If this declaration is a top-level