public override object VisitFieldDeclaration (ICSharpCode.NRefactory.Ast.FieldDeclaration fieldDeclaration, object data) { foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration varDecl in fieldDeclaration.Fields) { DomField field = new DomField (); field.Name = varDecl.Name; field.Documentation = RetrieveDocumentation (fieldDeclaration.StartLocation.Line); field.Location = ConvertLocation (fieldDeclaration.StartLocation); field.BodyRegion = ConvertRegion (varDecl.StartLocation, varDecl.EndLocation); field.Modifiers = ConvertModifiers (fieldDeclaration.Modifier); if (typeStack.Peek ().ClassType == ClassType.Enum) { field.ReturnType = new DomReturnType (typeStack.Peek ()); } else { field.ReturnType = ConvertReturnType (fieldDeclaration.TypeReference); } // Enum fields have an empty type. if (field.ReturnType != null && string.IsNullOrEmpty (field.ReturnType.FullName)) field.ReturnType = null; AddAttributes (field, fieldDeclaration.Attributes); field.DeclaringType = typeStack.Peek (); if (field.DeclaringType.ClassType == ClassType.Enum) { field.Modifiers |= Modifiers.Const; field.Modifiers |= Modifiers.SpecialName; field.Modifiers |= Modifiers.Public; } typeStack.Peek ().Add (field); } return null; }
public override object VisitFieldDeclaration(ICSharpCode.NRefactory.Ast.FieldDeclaration fieldDeclaration, object data) { Debug.Assert(currentType.Count > 0); DomType type = currentType.Peek(); foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration field in fieldDeclaration.Fields) { type.Add(new DomField(field.Name, (Modifiers)fieldDeclaration.Modifier, new DomLocation(fieldDeclaration.StartLocation.Line, fieldDeclaration.StartLocation.Column), TranslateTypeReference(fieldDeclaration.TypeReference))); } return(null); }
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 enum_type_definition get_enum_type(ICSharpCode.NRefactory.Ast.TypeDeclaration td) { enum_type_definition enum_td = new enum_type_definition(); enum_td.source_context = get_source_context(td); enum_td.enumerators = new enumerator_list(); foreach (ICSharpCode.NRefactory.Ast.INode node in td.Children) { if (node is ICSharpCode.NRefactory.Ast.FieldDeclaration) { ICSharpCode.NRefactory.Ast.FieldDeclaration fld = node as ICSharpCode.NRefactory.Ast.FieldDeclaration; foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration vd in fld.Fields) { enumerator en = new enumerator(new named_type_reference(vd.Name), null); // SSM здесь исправил 15.1.16 en.source_context = get_source_context(fld); enum_td.enumerators.enumerators.Add(en); } } } return(enum_td); }
private List <declaration> get_field_declaration(ICSharpCode.NRefactory.Ast.FieldDeclaration vd) { List <declaration> fields = new List <declaration>(); bool is_static = (vd.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Static) == ICSharpCode.NRefactory.Ast.Modifiers.Static; 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; if (is_static) { vds.var_attr = definition_attribute.Static; } fields.Add(vds); } return(fields); }
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)); } } } }