From 55915fe5ab8f6d2e0e334719c8722834e42a1932 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 19 Mar 2020 12:41:27 +0100 Subject: [PATCH] Fix build (java: ASTRecord::getDeclarations()) --- .../pmd/lang/java/ast/ASTRecordDeclaration.java | 7 +++---- .../sourceforge/pmd/lang/java/ast/Java14PreviewTest.java | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) 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 1dac2f1755..763c17623a 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 @@ -5,10 +5,9 @@ package net.sourceforge.pmd.lang.java.ast; -import java.util.List; - import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.ast.NodeStream; /** * A record declaration is a special data class type (JDK 14 preview feature). @@ -49,8 +48,8 @@ public final class ASTRecordDeclaration extends AbstractAnyTypeDeclaration { } @Override - public List getDeclarations() { - return getFirstChildOfType(ASTRecordBody.class).findChildrenOfType(ASTAnyTypeBodyDeclaration.class); + public NodeStream getDeclarations() { + return getFirstChildOfType(ASTRecordBody.class).children(ASTAnyTypeBodyDeclaration.class); } @Override 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 b487c35267..143b7eb312 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 @@ -134,7 +134,7 @@ public class Java14PreviewTest { Assert.assertTrue(complex.isNested()); Assert.assertEquals(0, getComponent(complex, 0).findChildrenOfType(ASTAnnotation.class).size()); Assert.assertEquals(1, getComponent(complex, 1).findChildrenOfType(ASTAnnotation.class).size()); - Assert.assertEquals(2, complex.getDeclarations().size()); + Assert.assertEquals(2, complex.getDeclarations().count()); Assert.assertTrue(complex.getDeclarations().get(0).getChild(1) instanceof ASTConstructorDeclaration); Assert.assertTrue(complex.getDeclarations().get(1).getChild(0) instanceof ASTRecordDeclaration); Assert.assertTrue(complex.getParent() instanceof ASTClassOrInterfaceBodyDeclaration); @@ -153,7 +153,7 @@ public class Java14PreviewTest { Assert.assertEquals(1, rangeConstructors.size()); Assert.assertEquals("Range", rangeConstructors.get(0).getImage()); Assert.assertTrue(rangeConstructors.get(0).getChild(0) instanceof ASTAnnotation); - Assert.assertEquals(2, range.getDeclarations().size()); + Assert.assertEquals(2, range.getDeclarations().count()); ASTRecordDeclaration varRec = recordDecls.get(3); Assert.assertEquals("VarRec", varRec.getSimpleName());