public GotoCaseRewriter(CSS.SwitchStatementSyntax csSwitch) { if (csSwitch == null) { throw new ArgumentNullException("csSwitch"); } _csSwitch = csSwitch; }
public override SyntaxList <StatementSyntax> VisitSwitchStatement(CSS.SwitchStatementSyntax node) { StatementSyntax stmt; _blockInfo.Push(new BlockInfo()); try { var blocks = node.Sections.OrderBy(IsDefaultSwitchStatement).Select(ConvertSwitchSection).ToArray(); stmt = SyntaxFactory.SelectBlock( SyntaxFactory.SelectStatement((ExpressionSyntax)node.Expression.Accept(_nodesVisitor)).WithCaseKeyword(SyntaxFactory.Token(SyntaxKind.CaseKeyword)), SyntaxFactory.List(AddLabels(blocks, _blockInfo.Peek().GotoCaseExpressions)) ); _switchCount++; } finally { _blockInfo.Pop(); } return(SyntaxFactory.SingletonList(stmt)); }
public override SyntaxList <VB.Syntax.StatementSyntax> VisitSwitchStatement(CS.Syntax.SwitchStatementSyntax node) { VB.Syntax.SelectStatementSyntax begin = VB.SyntaxFactory.SelectStatement( expression: nodeVisitor.VisitExpression(node.Expression)); return(List <VB.Syntax.StatementSyntax>( VB.SyntaxFactory.SelectBlock( begin, List(node.Sections.Select(nodeVisitor.Visit <VB.Syntax.CaseBlockSyntax>))))); }