/// <summary>
        /// : parameter_name(IN | OUT | INOUT | NOCOPY) * type_spec? default_value_part ?
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override object VisitParameter([NotNull] PlSqlParser.ParameterContext context)
        {
            bool _in  = context.IN() != null;
            bool _out = context.OUT() != null;

            if (context.INOUT() != null)
            {
                _in = _out = true;
            }
            bool _nocopy = context.NOCOPY() != null;

            OTypeReference type      = null;
            var            type_spec = context.type_spec();

            if (type_spec != null)
            {
                type = (OTypeReference)VisitType_spec(type_spec);
            }

            var arg = new ArgumentModel()
            {
                //Key = method.Arguments.Count().ToString(),
                Name        = context.parameter_name().GetCleanedName(),
                In          = _in,
                Out         = _out,
                Description = string.Empty,
            };

            if (type != null)
            {
                arg.Type = type;
            }

            return(arg);
        }
Exemplo n.º 2
0
        public static RoutineParameter Routine(PlSqlParser.ParameterContext context)
        {
            var paramName = Name.Simple(context.parameter_name());
            var paramType = SqlTypeParser.Parse(context.datatype());

            var paramDir = ParameterDirection.Input;

            if (context.IN() != null)
            {
                if (context.OUT() != null)
                {
                    paramDir = ParameterDirection.InputOutput;
                }
                else
                {
                    paramDir = ParameterDirection.Input;
                }
            }
            else if (context.OUT() != null)
            {
                paramDir = ParameterDirection.Output;
            }
            else if (context.INOUT() != null)
            {
                paramDir = ParameterDirection.InputOutput;
            }

            SqlExpression defaultValue = null;
            var           defaultPart  = context.defaultValuePart();

            if (defaultPart != null)
            {
                defaultValue = Expression.Build(defaultPart.expression());
            }

            // TODO: Support default in RoutineParameter
            return(new RoutineParameter(paramName, paramType, paramDir));
        }