public Expression rewriteExpression(Expression node, Void context, ExpressionTreeRewriter<Void> treeRewriter)
{
Expression rewrittenExpression = treeRewriter.defaultRewrite(node, context);
// cast expression if coercion is registered
Type coercion = analysis.getCoercion(node);
if (coercion != null) {
rewrittenExpression = new Cast(rewrittenExpression, coercion.getName());
}
return rewrittenExpression;
}
@Override
public Expression rewriteQualifiedNameReference(QualifiedNameReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter)
{
QualifiedName name = node.getName();
Integer fieldIndex = resolvedNames.get(name);
Preconditions.checkState(fieldIndex != null, "No field mapping for name '%s'", name);
Symbol symbol = rewriteBase.getSymbol(fieldIndex);
Preconditions.checkState(symbol != null, "No symbol mapping for name '%s' (%s)", name, fieldIndex);
Expression rewrittenExpression = new QualifiedNameReference(symbol.toQualifiedName());
// cast expression if coercion is registered
Type coercion = analysis.getCoercion(node);
if (coercion != null) {
rewrittenExpression = new Cast(rewrittenExpression, coercion.getName());
}
return rewrittenExpression;
}
}, expression);