}
public Node createTypeDeclaration(String kind, Node modifiers, Node name, Node params, Node body, List<Node> addons) {
if (kind.equals("interface")) return createInterfaceDeclaration(modifiers, name, params, body, addons);
ClassDeclaration decl = new ClassDeclaration().astName(createIdentifierIfNeeded(name, currentPos())).rawBody(body);
if (modifiers != null) decl.astModifiers(createModifiersIfNeeded(modifiers, currentPos()));
if (params instanceof TemporaryNode.OrphanedTypeVariables) {
TemporaryNode.OrphanedTypeVariables otv = (TemporaryNode.OrphanedTypeVariables)params;
if (otv.variables != null) for (Node typeParameter : otv.variables) {
if (typeParameter != null) decl.rawTypeVariables().addToEnd(typeParameter);
}
}
if (addons != null) for (Node n : addons) {
if (n instanceof TemporaryNode.ExtendsClause) {
//if (!decl.implementing().isEmpty()) //TODO add error node: implements must come after extends
//if (!decl.extending().isEmpty()) //TODO add error node: multiple extends clauses.
List<Node> superClasses = ((TemporaryNode.ExtendsClause)n).superTypes;
if (superClasses != null && superClasses.size() > 0) {
//if (superClasses.size() > 1) //TODO add error node: 'extends' on class can only accept 1 type.
decl.rawExtending(superClasses.get(0));
}
}
if (n instanceof TemporaryNode.ImplementsClause) {
//if (!decl.implementing().isEmpty()) //TODO add error node: multiple implements clauses.
List<Node> interfaces = ((TemporaryNode.ImplementsClause)n).superInterfaces;
if (interfaces != null) for (Node i : interfaces) decl.rawImplementing().addToEnd(i);
}
}
return posify(decl);
}