Fix build (java: ASTRecord::getDeclarations())

This commit is contained in:
Andreas Dangel
2020-03-19 12:41:27 +01:00
parent 235e5f4160
commit 55915fe5ab
2 changed files with 5 additions and 6 deletions

View File

@ -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<ASTAnyTypeBodyDeclaration> getDeclarations() {
return getFirstChildOfType(ASTRecordBody.class).findChildrenOfType(ASTAnyTypeBodyDeclaration.class);
public NodeStream<ASTAnyTypeBodyDeclaration> getDeclarations() {
return getFirstChildOfType(ASTRecordBody.class).children(ASTAnyTypeBodyDeclaration.class);
}
@Override

View File

@ -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());