Ejemplo n.º 1
0
    public static ImplicitSingleStatementBranches TryGetIfStatementBranches_ConditionalJump(IfStatementSyntax syntax)
    {
        var trueAction = syntax.Statement.CollapsedStatements().SingleOrDefaultAllowMany();
        if (trueAction == null) return null;
        if (!trueAction.IsGuaranteedToJumpOut()) return null;

        if (syntax.Else != null) return null;
        var followingAction = syntax.ElseAndFollowingStatements().FirstOrDefault();
        if (followingAction == null) return null;

        return new ImplicitSingleStatementBranches(trueAction, followingAction, syntax);
    }