public override void Visit(FixedField f) { var location = LocationsBag.GetMemberLocation(f); int locationIdx = 0; var newField = new FixedFieldDeclaration(); AddAttributeSection(newField, f); AddModifiers(newField, location); if (location != null && location.Count > 0) newField.AddChild(new CSharpTokenNode(Convert(location [locationIdx++]), FixedFieldDeclaration.FixedKeywordRole), FixedFieldDeclaration.FixedKeywordRole); if (f.TypeExpression != null) newField.AddChild(ConvertToType(f.TypeExpression), Roles.Type); var variable = new FixedVariableInitializer(); variable.AddChild(Identifier.Create(f.MemberName.Name, Convert(f.MemberName.Location)), Roles.Identifier); if (f.Initializer != null && !f.Initializer.IsNull) { variable.AddChild(new CSharpTokenNode(Convert(f.Initializer.Location), Roles.LBracket), Roles.LBracket); variable.AddChild((Expression)f.Initializer.Accept(this), Roles.Expression); var bracketLocations = LocationsBag.GetLocations(f.Initializer); if (bracketLocations != null) variable.AddChild(new CSharpTokenNode(Convert(bracketLocations [0]), Roles.RBracket), Roles.RBracket); } newField.AddChild(variable, FixedFieldDeclaration.VariableRole); if (f.Declarators != null) { foreach (var decl in f.Declarators) { var declLoc = LocationsBag.GetLocations(decl); if (declLoc != null) newField.AddChild(new CSharpTokenNode(Convert(declLoc [0]), Roles.Comma), Roles.Comma); variable = new FixedVariableInitializer(); variable.AddChild(Identifier.Create(decl.Name.Value, Convert(decl.Name.Location)), Roles.Identifier); variable.AddChild(new CSharpTokenNode(Convert(decl.Initializer.Location), Roles.LBracket), Roles.LBracket); variable.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression); var bracketLocations = LocationsBag.GetLocations(decl.Initializer); if (bracketLocations != null) variable.AddChild(new CSharpTokenNode(Convert(bracketLocations [0]), Roles.RBracket), Roles.RBracket); newField.AddChild(variable, FixedFieldDeclaration.VariableRole); } } if (location != null && location.Count > locationIdx) newField.AddChild(new CSharpTokenNode(Convert(location [locationIdx]), Roles.Semicolon), Roles.Semicolon); typeStack.Peek().AddChild(newField, Roles.TypeMemberRole); }
public override void Visit (FixedField f) { var location = LocationsBag.GetMemberLocation (f); var newField = new FixedFieldDeclaration (); AddAttributeSection (newField, f); AddModifiers (newField, location); if (location != null) newField.AddChild (new CSharpTokenNode (Convert (location [0]), "fixed".Length), FixedFieldDeclaration.Roles.Keyword); newField.AddChild (ConvertToType (f.TypeName), FixedFieldDeclaration.Roles.Type); var variable = new FixedVariableInitializer (); variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier); if (!f.Initializer.IsNull) { var bracketLocations = LocationsBag.GetLocations (f.Initializer); if (bracketLocations != null && bracketLocations.Count > 1) variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket); variable.AddChild ((Expression)f.Initializer.Accept (this), FieldDeclaration.Roles.Expression); if (bracketLocations != null && bracketLocations.Count > 1) variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket); } newField.AddChild (variable, FixedFieldDeclaration.VariableRole); if (f.Declarators != null) { foreach (var decl in f.Declarators) { var declLoc = LocationsBag.GetLocations (decl); if (declLoc != null) newField.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), FieldDeclaration.Roles.Comma); variable = new FixedVariableInitializer (); variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); if (!decl.Initializer.IsNull) { var bracketLocations = LocationsBag.GetLocations (f.Initializer); if (bracketLocations != null && bracketLocations.Count > 1) variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket); variable.AddChild ((Expression)decl.Initializer.Accept (this), FieldDeclaration.Roles.Expression); if (bracketLocations != null && bracketLocations.Count > 1) variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket); } newField.AddChild (variable, FixedFieldDeclaration.VariableRole); } } if (location != null) newField.AddChild (new CSharpTokenNode (Convert (location [1]), 1), FieldDeclaration.Roles.Semicolon); typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); }