You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
635 B
32 lines
635 B
using System.Linq.Expressions;
|
|
using Connected.Expressions.Expressions;
|
|
using Connected.Expressions.Visitors;
|
|
|
|
namespace Connected.Expressions.Translation.Resolvers;
|
|
|
|
internal sealed class ReferencedAliasesResolver : DatabaseVisitor
|
|
{
|
|
private ReferencedAliasesResolver()
|
|
{
|
|
Aliases = new();
|
|
}
|
|
|
|
private HashSet<Alias> Aliases { get; }
|
|
|
|
public static HashSet<Alias> Resolve(Expression source)
|
|
{
|
|
var resolver = new ReferencedAliasesResolver();
|
|
|
|
resolver.Visit(source);
|
|
|
|
return resolver.Aliases;
|
|
}
|
|
|
|
protected override Expression VisitColumn(ColumnExpression column)
|
|
{
|
|
Aliases.Add(column.Alias);
|
|
|
|
return column;
|
|
}
|
|
}
|