public override IASTNode VisitProjection(SqlServerCommandParser.ProjectionContext context) { // FIXME :The stop index of project is the stop index of projection, instead of alias. if (null != context.qualifiedShorthand()) { var shorthand = context.qualifiedShorthand(); var result = new ShorthandProjectionSegment(shorthand.Start.StartIndex, shorthand.Stop.StopIndex); IdentifierValue identifier = new IdentifierValue(shorthand.identifier().GetText()); result.SetOwner(new OwnerSegment(shorthand.identifier().Start.StartIndex, shorthand.identifier().Stop.StopIndex, identifier)); return(result); } AliasSegment alias = null == context.alias() ? null : (AliasSegment)Visit(context.alias()); if (null != context.columnName()) { ColumnSegment column = (ColumnSegment)Visit(context.columnName()); ColumnProjectionSegment result = new ColumnProjectionSegment(column); result.SetAlias(alias); return(result); } return(CreateProjection(context, alias)); }
private ShorthandProjection CreateProjection(ICollection <SimpleTableSegment> tableSegments, ShorthandProjectionSegment projectionSegment) { var owner = projectionSegment.GetOwner()?.GetIdentifier().GetValue(); ICollection <ColumnProjection> columns = GetShorthandColumns(tableSegments, owner); return(new ShorthandProjection(owner, columns)); }