}
}
private String getTupleElementTypeNames(ProducedType args, Unit unit) {
if (args!=null) {
Unit u = args.getDeclaration().getUnit();
boolean defaulted=false;
if (args.getDeclaration() instanceof UnionType) {
List<ProducedType> cts = args.getDeclaration().getCaseTypes();
if (cts.size()==2) {
TypeDeclaration lc = cts.get(0).getDeclaration();
if (lc instanceof Interface &&
lc.equals(u.getEmptyDeclaration())) {
args = cts.get(1);
defaulted = true;
}
TypeDeclaration rc = cts.get(1).getDeclaration();
if (lc instanceof Interface &&
rc.equals(u.getEmptyDeclaration())) {
args = cts.get(0);
defaulted = true;
}
}
}
if (args.getDeclaration() instanceof ClassOrInterface) {
if (args.getDeclaration().equals(u.getTupleDeclaration())) {
List<ProducedType> tal = args.getTypeArgumentList();
if (tal.size()>=3) {
ProducedType first = tal.get(1);
ProducedType rest = tal.get(2);
if (first!=null && rest!=null) {
String argtype = getProducedTypeName(first, unit);
if (rest.getDeclaration() instanceof Interface &&
rest.getDeclaration().equals(u.getEmptyDeclaration())) {
return defaulted ? argtype + "=" : argtype;
}
String argtypes = getTupleElementTypeNames(rest, unit);
if (argtypes!=null) {
return defaulted ?
argtype + "=, " + argtypes :
argtype + ", " + argtypes;
}
}
}
}
else if (args.getDeclaration().equals(u.getEmptyDeclaration())) {
return defaulted ? "=" : "";
}
else if (!defaulted &&
args.getDeclaration().equals(u.getSequentialDeclaration())) {
ProducedType elementType = u.getIteratedType(args);
if (elementType!=null) {
String etn = getProducedTypeName(elementType, unit);
if (isPrimitiveAbbreviatedType(elementType)) {
return etn + "*";
}
else {
return lt() + etn + gt() + "*";
}
}
}
else if (!defaulted &&
args.getDeclaration().equals(u.getSequenceDeclaration())) {
ProducedType elementType = u.getIteratedType(args);
if (elementType!=null) {
String etn = getProducedTypeName(elementType, unit);
if (isPrimitiveAbbreviatedType(elementType)) {
return etn + "+";
}