Exemple #1
0
        void AddMethod(IClass parent, NavigationBarItem item, IDocument document)
        {
            var method = new DefaultMethod(parent, item.text);

            UpdateMethodRegions(method, item, document);
            parent.Methods.Add(method);
        }
Exemple #2
0
        public void FindAllMethodsFromArrayWithParameterCountReturnsExpectedMethods()
        {
            DefaultClass  c       = CreateClass();
            DefaultMethod method1 = new DefaultMethod(c, "abc");

            method1.Parameters.Add(CreateParameter("a"));

            DefaultMethod method2 = new DefaultMethod(c, "abc");

            method2.Parameters.Add(CreateParameter("a"));
            method2.Parameters.Add(CreateParameter("b"));

            DefaultMethod method3 = new DefaultMethod(c, "abc");

            method3.Parameters.Add(CreateParameter("c"));

            ArrayList items = new ArrayList();

            items.Add(method1);
            items.Add(method2);
            items.Add(method3);

            List <IMethod> expectedMethods = new List <IMethod>();

            expectedMethods.Add(method1);
            expectedMethods.Add(method3);

            int            parameterCount = 1;
            List <IMethod> methods        = PythonCompletionItemsHelper.FindAllMethodsFromCollection("abc", parameterCount, items);

            Assert.AreEqual(expectedMethods, methods);
        }
Exemple #3
0
        DefaultMethod MakeMethod(params object[] parameterTypesOrDefaultValues)
        {
            DefaultMethod m = new DefaultMethod(dummyClass, "Method");

            foreach (var typeOrDefaultValue in parameterTypesOrDefaultValues)
            {
                Type type = typeOrDefaultValue as Type;
                if (type != null)
                {
                    m.Parameters.Add(new DefaultParameter(type.ToTypeReference(), string.Empty));
                }
                else if (Type.GetTypeCode(typeOrDefaultValue.GetType()) > TypeCode.Object)
                {
                    m.Parameters.Add(new DefaultParameter(typeOrDefaultValue.GetType().ToTypeReference(), string.Empty)
                    {
                        DefaultValue = new SimpleConstantValue(typeOrDefaultValue.GetType().ToTypeReference(), typeOrDefaultValue)
                    });
                }
                else
                {
                    throw new ArgumentException(typeOrDefaultValue.ToString());
                }
            }
            return(m);
        }
        public DefaultMethod AddMethod(string name)
        {
            var method = new DefaultMethod(this, name);

            AddMethod(method);
            return(method);
        }
        public override IEntity VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
        {
            DefaultMethod m = new DefaultMethod(currentTypeDefinition, methodDeclaration.Name);

            currentMethod = m;             // required for resolving type parameters
            m.Region      = MakeRegion(methodDeclaration);
            m.BodyRegion  = MakeRegion(methodDeclaration.Body);


            ConvertTypeParameters(m.TypeParameters, methodDeclaration.TypeParameters, methodDeclaration.Constraints);
            m.ReturnType = ConvertType(methodDeclaration.ReturnType);
            ConvertAttributes(m.Attributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget != AttributeTarget.Return));
            ConvertAttributes(m.ReturnTypeAttributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget == AttributeTarget.Return));

            ApplyModifiers(m, methodDeclaration.Modifiers);
            m.IsExtensionMethod = methodDeclaration.IsExtensionMethod;

            ConvertParameters(m.Parameters, methodDeclaration.Parameters);
            if (!methodDeclaration.PrivateImplementationType.IsNull)
            {
                m.Accessibility = Accessibility.None;
                m.InterfaceImplementations.Add(ConvertInterfaceImplementation(methodDeclaration.PrivateImplementationType, m.Name));
            }

            currentTypeDefinition.Methods.Add(m);
            currentMethod = null;
            return(m);
        }
        LocalResolveResult CreateLocalResolveResult(string identifier, IClass resolvedClass)
        {
            DefaultMethod dummyMethod = CreateDummyMethod();

            DefaultField.LocalVariableField field = CreateLocalVariableField(identifier, resolvedClass, dummyMethod.DeclaringType);
            return(new LocalResolveResult(dummyMethod, field));
        }
Exemple #7
0
        DefaultMethod MakeParamsMethod(params object[] parameterTypesOrDefaultValues)
        {
            DefaultMethod m = MakeMethod(parameterTypesOrDefaultValues);

            ((DefaultParameter)m.Parameters.Last()).IsParams = true;
            return(m);
        }
Exemple #8
0
        public void AddMethod(JavaScriptGlobalClass c)
        {
            string        methodName = GetMethodName();
            DefaultMethod method     = c.AddMethod(methodName);

            UpdateRegions(method);
        }
Exemple #9
0
        void UpdateRegions(DefaultMethod method)
        {
            var methodRegion = new JavaScriptMethodRegion(ast, tree);

            method.Region     = methodRegion.GetHeaderRegion();
            method.BodyRegion = methodRegion.GetBodyRegion();
        }
        public DefaultMethod AddMethod(string name)
        {
            DefaultMethod method = new DefaultMethod(this, name);

            Methods.Add(method);
            return(method);
        }
        public override IEntity VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
        {
            Modifiers     modifiers = constructorDeclaration.Modifiers;
            bool          isStatic  = (modifiers & Modifiers.Static) != 0;
            DefaultMethod ctor      = new DefaultMethod(currentTypeDefinition, isStatic ? ".cctor" : ".ctor");

            ctor.EntityType = EntityType.Constructor;
            ctor.Region     = MakeRegion(constructorDeclaration);
            if (!constructorDeclaration.Initializer.IsNull)
            {
                ctor.BodyRegion = MakeRegion(constructorDeclaration.Initializer.StartLocation, constructorDeclaration.EndLocation);
            }
            else
            {
                ctor.BodyRegion = MakeRegion(constructorDeclaration.Body);
            }
            ctor.ReturnType = currentTypeDefinition;

            ConvertAttributes(ctor.Attributes, constructorDeclaration.Attributes);
            ConvertParameters(ctor.Parameters, constructorDeclaration.Parameters);

            if (isStatic)
            {
                ctor.IsStatic = true;
            }
            else
            {
                ApplyModifiers(ctor, modifiers);
            }

            currentTypeDefinition.Methods.Add(ctor);
            return(ctor);
        }
        public override object VisitMethodDeclaration(AST.MethodDeclaration methodDeclaration, object data)
        {
            DomRegion    region     = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
            DomRegion    bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : RefParser.Location.Empty);
            DefaultClass c          = GetCurrentClass();

            DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, GetCurrentClass());

            method.Documentation = GetDocumentation(region.BeginLine, methodDeclaration.Attributes);
            ConvertTemplates(methodDeclaration.Templates, method);
            method.ReturnType = CreateReturnType(methodDeclaration.TypeReference, method);
            ConvertAttributes(methodDeclaration, method);
            if (methodDeclaration.Parameters != null && methodDeclaration.Parameters.Count > 0)
            {
                foreach (AST.ParameterDeclarationExpression par in methodDeclaration.Parameters)
                {
                    method.Parameters.Add(CreateParameter(par, method));
                }
            }
            else
            {
                method.Parameters = DefaultParameter.EmptyParameterList;
            }
            c.Methods.Add(method);
            return(null);
        }
Exemple #13
0
        protected override void Walk(MethodDefinition methodDef)
        {
            IClass c = currentClass;

            if (currentClass == null)
            {
                // Walking a global method.
                CreateGlobalClass();
                c = globalClass;
            }

            // Create method.
            string    methodName = methodDef.Name;
            DomRegion region     = GetMethodRegion(methodDef);
            DomRegion bodyRegion = GetMethodBodyRegion(methodDef.Body.Location, region);

            DefaultMethod method;

            if (methodName == "initialize")
            {
                method = new Constructor(ModifierEnum.Public, region, bodyRegion, c);
            }
            else
            {
                method = new DefaultMethod(methodName, new DefaultReturnType(c), ModifierEnum.Public, region, bodyRegion, c);
            }
            foreach (IParameter parameter in ConvertParameters(methodDef.Parameters))
            {
                method.Parameters.Add(parameter);
            }
            c.Methods.Add(method);
        }
        public void ExpressionResultContextShowItemReturnsTrueForIMethod()
        {
            MockProjectContent     projectContent = new MockProjectContent();
            DefaultCompilationUnit unit           = new DefaultCompilationUnit(projectContent);
            DefaultClass           c      = new DefaultClass(unit, "MyClass");
            DefaultMethod          method = new DefaultMethod(c, "Test");

            Assert.IsTrue(expressionResult.Context.ShowEntry(method));
        }
Exemple #15
0
        void CreateResolver()
        {
            resolverHelper      = new PythonResolverTestsHelper();
            myClass             = resolverHelper.CreateClass("MyClass");
            myMethod            = myClass.AddMethod("MyMethod");
            myMethod.ReturnType = new DefaultReturnType(myClass);

            resolverHelper.ProjectContent.SetClassToReturnFromGetClass("MyClass", myClass);
        }
        /// <summary>
        /// Adds the 'Invoke', 'BeginInvoke', 'EndInvoke' methods, and a constructor, to the <paramref name="delegateType"/>.
        /// </summary>
        public static void AddDefaultMethodsToDelegate(DefaultTypeDefinition delegateType, ITypeReference returnType, IEnumerable <IParameter> parameters)
        {
            if (delegateType == null)
            {
                throw new ArgumentNullException("delegateType");
            }
            if (returnType == null)
            {
                throw new ArgumentNullException("returnType");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            DomRegion region = new DomRegion(delegateType.Region.FileName, delegateType.Region.BeginLine, delegateType.Region.BeginColumn);

            DefaultMethod invoke = new DefaultMethod(delegateType, "Invoke");

            invoke.Accessibility = Accessibility.Public;
            invoke.IsSynthetic   = true;
            invoke.Parameters.AddRange(parameters);
            invoke.ReturnType = returnType;
            invoke.Region     = region;
            delegateType.Methods.Add(invoke);

            DefaultMethod beginInvoke = new DefaultMethod(delegateType, "BeginInvoke");

            beginInvoke.Accessibility = Accessibility.Public;
            beginInvoke.IsSynthetic   = true;
            beginInvoke.Parameters.AddRange(invoke.Parameters);
            beginInvoke.Parameters.Add(delegateAsyncCallbackParameter);
            beginInvoke.Parameters.Add(delegateObjectParameter);
            beginInvoke.ReturnType = delegateResultParameter.Type;
            beginInvoke.Region     = region;
            delegateType.Methods.Add(beginInvoke);

            DefaultMethod endInvoke = new DefaultMethod(delegateType, "EndInvoke");

            endInvoke.Accessibility = Accessibility.Public;
            endInvoke.IsSynthetic   = true;
            endInvoke.Parameters.Add(delegateResultParameter);
            endInvoke.ReturnType = invoke.ReturnType;
            endInvoke.Region     = region;
            delegateType.Methods.Add(endInvoke);

            DefaultMethod ctor = new DefaultMethod(delegateType, ".ctor");

            ctor.EntityType    = EntityType.Constructor;
            ctor.Accessibility = Accessibility.Public;
            ctor.IsSynthetic   = true;
            ctor.Parameters.Add(delegateObjectParameter);
            ctor.Parameters.Add(delegateIntPtrMethodParameter);
            ctor.ReturnType = delegateType;
            ctor.Region     = region;
            delegateType.Methods.Add(ctor);
        }
Exemple #17
0
        void UpdateMethodRegions(DefaultMethod method, NavigationBarItem item, IDocument document)
        {
            DomRegion region = item.ToRegionStartingFromOpeningCurlyBrace(document);

            method.Region = new DomRegion(
                region.BeginLine,
                region.BeginColumn,
                region.BeginLine,
                region.BeginColumn);
            method.BodyRegion = region;
        }
Exemple #18
0
        public void FindMethodFromArrayReturnsExpectedMethod()
        {
            DefaultClass  c      = CreateClass();
            DefaultMethod method = new DefaultMethod(c, "abc");

            ArrayList items = new ArrayList();

            items.Add(method);

            Assert.AreEqual(method, PythonCompletionItemsHelper.FindMethodFromCollection("abc", items));
        }
Exemple #19
0
 void ConvertParameters(AST.ParameterDeclarationCollection parameters, DefaultMethod m)
 {
     if (parameters == null || parameters.Count == 0)
     {
         m.Parameters = DefaultParameter.EmptyParameterList;
     }
     else
     {
         AddParameters(parameters, m.Parameters, m, m.DeclaringType);
     }
 }
Exemple #20
0
        public void FindMethodFromArrayReturnsNullForUnknownMethod()
        {
            DefaultClass  c      = new DefaultClass(new DefaultCompilationUnit(new DefaultProjectContent()), "Test");
            DefaultMethod method = new DefaultMethod(c, "abc");

            ArrayList items = new ArrayList();

            items.Add(method);

            Assert.IsNull(PythonCompletionItemsHelper.FindMethodFromCollection("unknown", items));
        }
 private WrapperGenerator(object[] partDefinitions, Func <object, IEnumerable <object> > getWrappers)
 {
     object[] flatDefinitions = Flatten(partDefinitions).ToArray();
     this.partDefinitions = flatDefinitions;
     this.getWrappers     = getWrappers;
     defaultProperty      = partDefinitions.OfType <DefaultProperty>().SingleOrDefault();
     defaultMethod        = partDefinitions.OfType <DefaultMethod>().SingleOrDefault();
     this.partDefinitions = this.partDefinitions
                            .Concat(GetDefaultProperties(flatDefinitions.OfType <PropertyDefinition>()))
                            .Concat(GetDefaultMethods())
                            .ToArray();
 }
        /// <summary>
        /// Gets a method implementing the signature specified by the event descriptor
        /// </summary>
        protected static IMethod ConvertEventInvokeMethodToDom(IClass declaringType, Type eventType, string methodName)
        {
            MethodInfo    mInfo = eventType.GetMethod("Invoke");
            DefaultMethod m     = new DefaultMethod(declaringType, methodName);

            m.ReturnType = ReflectionLayer.ReflectionReturnType.Create(m, mInfo.ReturnType);
            foreach (ParameterInfo pInfo in mInfo.GetParameters())
            {
                m.Parameters.Add(new ReflectionLayer.ReflectionParameter(pInfo, m));
            }
            return(m);
        }
        public override object VisitMethodDeclaration(AST.MethodDeclaration methodDeclaration, object data)
        {
            DomRegion    region       = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
            DomRegion    bodyRegion   = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : RefParser.Location.Empty);
            DefaultClass currentClass = GetCurrentClass();

            DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, currentClass);

            method.Documentation = GetDocumentation(region.BeginLine, methodDeclaration.Attributes);
            ConvertTemplates(methodDeclaration.Templates, method);
            method.ReturnType = CreateReturnType(methodDeclaration.TypeReference, method, TypeVisitor.ReturnTypeOptions.None);
            ConvertAttributes(methodDeclaration, method);
            method.IsExtensionMethod = methodDeclaration.IsExtensionMethod ||
                                       method.Attributes.Any(att => att.AttributeType != null && att.AttributeType.FullyQualifiedName == "System.Runtime.CompilerServices.ExtensionAttribute");
            if (methodDeclaration.Parameters.Count > 0)
            {
                foreach (AST.ParameterDeclarationExpression par in methodDeclaration.Parameters)
                {
                    method.Parameters.Add(CreateParameter(par, method));
                }
            }
            else
            {
                method.Parameters = DefaultParameter.EmptyParameterList;
            }
            if (methodDeclaration.HandlesClause.Count > 0)
            {
                foreach (string handlesClause in methodDeclaration.HandlesClause)
                {
                    if (handlesClause.ToLowerInvariant().StartsWith("me."))
                    {
                        method.HandlesClauses.Add(handlesClause.Substring(3));
                    }
                    else if (handlesClause.ToLowerInvariant().StartsWith("mybase."))
                    {
                        method.HandlesClauses.Add(handlesClause.Substring(7));
                    }
                    else
                    {
                        method.HandlesClauses.Add(handlesClause);
                    }
                }
            }
            else
            {
                method.HandlesClauses = EmptyList <string> .Instance;
            }

            AddInterfaceImplementations(method, methodDeclaration);

            currentClass.Methods.Add(method);
            return(null);
        }
        public override object VisitEventDeclaration(NRefactoryAST.EventDeclaration eventDeclaration, object data)
        {
            DomRegion    region     = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation);
            DomRegion    bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd);
            DefaultClass c          = GetCurrentClass();

            IReturnType type;

            if (eventDeclaration.TypeReference.IsNull)
            {
                DefaultClass del = new DefaultClass(cu, ClassType.Delegate,
                                                    ConvertModifier(eventDeclaration.Modifier),
                                                    region, c);
                del.Modifiers |= ModifierEnum.Synthetic;
                CreateDelegate(del, eventDeclaration.Name + "EventHandler",
                               new NRefactoryAST.TypeReference("System.Void", true),
                               new NRefactoryAST.TemplateDefinition[0],
                               eventDeclaration.Parameters);
                type = del.DefaultReturnType;
            }
            else
            {
                type = CreateReturnType(eventDeclaration.TypeReference);
            }
            DefaultEvent e = new DefaultEvent(eventDeclaration.Name, type, ConvertModifier(eventDeclaration.Modifier), region, bodyRegion, c);

            ConvertAttributes(eventDeclaration, e);
            c.Events.Add(e);

            e.Documentation = GetDocumentation(region.BeginLine, eventDeclaration.Attributes);
            if (eventDeclaration.HasAddRegion)
            {
                var defaultMethod     = new DefaultMethod(e.DeclaringType, "add_" + e.Name);
                var defaultParameters = new List <IParameter>();
                defaultParameters.Add(new DefaultParameter("value", e.ReturnType, DomRegion.Empty));
                defaultMethod.Parameters = defaultParameters;
                defaultMethod.Region     = GetRegion(eventDeclaration.AddRegion.StartLocation, eventDeclaration.AddRegion.EndLocation);
                defaultMethod.BodyRegion = GetRegion(eventDeclaration.AddRegion.Block.StartLocation, eventDeclaration.AddRegion.Block.EndLocation);
                e.AddMethod = defaultMethod;
            }
            if (eventDeclaration.HasRemoveRegion)
            {
                var defaultMethod     = new DefaultMethod(e.DeclaringType, "remove_" + e.Name);
                var defaultParameters = new List <IParameter>();
                defaultParameters.Add(new DefaultParameter("value", e.ReturnType, DomRegion.Empty));
                defaultMethod.Parameters = defaultParameters;
                defaultMethod.Region     = GetRegion(eventDeclaration.RemoveRegion.StartLocation, eventDeclaration.RemoveRegion.EndLocation);
                defaultMethod.BodyRegion = GetRegion(eventDeclaration.RemoveRegion.Block.StartLocation, eventDeclaration.RemoveRegion.Block.EndLocation);
                e.RemoveMethod           = defaultMethod;
            }
            return(null);
        }
 internal static void ApplySpecialsFromAttributes(DefaultMethod m)
 {
     if (m.IsStatic) {
         foreach (IAttribute a in m.Attributes) {
             string attributeName = a.AttributeType.FullyQualifiedName;
             if (attributeName == "System.Runtime.CompilerServices.ExtensionAttribute"
                 || attributeName == "Boo.Lang.ExtensionAttribute")
             {
                 m.IsExtensionMethod = true;
             }
         }
     }
 }
Exemple #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:AppAiCorp.Implements.RemPost"/> class.
        /// </summary>
        /// <param name="httpContext">Http context.</param>
        /// <param name="url">URL.</param>
        /// <param name="method">Method.</param>

        public Remote(HttpContext httpContext, string url, DefaultMethod method) : this(httpContext)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url Error!");
            }

            if (httpContext.Equals(null))
            {
                throw new ArgumentNullException("httpContext Error!");
            }

            Url    = url;
            Method = method;
        }
 internal static void ApplySpecialsFromAttributes(DefaultMethod m)
 {
     if (m.IsStatic)
     {
         foreach (IAttribute a in m.Attributes)
         {
             string attributeName = a.Name;
             if (attributeName == "System.Runtime.CompilerServices.ExtensionAttribute" ||
                 attributeName == "Boo.Lang.ExtensionAttribute")
             {
                 m.IsExtensionMethod = true;
             }
         }
     }
 }
Exemple #28
0
        void ConvertTemplates(List <AST.TemplateDefinition> templateList, DefaultMethod m)
        {
            int index = 0;

            if (templateList.Count == 0)
            {
                m.TypeParameters = DefaultTypeParameter.EmptyTypeParameterList;
            }
            else
            {
                foreach (AST.TemplateDefinition template in templateList)
                {
                    m.TypeParameters.Add(ConvertConstraints(template, new DefaultTypeParameter(m, template.Name, index++)));
                }
            }
        }
        public override IEntity VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
        {
            DefaultMethod dtor = new DefaultMethod(currentTypeDefinition, "Finalize");

            dtor.EntityType    = EntityType.Destructor;
            dtor.Region        = MakeRegion(destructorDeclaration);
            dtor.BodyRegion    = MakeRegion(destructorDeclaration.Body);
            dtor.Accessibility = Accessibility.Protected;
            dtor.IsOverride    = true;
            dtor.ReturnType    = KnownTypeReference.Void;

            ConvertAttributes(dtor.Attributes, destructorDeclaration.Attributes);

            currentTypeDefinition.Methods.Add(dtor);
            return(dtor);
        }
Exemple #30
0
        public void Init()
        {
            DefaultProjectContent projectContent = new DefaultProjectContent();

            unit = new DefaultCompilationUnit(projectContent);
            DefaultClass c = new DefaultClass(unit, "Foo");

            DefaultMethod buttonClickMethod = new DefaultMethod(c, "ButtonClick");

            AddSenderAndEventArgsParameters(buttonClickMethod);
            c.Methods.Add(buttonClickMethod);

            projectContent.AddClassToNamespaceList(c);

            parseInfo = new ParseInformation(unit);
        }
Exemple #31
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);
     }
 }
		public override object VisitOperatorDeclaration(AST.OperatorDeclaration operatorDeclaration, object data)
		{
			DefaultClass c  = GetCurrentClass();
			DomRegion region     = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation);
			DomRegion bodyRegion = GetRegion(operatorDeclaration.EndLocation, operatorDeclaration.Body != null ? operatorDeclaration.Body.EndLocation : RefParser.Location.Empty);
			
			DefaultMethod method = new DefaultMethod(operatorDeclaration.Name, CreateReturnType(operatorDeclaration.TypeReference), ConvertModifier(operatorDeclaration.Modifier), region, bodyRegion, c);
			ConvertAttributes(operatorDeclaration, method);
			if(operatorDeclaration.Parameters != null)
			{
				foreach (AST.ParameterDeclarationExpression par in operatorDeclaration.Parameters) {
					method.Parameters.Add(CreateParameter(par, method));
				}
			}
			AddInterfaceImplementations(method, operatorDeclaration);
			c.Methods.Add(method);
			return null;
		}
		public override object VisitDeclareDeclaration(AST.DeclareDeclaration declareDeclaration, object data)
		{
			DefaultClass currentClass = GetCurrentClass();
			
			DomRegion region = GetRegion(declareDeclaration.StartLocation, declareDeclaration.EndLocation);
			DefaultMethod method = new DefaultMethod(declareDeclaration.Name, null, ConvertModifier(declareDeclaration.Modifier), region, DomRegion.Empty, currentClass);
			method.Documentation = GetDocumentation(region.BeginLine, declareDeclaration.Attributes);
			method.Modifiers |= ModifierEnum.Extern | ModifierEnum.Static;
			
			method.ReturnType = CreateReturnType(declareDeclaration.TypeReference, method, TypeVisitor.ReturnTypeOptions.None);
			ConvertAttributes(declareDeclaration, method);
			
			foreach (AST.ParameterDeclarationExpression par in declareDeclaration.Parameters) {
				method.Parameters.Add(CreateParameter(par, method));
			}
			
			currentClass.Methods.Add(method);
			return null;
		}
		public override object VisitMethodDeclaration(AST.MethodDeclaration methodDeclaration, object data)
		{
			DomRegion region     = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
			DomRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : RefParser.Location.Empty);
			DefaultClass currentClass = GetCurrentClass();
			
			DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, currentClass);
			method.Documentation = GetDocumentation(region.BeginLine, methodDeclaration.Attributes);
			ConvertTemplates(methodDeclaration.Templates, method);
			method.ReturnType = CreateReturnType(methodDeclaration.TypeReference, method, TypeVisitor.ReturnTypeOptions.None);
			ConvertAttributes(methodDeclaration, method);
			method.IsExtensionMethod = methodDeclaration.IsExtensionMethod
				|| method.Attributes.Any(att => att.AttributeType != null && att.AttributeType.FullyQualifiedName == "System.Runtime.CompilerServices.ExtensionAttribute");
			if (methodDeclaration.Parameters.Count > 0) {
				foreach (AST.ParameterDeclarationExpression par in methodDeclaration.Parameters) {
					method.Parameters.Add(CreateParameter(par, method));
				}
			} else {
				method.Parameters = DefaultParameter.EmptyParameterList;
			}
			if (methodDeclaration.HandlesClause.Count > 0) {
				foreach (string handlesClause in methodDeclaration.HandlesClause) {
					if (handlesClause.ToLowerInvariant().StartsWith("me."))
						method.HandlesClauses.Add(handlesClause.Substring(3));
					else if (handlesClause.ToLowerInvariant().StartsWith("mybase."))
						method.HandlesClauses.Add(handlesClause.Substring(7));
					else
						method.HandlesClauses.Add(handlesClause);
				}
			} else {
				method.HandlesClauses = EmptyList<string>.Instance;
			}

			AddInterfaceImplementations(method, methodDeclaration);
			
			currentClass.Methods.Add(method);
			return null;
		}
		void ConvertTemplates(List<AST.TemplateDefinition> templateList, DefaultMethod m)
		{
			int index = 0;
			if (templateList.Count == 0) {
				m.TypeParameters = DefaultTypeParameter.EmptyTypeParameterList;
			} else {
				Debug.Assert(m.TypeParameters.Count == 0);
				foreach (AST.TemplateDefinition template in templateList) {
					m.TypeParameters.Add(new DefaultTypeParameter(m, template.Name, index++));
				}
				// converting the constraints requires that the type parameters are already present
				for (int i = 0; i < templateList.Count; i++) {
					ConvertConstraints(templateList[i], (DefaultTypeParameter)m.TypeParameters[i]);
				}
			}
		}
		void ConvertTemplates(List<AST.TemplateDefinition> templateList, DefaultMethod m)
		{
			int index = 0;
			if (templateList.Count == 0) {
				m.TypeParameters = DefaultTypeParameter.EmptyTypeParameterList;
			} else {
				foreach (AST.TemplateDefinition template in templateList) {
					m.TypeParameters.Add(ConvertConstraints(template, new DefaultTypeParameter(m, template.Name, index++)));
				}
			}
		}
		public override object VisitMethodDeclaration(AST.MethodDeclaration methodDeclaration, object data)
		{
			DomRegion region     = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
			DomRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : RefParser.Location.Empty);
			DefaultClass c  = GetCurrentClass();
			
			DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
			method.Documentation = GetDocumentation(region.BeginLine, methodDeclaration.Attributes);
			ConvertTemplates(methodDeclaration.Templates, method);
			method.ReturnType = CreateReturnType(methodDeclaration.TypeReference, method);
			ConvertAttributes(methodDeclaration, method);
			if (methodDeclaration.Parameters != null && methodDeclaration.Parameters.Count > 0) {
				foreach (AST.ParameterDeclarationExpression par in methodDeclaration.Parameters) {
					method.Parameters.Add(CreateParameter(par, method));
				}
			} else {
				method.Parameters = DefaultParameter.EmptyParameterList;
			}
			c.Methods.Add(method);
			return null;
		}
		public override object VisitEventDeclaration(AST.EventDeclaration eventDeclaration, object data)
		{
			DomRegion region     = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation);
			DomRegion bodyRegion = GetRegion(eventDeclaration.BodyStart,     eventDeclaration.BodyEnd);
			DefaultClass c = GetCurrentClass();
			
			IReturnType type;
			if (eventDeclaration.TypeReference.IsNull) {
				DefaultClass del = new DefaultClass(cu, ClassType.Delegate,
				                                    ConvertModifier(eventDeclaration.Modifier),
				                                    region, c);
				del.Modifiers |= ModifierEnum.Synthetic;
				CreateDelegate(del, eventDeclaration.Name + "EventHandler",
				               new AST.TypeReference("System.Void", true),
				               new AST.TemplateDefinition[0],
				               eventDeclaration.Parameters);
				type = del.DefaultReturnType;
			} else {
				type = CreateReturnType(eventDeclaration.TypeReference);
			}
			DefaultEvent e = new DefaultEvent(eventDeclaration.Name, type, ConvertModifier(eventDeclaration.Modifier), region, bodyRegion, c);
			ConvertAttributes(eventDeclaration, e);
			c.Events.Add(e);
			
			e.Documentation = GetDocumentation(region.BeginLine, eventDeclaration.Attributes);
			if (eventDeclaration.HasAddRegion) 
			{
				var defaultMethod = new DefaultMethod(e.DeclaringType, "add_" + e.Name);
				defaultMethod.Parameters = new List<IParameter>().add(new DefaultParameter("value", e.ReturnType, DomRegion.Empty));
				defaultMethod.Region = GetRegion(eventDeclaration.AddRegion.StartLocation, eventDeclaration.AddRegion.EndLocation);
				defaultMethod.BodyRegion = GetRegion(eventDeclaration.AddRegion.Block.StartLocation, eventDeclaration.AddRegion.Block.EndLocation);				
				e.AddMethod = defaultMethod;
			}
			if (eventDeclaration.HasRemoveRegion) 
			{
				var defaultMethod = new DefaultMethod(e.DeclaringType, "remove_" + e.Name);
				defaultMethod.Parameters = new List<IParameter>().add(new DefaultParameter("value", e.ReturnType, DomRegion.Empty) );
				defaultMethod.Region = GetRegion(eventDeclaration.RemoveRegion.StartLocation, eventDeclaration.RemoveRegion.EndLocation);
				defaultMethod.BodyRegion = GetRegion(eventDeclaration.RemoveRegion.Block.StartLocation, eventDeclaration.RemoveRegion.Block.EndLocation);				
				e.RemoveMethod = defaultMethod;
			}
			return null;
		}