ICSharpCode.NRefactory.CSharp.Refactoring.BaseRefactoringContext.CreateReachabilityAnalysis C# (CSharp) Method

CreateReachabilityAnalysis() public method

Creates a new reachability analysis object with a given statement.
public CreateReachabilityAnalysis ( Statement statement, ICSharpCode.NRefactory.CSharp.Analysis.ReachabilityAnalysis recursiveDetectorVisitor = null ) : ICSharpCode.NRefactory.CSharp.Analysis.ReachabilityAnalysis
statement Statement /// The statement to start the analysis. ///
recursiveDetectorVisitor ICSharpCode.NRefactory.CSharp.Analysis.ReachabilityAnalysis /// TODO. ///
return ICSharpCode.NRefactory.CSharp.Analysis.ReachabilityAnalysis
		public ReachabilityAnalysis CreateReachabilityAnalysis (Statement statement, ReachabilityAnalysis.RecursiveDetectorVisitor recursiveDetectorVisitor = null)
		{
			return ReachabilityAnalysis.Create (statement, resolver, recursiveDetectorVisitor, CancellationToken);
		}

Usage Example

Example #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());
            }
        }