public override SyntaxList <StatementSyntax> VisitBreakStatement(CSS.BreakStatementSyntax node) { var statementKind = SyntaxKind.None; var keywordKind = SyntaxKind.None; foreach (var stmt in node.GetAncestors <CSS.StatementSyntax>()) { if (stmt is CSS.DoStatementSyntax) { statementKind = SyntaxKind.ExitDoStatement; keywordKind = SyntaxKind.DoKeyword; break; } if (stmt is CSS.WhileStatementSyntax) { statementKind = SyntaxKind.ExitWhileStatement; keywordKind = SyntaxKind.WhileKeyword; break; } if (stmt is CSS.ForStatementSyntax || stmt is CSS.ForEachStatementSyntax) { statementKind = SyntaxKind.ExitForStatement; keywordKind = SyntaxKind.ForKeyword; break; } if (stmt is CSS.SwitchStatementSyntax) { statementKind = SyntaxKind.ExitSelectStatement; keywordKind = SyntaxKind.SelectKeyword; break; } } return(SyntaxFactory.SingletonList <StatementSyntax>(SyntaxFactory.ExitStatement(statementKind, SyntaxFactory.Token(keywordKind)))); }
public override SyntaxList <StatementSyntax> VisitBreakStatement(CSS.BreakStatementSyntax node) { var statementKind = SyntaxKind.None; var keywordKind = SyntaxKind.None; foreach (var stmt in node.GetAncestors <CSS.StatementSyntax>()) { if (stmt is CSS.DoStatementSyntax) { statementKind = SyntaxKind.ExitDoStatement; keywordKind = SyntaxKind.DoKeyword; break; } if (stmt is CSS.WhileStatementSyntax) { statementKind = SyntaxKind.ExitWhileStatement; keywordKind = SyntaxKind.WhileKeyword; break; } if (stmt is CSS.ForEachStatementSyntax) { statementKind = SyntaxKind.ExitForStatement; keywordKind = SyntaxKind.ForKeyword; break; } if (stmt is CSS.ForStatementSyntax fs) { bool isFor = ConvertForToSimpleForNextWithoutStatements(fs, out _); statementKind = isFor ? SyntaxKind.ExitForStatement : SyntaxKind.ExitWhileStatement; keywordKind = isFor ? SyntaxKind.ForKeyword : SyntaxKind.WhileKeyword; break; } if (stmt is CSS.SwitchStatementSyntax) { statementKind = SyntaxKind.ExitSelectStatement; keywordKind = SyntaxKind.SelectKeyword; break; } } return(SyntaxFactory.SingletonList <StatementSyntax>(SyntaxFactory.ExitStatement(statementKind, SyntaxFactory.Token(keywordKind)))); }