예제 #1
0
 void AddParameters(IMethodOrProperty target, ParameterDefinitionCollection plist)
 {
     foreach (ParameterDefinition par in plist)
     {
         IReturnType      pReturnType = CreateType(this.ProjectContent, target, par.ParameterType);
         DefaultParameter p           = new DefaultParameter(par.Name, pReturnType, DomRegion.Empty);
         if ((par.Attributes & ParameterAttributes.Out) == ParameterAttributes.Out)
         {
             p.Modifiers = ParameterModifiers.Out;
         }
         else if (par.ParameterType is ReferenceType)
         {
             p.Modifiers = ParameterModifiers.Ref;
         }
         else
         {
             p.Modifiers = ParameterModifiers.In;
         }
         if ((par.Attributes & ParameterAttributes.Optional) == ParameterAttributes.Optional)
         {
             p.Modifiers |= ParameterModifiers.Optional;
         }
         if (p.ReturnType.IsArrayReturnType)
         {
             foreach (CustomAttribute att in par.CustomAttributes)
             {
                 if (att.Constructor.DeclaringType.FullName == typeof(ParamArrayAttribute).FullName)
                 {
                     p.Modifiers |= ParameterModifiers.Params;
                 }
             }
         }
         target.Parameters.Add(p);
     }
 }
예제 #2
0
 void ReadParameters(IList <IParameter> parameters, int count)
 {
     for (int i = 0; i < count; i++)
     {
         string           name = ReadString();
         DefaultParameter p    = new DefaultParameter(name, ReadType(), DomRegion.Empty);
         p.Modifiers = (ParameterModifiers)reader.ReadByte();
         ReadAttributes(p);
         parameters.Add(p);
     }
 }
예제 #3
0
        public override IMember Clone()
        {
            DefaultProperty p = new DefaultProperty(Name, ReturnType, Modifiers, Region, BodyRegion, DeclaringType);

            p.parameters  = DefaultParameter.Clone(this.Parameters);
            p.accessFlags = this.accessFlags;
            foreach (ExplicitInterfaceImplementation eii in InterfaceImplementations)
            {
                p.InterfaceImplementations.Add(eii.Clone());
            }
            return(p);
        }
예제 #4
0
            void ReadAttributes(DefaultParameter parameter)
            {
                int count = reader.ReadUInt16();

                if (count > 0)
                {
                    ReadAttributes(parameter.Attributes, count);
                }
                else
                {
                    parameter.Attributes = DefaultAttribute.EmptyAttributeList;
                }
            }
예제 #5
0
        public override IMember Clone()
        {
            DefaultMethod p = new DefaultMethod(Name, ReturnType, Modifiers, Region, BodyRegion, DeclaringType);

            p.parameters     = DefaultParameter.Clone(this.Parameters);
            p.typeParameters = new List <ITypeParameter>(this.typeParameters);
            p.CopyDocumentationFrom(this);
            p.isExtensionMethod = this.isExtensionMethod;
            foreach (ExplicitInterfaceImplementation eii in InterfaceImplementations)
            {
                p.InterfaceImplementations.Add(eii.Clone());
            }
            return(p);
        }
예제 #6
0
		IParameter[] ConvertParameters(IList<Parameter> parameters, int startingIndex)
		{
			List<IParameter> convertedParameters = new List<IParameter>();
			for (int i = startingIndex; i < parameters.Count; ++i) {				
				DefaultParameter parameter = new DefaultParameter(parameters[i].Name, null, new DomRegion());
				convertedParameters.Add(parameter);
			}
			return convertedParameters.ToArray();
		}
예제 #7
0
 void AddParameters(IMethodOrProperty target, Collection<ParameterDefinition> plist)
 {
     foreach (ParameterDefinition par in plist) {
         IReturnType pReturnType = CreateType(this.ProjectContent, target, par.ParameterType);
         DefaultParameter p = new DefaultParameter(par.Name, pReturnType, DomRegion.Empty);
         if (par.ParameterType is ByReferenceType)
         {
             if ((par.Attributes & ParameterAttributes.Out) == ParameterAttributes.Out) {
                 p.Modifiers = ParameterModifiers.Out;
             } else {
                 p.Modifiers = ParameterModifiers.Ref;
             }
         } else {
             p.Modifiers = ParameterModifiers.In;
         }
         if ((par.Attributes & ParameterAttributes.Optional) == ParameterAttributes.Optional) {
             p.Modifiers |= ParameterModifiers.Optional;
         }
         if (p.ReturnType.IsArrayReturnType) {
             foreach (CustomAttribute att in par.CustomAttributes) {
                 if (att.Constructor.DeclaringType.FullName == typeof(ParamArrayAttribute).FullName) {
                     p.Modifiers |= ParameterModifiers.Params;
                 }
             }
         }
         target.Parameters.Add(p);
     }
 }
예제 #8
0
		internal static IParameter CreateParameter(NRefactoryAST.ParameterDeclarationExpression par, IMethod method, IClass currentClass, ICompilationUnit cu)
		{
			IReturnType parType = CreateReturnType(par.TypeReference, method, currentClass, cu, TypeVisitor.ReturnTypeOptions.None);
			DefaultParameter p = new DefaultParameter(par.ParameterName, parType, GetRegion(par.StartLocation, par.EndLocation));
			p.Modifiers = (ParameterModifiers)par.ParamModifier;
			return p;
		}
			void ReadParameters(IList<IParameter> parameters, int count)
			{
				for (int i = 0; i < count; i++) {
					string name = ReadString();
					DefaultParameter p = new DefaultParameter(name, ReadType(), DomRegion.Empty);
					p.Modifiers = (ParameterModifiers)reader.ReadByte();
					ReadAttributes(p);
					parameters.Add(p);
				}
			}
			void ReadAttributes(DefaultParameter parameter)
			{
				int count = reader.ReadUInt16();
				if (count > 0) {
					ReadAttributes(parameter.Attributes, count);
				} else {
					parameter.Attributes = DefaultAttribute.EmptyAttributeList;
				}
			}
예제 #11
0
		internal static void AddParameters(AST.ParameterDeclarationCollection parameters, IList<IParameter> output, IMethodOrProperty method, IClass c)
		{
			if (c == null) throw new ArgumentNullException("c");
			DefaultParameter p = null;
			foreach (AST.ParameterDeclaration par in parameters) {
				p = new DefaultParameter(par.Name,
				                         CreateReturnType(par.Type, c, method as IMethod, c.Region.BeginLine + 1, 1, c.ProjectContent),
				                         new DomRegion(par.LexicalInfo.Line, par.LexicalInfo.Column));
				if (par.IsByRef) p.Modifiers |= ParameterModifiers.Ref;
				output.Add(p);
			}
			if (parameters.HasParamArray) {
				p.Modifiers |= ParameterModifiers.Params;
			}
		}
예제 #12
0
 /// <summary>
 /// Copies methods from one class to another.
 /// </summary>
 /// <param name="oldClass">Source class</param>
 /// <param name="newClass">Target class</param>		
 private void copyMethods(IClass oldClass, IClass newClass)
 {
     foreach(IMethod element in oldClass.Methods){
         DefaultMethod newMethod = new DefaultMethod(element.Name,element.ReturnType,
                                       				element.Modifiers,element.Region,element.BodyRegion,newClass);
         foreach(IParameter param in element.Parameters){
             DefaultParameter newParam = new DefaultParameter(param);
             newMethod.Parameters.Add(newParam);
         }
         newMethod.BodyRegion = new DomRegion(element.BodyRegion.BeginLine,element.BodyRegion.BeginColumn,
                                              element.BodyRegion.EndLine,element.BodyRegion.EndColumn);
         newClass.Methods.Add(newMethod);
     }
 }
예제 #13
0
		/// <summary>
		/// Converts from Ruby AST expressions to parameters.
		/// </summary>
		IParameter[] ConvertParameters(Parameters parameters)
		{
			List<IParameter> convertedParameters = new List<IParameter>();
			foreach (LocalVariable variable in GetParameterVariables(parameters)) {
				DefaultParameter parameter = new DefaultParameter(variable.Name, null, new DomRegion());
				convertedParameters.Add(parameter);
			}
			return convertedParameters.ToArray();
		}