|
|
@ -174,22 +174,16 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
static void CollectSwitchSectionStatements (AstNodeCollection<Statement> result, RefactoringContext context, |
|
|
|
static void CollectSwitchSectionStatements (AstNodeCollection<Statement> result, RefactoringContext context, |
|
|
|
Statement statement) |
|
|
|
Statement statement) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BlockStatement blockStatement; |
|
|
|
BlockStatement blockStatement = statement as BlockStatement; |
|
|
|
if (statement is BlockStatement) |
|
|
|
if (blockStatement != null) |
|
|
|
blockStatement = (BlockStatement)statement.Clone (); |
|
|
|
result.AddRange(blockStatement.Statements.Select(s => s.Clone())); |
|
|
|
else |
|
|
|
else |
|
|
|
blockStatement = new BlockStatement { statement.Clone () }; |
|
|
|
result.Add(statement.Clone()); |
|
|
|
|
|
|
|
|
|
|
|
var breackStatement = new BreakStatement (); |
|
|
|
// add 'break;' at end if necessary
|
|
|
|
blockStatement.Add (breackStatement); |
|
|
|
var reachabilityAnalysis = context.CreateReachabilityAnalysis (statement); |
|
|
|
// check if break is needed
|
|
|
|
if (reachabilityAnalysis.IsEndpointReachable(statement)) |
|
|
|
var reachabilityAnalysis = context.CreateReachabilityAnalysis (blockStatement); |
|
|
|
result.Add(new BreakStatement()); |
|
|
|
if (!reachabilityAnalysis.IsReachable (breackStatement)) |
|
|
|
|
|
|
|
blockStatement.Statements.Remove (breackStatement); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var statements = blockStatement.Statements.ToArray (); |
|
|
|
|
|
|
|
blockStatement.Statements.Clear (); |
|
|
|
|
|
|
|
result.AddRange (statements); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|