using System.Linq.Expressions; using Connected.Expressions.Expressions; using Connected.Expressions.Visitors; namespace Connected.Expressions.Translation.Resolvers; internal sealed class DeclaredAliasesResolver : DatabaseVisitor { private DeclaredAliasesResolver() { Aliases = new(); } private HashSet Aliases { get; set; } public static HashSet Resolve(Expression source) { var resolver = new DeclaredAliasesResolver(); resolver.Visit(source); return resolver.Aliases; } protected override Expression VisitSelect(SelectExpression select) { Aliases.Add(select.Alias); return select; } protected override Expression VisitTable(TableExpression table) { Aliases.Add(table.Alias); return table; } }