public override IASTNode VisitColumnDefinition(SqlServerCommandParser.ColumnDefinitionContext context)
        {
            ColumnSegment           column       = (ColumnSegment)Visit(context.columnName());
            DataTypeSegment         dataType     = (DataTypeSegment)Visit(context.dataType());
            var                     isPrimaryKey = IsPrimaryKey(context);
            ColumnDefinitionSegment result       = new ColumnDefinitionSegment(
                context.Start.StartIndex, context.Stop.StopIndex, column, dataType, isPrimaryKey);

            foreach (var columnDefinitionOptionContext in context.columnDefinitionOption())
            {
                foreach (var columnConstraintContext in columnDefinitionOptionContext.columnConstraint())
                {
                    if (null != columnConstraintContext.columnForeignKeyConstraint())
                    {
                        result.ReferencedTables.Add((SimpleTableSegment)Visit(columnConstraintContext.columnForeignKeyConstraint().tableName()));
                    }
                }
            }

            foreach (var columnConstraintContext in context.columnConstraints().columnConstraint())
            {
                if (null != columnConstraintContext.columnForeignKeyConstraint())
                {
                    result.ReferencedTables.Add((SimpleTableSegment)Visit(columnConstraintContext.columnForeignKeyConstraint().tableName()));
                }
            }
            return(result);
        }
        public override IASTNode VisitModifyColumnSpecification(SqlServerCommandParser.ModifyColumnSpecificationContext context)
        {
            // TODO visit pk and table ref
            ColumnSegment           column           = (ColumnSegment)Visit(context.alterColumnOperation().columnName());
            DataTypeSegment         dataType         = (DataTypeSegment)Visit(context.dataType());
            ColumnDefinitionSegment columnDefinition = new ColumnDefinitionSegment(context.Start.StartIndex, context.Stop.StopIndex, column, dataType, false);

            return(new ModifyColumnDefinitionSegment(context.Start.StartIndex, context.Stop.StopIndex, columnDefinition));
        }
 public ModifyColumnDefinitionSegment(int startIndex, int stopIndex, ColumnDefinitionSegment columnDefinition)
 {
     _startIndex      = startIndex;
     _stopIndex       = stopIndex;
     ColumnDefinition = columnDefinition;
 }