Пример #1
0
 /// <summary>
 /// Adds a method parameter to this method
 /// </summary>
 /// <param name="parameter">The parameter to add</param>
 public void AddMethodParameter(ParameterDeclaration parameter) {
     parameter.Scope = this;
     _parameters.Add(parameter);
 }
Пример #2
0
        /// <summary>
        /// Generates a parameter declaration for the given declaration
        /// </summary>
        /// <param name="declElement">The declaration XElement from within the parameter element. Must be a <see cref="ABB.SrcML.SRC.Declaration"/> or <see cref="ABB.SrcML.SRC.FunctionDeclaration"/></param>
        /// <param name="context">the parser context</param>
        /// <returns>A parameter declaration object</returns>
        public virtual ParameterDeclaration ParseMethodParameterElement(XElement declElement, ParserContext context) {
            if(declElement == null) throw new ArgumentNullException("declElement");
            if(declElement.Name != SRC.Declaration && declElement.Name != SRC.FunctionDeclaration) throw new ArgumentException("must be of element type SRC.Declaration or SRC.FunctionDeclaration", "declElement");

            var typeElement = declElement.Element(SRC.Type);
            var nameElement = declElement.Element(SRC.Name);
            var name = (nameElement == null ? String.Empty : nameElement.Value);

            var parameterDeclaration = new ParameterDeclaration {
                VariableType = ParseTypeUseElement(typeElement, context),
                Name = name,
                Scope = context.CurrentScope
            };
            parameterDeclaration.Locations.Add(context.CreateLocation(declElement));
            return parameterDeclaration;
        }