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));
        }
Пример #2
0
        private ColumnProjection CreateProjection(ColumnProjectionSegment projectionSegment)
        {
            String owner = projectionSegment.GetColumn().GetOwner()?.GetIdentifier().GetValue();

            return(new ColumnProjection(owner, projectionSegment.GetColumn().GetIdentifier().GetValue(), projectionSegment.GetAlias()));
        }