public void visit(Select obj) {
super.visit(obj);
List selectSymbols = obj.getSymbols();
HashMap<SingleElementSymbol, String> symbols = new HashMap<SingleElementSymbol, String>(selectSymbols.size());
for (int i = 0; i < selectSymbols.size(); i++) {
SingleElementSymbol symbol = (SingleElementSymbol)selectSymbols.get(i);
boolean needsAlias = visitor.namingContext.aliasColumns;
String newAlias = "c_" + i; //$NON-NLS-1$
Expression expr = SymbolMap.getExpression(symbol);
SingleElementSymbol newSymbol = symbol;
if (!(expr instanceof SingleElementSymbol)) {
newSymbol = new ExpressionSymbol(newSymbol.getShortName(), expr);
} else if (expr instanceof ElementSymbol) {
newSymbol = (ElementSymbol)expr;
if (!needsAlias) {
newAlias = newSymbol.getOutputName();
} else {
needsAlias &= needsAlias(newAlias, (ElementSymbol)expr);
}
} else {
newSymbol = (SingleElementSymbol)expr;
}
symbols.put(symbol, newAlias);
if (visitor.namingContext.aliasColumns && needsAlias) {
newSymbol = new AliasSymbol(symbol.getShortName(), newSymbol);
newSymbol.setOutputName(newAlias);
}
selectSymbols.set(i, newSymbol);
}
visitor.namingContext.currentSymbols = symbols;