public override void Visit (EventProperty ep) { EventDeclaration newEvent = new EventDeclaration (); var location = LocationsBag.GetMemberLocation (ep); AddModifiers (newEvent, location); if (location != null) newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), EventDeclaration.Roles.Keyword); newEvent.AddChild ((AstNode)ep.TypeName.Accept (this), EventDeclaration.Roles.ReturnType); newEvent.AddChild (new Identifier (ep.MemberName.Name, Convert (ep.MemberName.Location)), EventDeclaration.Roles.Identifier); if (location != null && location.Count >= 2) newEvent.AddChild (new CSharpTokenNode (Convert (location[1]), 1), EventDeclaration.Roles.LBrace); if (ep.Add != null) { MonoDevelop.CSharp.Ast.Accessor addAccessor = new MonoDevelop.CSharp.Ast.Accessor (); var addLocation = LocationsBag.GetMemberLocation (ep.Add); AddModifiers (addAccessor, addLocation); addAccessor.AddChild (new CSharpTokenNode (Convert (ep.Add.Location), "add".Length), EventDeclaration.Roles.Keyword); if (ep.Add.Block != null) addAccessor.AddChild ((AstNode)ep.Add.Block.Accept (this), EventDeclaration.Roles.Body); newEvent.AddChild (addAccessor, EventDeclaration.EventAddRole); } if (ep.Remove != null) { MonoDevelop.CSharp.Ast.Accessor removeAccessor = new MonoDevelop.CSharp.Ast.Accessor (); var removeLocation = LocationsBag.GetMemberLocation (ep.Remove); AddModifiers (removeAccessor, removeLocation); removeAccessor.AddChild (new CSharpTokenNode (Convert (ep.Remove.Location), "remove".Length), EventDeclaration.Roles.Keyword); if (ep.Remove.Block != null) removeAccessor.AddChild ((AstNode)ep.Remove.Block.Accept (this), EventDeclaration.Roles.Body); newEvent.AddChild (removeAccessor, EventDeclaration.EventRemoveRole); } if (location != null && location.Count >= 3) newEvent.AddChild (new CSharpTokenNode (Convert (location[2]), 1), EventDeclaration.Roles.RBrace); typeStack.Peek ().AddChild (newEvent, TypeDeclaration.Roles.Member); }
public override void Visit (Indexer indexer) { IndexerDeclaration newIndexer = new IndexerDeclaration (); var location = LocationsBag.GetMemberLocation (indexer); AddModifiers (newIndexer, location); newIndexer.AddChild ((AstNode)indexer.TypeName.Accept (this), AstNode.Roles.ReturnType); if (location != null) newIndexer.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IndexerDeclaration.Roles.LBracket); AddParameter (newIndexer, indexer.Parameters); if (location != null) newIndexer.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IndexerDeclaration.Roles.RBracket); if (location != null) newIndexer.AddChild (new CSharpTokenNode (Convert (location[2]), 1), IndexerDeclaration.Roles.LBrace); if (indexer.Get != null) { MonoDevelop.CSharp.Ast.Accessor getAccessor = new MonoDevelop.CSharp.Ast.Accessor (); var getLocation = LocationsBag.GetMemberLocation (indexer.Get); AddModifiers (getAccessor, getLocation); if (getLocation != null) getAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Get.Location), "get".Length), PropertyDeclaration.Roles.Keyword); if (indexer.Get.Block != null) { getAccessor.AddChild ((AstNode)indexer.Get.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (getLocation != null && getLocation.Count > 0) newIndexer.AddChild (new CSharpTokenNode (Convert (getLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newIndexer.AddChild (getAccessor, PropertyDeclaration.PropertyGetRole); } if (indexer.Set != null) { MonoDevelop.CSharp.Ast.Accessor setAccessor = new MonoDevelop.CSharp.Ast.Accessor (); var setLocation = LocationsBag.GetMemberLocation (indexer.Set); AddModifiers (setAccessor, setLocation); if (setLocation != null) setAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Set.Location), "set".Length), PropertyDeclaration.Roles.Keyword); if (indexer.Set.Block != null) { setAccessor.AddChild ((AstNode)indexer.Set.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (setLocation != null && setLocation.Count > 0) newIndexer.AddChild (new CSharpTokenNode (Convert (setLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newIndexer.AddChild (setAccessor, PropertyDeclaration.PropertySetRole); } if (location != null) newIndexer.AddChild (new CSharpTokenNode (Convert (location[3]), 1), IndexerDeclaration.Roles.RBrace); typeStack.Peek ().AddChild (newIndexer, TypeDeclaration.Roles.Member); }
public override void Visit (Property p) { PropertyDeclaration newProperty = new PropertyDeclaration (); var location = LocationsBag.GetMemberLocation (p); AddModifiers (newProperty, location); newProperty.AddChild ((AstNode)p.TypeName.Accept (this), AstNode.Roles.ReturnType); newProperty.AddChild (new Identifier (p.MemberName.Name, Convert (p.MemberName.Location)), AstNode.Roles.Identifier); if (location != null) newProperty.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LBrace); if (p.Get != null) { MonoDevelop.CSharp.Ast.Accessor getAccessor = new MonoDevelop.CSharp.Ast.Accessor (); var getLocation = LocationsBag.GetMemberLocation (p.Get); AddModifiers (getAccessor, getLocation); getAccessor.AddChild (new CSharpTokenNode (Convert (p.Get.Location), "get".Length), PropertyDeclaration.Roles.Keyword); if (p.Get.Block != null) { getAccessor.AddChild ((AstNode)p.Get.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (getLocation != null && getLocation.Count > 0) newProperty.AddChild (new CSharpTokenNode (Convert (getLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newProperty.AddChild (getAccessor, PropertyDeclaration.PropertyGetRole); } if (p.Set != null) { MonoDevelop.CSharp.Ast.Accessor setAccessor = new MonoDevelop.CSharp.Ast.Accessor (); var setLocation = LocationsBag.GetMemberLocation (p.Set); AddModifiers (setAccessor, setLocation); setAccessor.AddChild (new CSharpTokenNode (Convert (p.Set.Location), "set".Length), PropertyDeclaration.Roles.Keyword); if (p.Set.Block != null) { setAccessor.AddChild ((AstNode)p.Set.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (setLocation != null && setLocation.Count > 0) newProperty.AddChild (new CSharpTokenNode (Convert (setLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newProperty.AddChild (setAccessor, PropertyDeclaration.PropertySetRole); } if (location != null) newProperty.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RBrace); typeStack.Peek ().AddChild (newProperty, TypeDeclaration.Roles.Member); }
public virtual S VisitAccessor(Accessor accessor, T data) { return(VisitChildren(accessor, data)); }