ASTFieldDeclaration extends AbstractJavaAccessTypeNode implements Dimensionable, SignedNode<ASTFieldDeclaration>, Iterable<ASTVariableDeclaratorId> { @Deprecated @DeprecatedAttribute(replaceWith = "VariableDeclaratorId/@Name") public String getVariableName() { ASTVariableDeclaratorId decl = getFirstDescendantOfType(ASTVariableDeclaratorId.class); if (decl != null) { return decl.getImage(); } return null; } @InternalApi @Deprecated  ASTFieldDeclaration(int id); @InternalApi @Deprecated  ASTFieldDeclaration(JavaParser p, int id); @Override Object jjtAccept(JavaParserVisitor visitor, Object data); boolean isSyntacticallyPublic(); @Override boolean isPublic(); boolean isSyntacticallyStatic(); @Override boolean isStatic(); boolean isSyntacticallyFinal(); @Override boolean isFinal(); @Override boolean isPrivate(); @Override boolean isPackagePrivate(); @Override boolean isProtected(); boolean isAnnotationMember(); boolean isInterfaceMember(); @Override @Deprecated boolean isArray(); @Override @Deprecated int getArrayDepth(); @Deprecated @DeprecatedAttribute(replaceWith = "VariableDeclaratorId/@Name") String getVariableName(); @Override JavaFieldSignature getSignature(); @Override Iterator<ASTVariableDeclaratorId> iterator(); @Override @Deprecated Class<?> getType(); @Override @Deprecated JavaTypeDefinition getTypeDefinition();  }
@Test public void testGetVariableName() { int id = 0; ASTFieldDeclaration n = new ASTFieldDeclaration(id++); ASTType t = new ASTType(id++); ASTVariableDeclarator decl = new ASTVariableDeclarator(id++); ASTVariableDeclaratorId declid = new ASTVariableDeclaratorId(id++); n.jjtAddChild(t, 0); t.jjtAddChild(decl, 0); decl.jjtAddChild(declid, 0); declid.setImage("foo"); assertEquals("foo", n.getVariableName()); }