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); } }
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); } }
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); }
void ReadAttributes(DefaultParameter parameter) { int count = reader.ReadUInt16(); if (count > 0) { ReadAttributes(parameter.Attributes, count); } else { parameter.Attributes = DefaultAttribute.EmptyAttributeList; } }
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); }
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(); }
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); } }
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); } }
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; } }
/// <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); } }
/// <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(); }