public override object Visit (Switch switchStatement) { var result = new SwitchStatement (); var location = LocationsBag.GetLocations (switchStatement); result.AddChild (new CSharpTokenNode (Convert (switchStatement.loc), "switch".Length), SwitchStatement.Roles.Keyword); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), SwitchStatement.Roles.LPar); result.AddChild ((INode)switchStatement.Expr.Accept (this), SwitchStatement.Roles.Expression); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), SwitchStatement.Roles.RPar); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), SwitchStatement.Roles.LBrace); foreach (var section in switchStatement.Sections) { var newSection = new MonoDevelop.CSharp.Dom.SwitchSection (); foreach (var caseLabel in section.Labels) { var newLabel = new CaseLabel (); newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location), "case".Length), SwitchStatement.Roles.Keyword); if (caseLabel.Label != null) newLabel.AddChild ((INode)caseLabel.Label.Accept (this), SwitchStatement.Roles.Expression); newSection.AddChild (newLabel, MonoDevelop.CSharp.Dom.SwitchSection.CaseLabelRole); } newSection.AddChild ((INode)section.Block.Accept (this), MonoDevelop.CSharp.Dom.SwitchSection.Roles.Body); result.AddChild (newSection, SwitchStatement.SwitchSectionRole); } if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), SwitchStatement.Roles.RBrace); return result; }
public virtual S VisitSwitchSection(SwitchSection switchSection, T data) { return(VisitChildren(switchSection, data)); }