// Iterate over all projection elements to retrieve the defined aliases
Set<String> aliases = new HashSet<String>();
List<Node> unaliasedNodes = new ArrayList<Node>();
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
Node projElem = node.jjtGetChild(i);
assert projElem instanceof ASTProjectionElem : "child node is not a projection element";
Object result = projElem.jjtAccept(this, aliases);
if (result instanceof String) {
String alias = (String)result;
boolean isUnique = aliases.add(alias);
if (!isUnique) {
throw new VisitorException("Duplicate projection element aliases: '" + alias + "'");
}
}
else {
unaliasedNodes.add(projElem);
}
}
// Iterate over the unaliased nodes and generate aliases for them
int aliasNo = 1;
for (Node projElem : unaliasedNodes) {
Node exprNode = projElem.jjtGetChild(0);
if (exprNode instanceof ASTVar) {
String varName = ((ASTVar)exprNode).getName();
if (!aliases.contains(varName)) {