public override object VisitMethodDeclaration (ICSharpCode.NRefactory.Ast.MethodDeclaration methodDeclaration, object data) { DomMethod method = new DomMethod (); method.Name = methodDeclaration.Name; method.Documentation = RetrieveDocumentation (methodDeclaration.StartLocation.Line); method.Location = ConvertLocation (methodDeclaration.StartLocation); method.BodyRegion = ConvertRegion (methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new ICSharpCode.NRefactory.Location (-1, -1)); method.Modifiers = ConvertModifiers (methodDeclaration.Modifier); if (methodDeclaration.IsExtensionMethod) method.MethodModifier |= MethodModifier.IsExtension; method.ReturnType = ConvertReturnType (methodDeclaration.TypeReference); AddAttributes (method, methodDeclaration.Attributes); method.Add (ConvertParameterList (method, methodDeclaration.Parameters)); AddExplicitInterfaces (method, methodDeclaration.InterfaceImplementations); if (methodDeclaration.Templates != null && methodDeclaration.Templates.Count > 0) { foreach (ICSharpCode.NRefactory.Ast.TemplateDefinition template in methodDeclaration.Templates) { TypeParameter parameter = ConvertTemplateDefinition (template); method.AddTypeParameter (parameter); } } method.DeclaringType = typeStack.Peek (); typeStack.Peek ().Add (method); return null; }
private procedure_definition get_method_declaration(ICSharpCode.NRefactory.Ast.MethodDeclaration method) { procedure_definition proc = new procedure_definition(); proc.proc_header = get_method_header(method); proc.proc_body = get_body(method.Body); proc.source_context = new SourceContext(method.StartLocation.Line, method.StartLocation.Column, method.Body.EndLocation.Line, method.Body.EndLocation.Column); return(proc); }
public override object VisitMethodDeclaration(ICSharpCode.NRefactory.Ast.MethodDeclaration methodDeclaration, object data) { Debug.Assert(currentType.Count > 0); DomType type = currentType.Peek(); type.Add(new DomMethod(methodDeclaration.Name, (Modifiers)methodDeclaration.Modifier, MethodModifier.None, new DomLocation(methodDeclaration.StartLocation.Line, methodDeclaration.StartLocation.Column), methodDeclaration.Body != null ? TranslateRegion(methodDeclaration.Body.StartLocation, methodDeclaration.Body.EndLocation) : DomRegion.Empty)); return(null); }
private procedure_header get_method_header(ICSharpCode.NRefactory.Ast.MethodDeclaration method) { procedure_header proc_header; if (is_void(method.TypeReference)) { proc_header = new procedure_header(); } else { proc_header = new function_header(); } proc_header.name = new method_name(); proc_header.name.meth_name = new ident(method.Name); proc_header.source_context = get_source_context(method); if (proc_header is function_header) { (proc_header as function_header).return_type = get_type_reference(method.TypeReference); } proc_header.parameters = get_parameters(method.Parameters); proc_header.proc_attributes = new procedure_attributes_list(); if ((method.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Abstract) == ICSharpCode.NRefactory.Ast.Modifiers.Abstract) { proc_header.proc_attributes.proc_attributes.Add(new procedure_attribute(proc_attribute.attr_abstract)); } if ((method.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Virtual) == ICSharpCode.NRefactory.Ast.Modifiers.Virtual) { proc_header.proc_attributes.proc_attributes.Add(new procedure_attribute(proc_attribute.attr_virtual)); } if ((method.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Override) == ICSharpCode.NRefactory.Ast.Modifiers.Override) { proc_header.proc_attributes.proc_attributes.Add(new procedure_attribute(proc_attribute.attr_override)); } //if ((method.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Overloads) == ICSharpCode.NRefactory.Ast.Modifiers.Overloads) // proc_header.proc_attributes.proc_attributes.Add(new procedure_attribute(proc_attribute.attr_overload)); if ((method.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.New) == ICSharpCode.NRefactory.Ast.Modifiers.New) { proc_header.proc_attributes.proc_attributes.Add(new procedure_attribute(proc_attribute.attr_reintroduce)); } if ((method.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Static) == ICSharpCode.NRefactory.Ast.Modifiers.Static) { proc_header.class_keyword = true; } return(proc_header); }
private class_members get_class_member(ICSharpCode.NRefactory.Ast.INode node) { class_members cmem = new class_members(); if (node is ICSharpCode.NRefactory.Ast.FieldDeclaration) { ICSharpCode.NRefactory.Ast.FieldDeclaration fld = node as ICSharpCode.NRefactory.Ast.FieldDeclaration; cmem.access_mod = get_access_modifier(fld.Modifier); //if ((fld.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Const) == ICSharpCode.NRefactory.Ast.Modifiers.Const) //cmem.members.AddRange(get_const_declaration(fld)); //else cmem.members.AddRange(get_field_declaration(fld)); } else if (node is ICSharpCode.NRefactory.Ast.ConstructorDeclaration) { ICSharpCode.NRefactory.Ast.ConstructorDeclaration meth = node as ICSharpCode.NRefactory.Ast.ConstructorDeclaration; cmem.access_mod = get_access_modifier(meth.Modifier); cmem.members.Add(get_constructor_declaration(meth)); } else if (node is ICSharpCode.NRefactory.Ast.MethodDeclaration) { ICSharpCode.NRefactory.Ast.MethodDeclaration meth = node as ICSharpCode.NRefactory.Ast.MethodDeclaration; cmem.access_mod = get_access_modifier(meth.Modifier); if (!meth.Body.IsNull) { cmem.members.Add(get_method_declaration(meth)); } else { cmem.members.Add(get_method_header(meth)); } } return(cmem); /*else if (node is ICSharpCode.NRefactory.Ast.EventDeclaration) * { * ICSharpCode.NRefactory.Ast.EventDeclaration meth = node as ICSharpCode.NRefactory.Ast.EventDeclaration; * cmem.access_mod = get_access_modifier(meth.Modifier); * cmem.members.Add(get_event_declaration(meth)); * }*/ }
private void add_module_members(unit_module mod, ICSharpCode.NRefactory.Ast.TypeDeclaration td) { foreach (ICSharpCode.NRefactory.Ast.INode node in td.Children) { if (node is ICSharpCode.NRefactory.Ast.FieldDeclaration) { ICSharpCode.NRefactory.Ast.FieldDeclaration vd = node as ICSharpCode.NRefactory.Ast.FieldDeclaration; if ((vd.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Dim) == ICSharpCode.NRefactory.Ast.Modifiers.Dim) { foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration vard in vd.Fields) { var_def_statement vds = new var_def_statement(); vds.source_context = get_source_context(vd); vds.vars_type = get_type_reference(vard.TypeReference); ident_list idents = new ident_list(); ident name = new ident(vard.Name); name.source_context = vds.source_context; idents.idents.Add(name); vds.vars = idents; mod.interface_part.interface_definitions.defs.Add(vds); } } else if ((vd.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Const) == ICSharpCode.NRefactory.Ast.Modifiers.Const) { foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration vard in vd.Fields) { const_definition tcd = null; if (vard.TypeReference is ICSharpCode.NRefactory.Ast.TypeReference) { tcd = new simple_const_definition(); } else { tcd = new typed_const_definition(); } tcd.source_context = get_source_context(vd); if (tcd is typed_const_definition) { (tcd as typed_const_definition).const_type = get_type_reference(vard.TypeReference); } tcd.const_name = new ident(vard.Name); tcd.const_name.source_context = tcd.source_context; tcd.const_value = get_expression(vard.Initializer); mod.interface_part.interface_definitions.defs.Add(tcd); } } } else if (node is ICSharpCode.NRefactory.Ast.TypeDeclaration) { mod.interface_part.interface_definitions.defs.Add(get_type_declaration(node as ICSharpCode.NRefactory.Ast.TypeDeclaration)); } else if (node is ICSharpCode.NRefactory.Ast.MethodDeclaration) { ICSharpCode.NRefactory.Ast.MethodDeclaration meth = node as ICSharpCode.NRefactory.Ast.MethodDeclaration; if (!meth.Body.IsNull) { mod.interface_part.interface_definitions.defs.Add(get_method_declaration(meth)); } else { mod.interface_part.interface_definitions.defs.Add(get_method_header(meth)); } } } }