コード例 #1
0
        static void CollectSwitchSectionStatements(AstNodeCollection <Statement> result, BaseRefactoringContext context,
                                                   Statement statement)
        {
            BlockStatement blockStatement = statement as BlockStatement;

            if (blockStatement != null)
            {
                result.AddRange(blockStatement.Statements.Select(s => s.Clone()));
            }
            else
            {
                result.Add(statement.Clone());
            }

            // add 'break;' at end if necessary
            var reachabilityAnalysis = context.CreateReachabilityAnalysis(statement);

            if (reachabilityAnalysis.IsEndpointReachable(statement))
            {
                result.Add(new BreakStatement());
            }
        }