예제 #1
0
        /// <exception cref="BadSyntaxException">
        /// The <paramref name="declaration"/> does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        /// The parameter name is already exists.
        /// </exception>
        public override Parameter Add(string declaration)
        {
            var param = JavaParameterDeclaration.Create(declaration);

            if (IsReservedName(param.Name))
            {
                throw new ReservedNameException(param.Name);
            }

            var parameter = new JavaParameter(param.Name, param.Type);

            InnerList.Add(parameter);

            return(parameter);
        }
예제 #2
0
        /// <exception cref="BadSyntaxException">
        /// The <paramref name="declaration"/> does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        /// The parameter name is already exists.
        /// </exception>
        public override Parameter ModifyParameter(Parameter parameter, string declaration)
        {
            var param = JavaParameterDeclaration.Create(declaration);
            int index = InnerList.IndexOf(parameter);

            if (index < 0)
            {
                return(parameter);
            }

            if (IsReservedName(param.Name, index))
            {
                throw new ReservedNameException(param.Name);
            }

            var newParameter = new JavaParameter(param.Name, param.Type);

            InnerList[index] = newParameter;
            return(newParameter);
        }