public void test_create() {
   ASTNode owner = argumentList();
   NodeList<ASTNode> list = NodeList.create(owner);
   assertNotNull(list);
   assertSize(0, list);
   assertSame(owner, list.getOwner());
 }
Beispiel #2
0
/** Representation of a Dart type name. */
public class DartTypeNode extends DartNode {

  private DartNode identifier;
  private NodeList<DartTypeNode> typeArguments = NodeList.create(this);
  private Type type;

  public DartTypeNode(DartNode identifier) {
    this(identifier, null);
  }

  public DartTypeNode(DartNode identifier, List<DartTypeNode> typeArguments) {
    this.identifier = becomeParentOf(identifier);
    this.typeArguments.addAll(typeArguments);
  }

  public DartNode getIdentifier() {
    return identifier;
  }

  public List<DartTypeNode> getTypeArguments() {
    return typeArguments;
  }

  @Override
  public void setType(Type type) {
    this.type = type;
  }

  @Override
  public Type getType() {
    return type;
  }

  @Override
  public void visitChildren(ASTVisitor<?> visitor) {
    identifier.accept(visitor);
    typeArguments.accept(visitor);
  }

  @Override
  public <R> R accept(ASTVisitor<R> visitor) {
    return visitor.visitTypeNode(this);
  }
}
/** Represents a Dart function. */
public class DartFunction extends DartNode {

  private final NodeList<DartParameter> parameters = NodeList.create(this);
  private DartBlock body;
  private DartTypeNode returnTypeNode;

  public DartFunction(List<DartParameter> parameters, DartBlock body, DartTypeNode returnTypeNode) {
    this.parameters.addAll(parameters);
    this.body = becomeParentOf(body);
    this.returnTypeNode = becomeParentOf(returnTypeNode);
  }

  public DartBlock getBody() {
    return body;
  }

  public List<DartParameter> getParameters() {
    return parameters;
  }

  public DartTypeNode getReturnTypeNode() {
    return returnTypeNode;
  }

  @Override
  public void visitChildren(ASTVisitor<?> visitor) {
    parameters.accept(visitor);
    safelyVisitChild(body, visitor);
    safelyVisitChild(returnTypeNode, visitor);
  }

  @Override
  public <R> R accept(ASTVisitor<R> visitor) {
    return visitor.visitFunction(this);
  }
}