public override void VisitIfElseStatement(IfElseStatement ifElseStatement)
        {
            ForceSpacesBefore(ifElseStatement.LParToken, policy.SpaceBeforeIfParentheses);

            ForceSpacesAfter(ifElseStatement.LParToken, policy.SpacesWithinIfParentheses);
            ForceSpacesBefore(ifElseStatement.RParToken, policy.SpacesWithinIfParentheses);

            if (!(ifElseStatement.Parent is IfElseStatement && ((IfElseStatement)ifElseStatement.Parent).FalseStatement == ifElseStatement))
            {
                FixStatementIndentation(ifElseStatement.StartLocation);
            }

            if (!ifElseStatement.Condition.IsNull)
            {
                ifElseStatement.Condition.AcceptVisitor(this);
            }

            if (!ifElseStatement.TrueStatement.IsNull)
            {
                FixEmbeddedStatment(policy.StatementBraceStyle, ifElseStatement.IfToken, policy.AllowIfBlockInline, ifElseStatement.TrueStatement);
            }

            if (!ifElseStatement.FalseStatement.IsNull)
            {
                var placeElseOnNewLine = policy.ElseNewLinePlacement;
                if (!(ifElseStatement.TrueStatement is BlockStatement))
                {
                    placeElseOnNewLine = NewLinePlacement.NewLine;
                }
                PlaceOnNewLine(placeElseOnNewLine, ifElseStatement.ElseToken);
                if (ifElseStatement.FalseStatement is IfElseStatement)
                {
                    PlaceOnNewLine(policy.ElseIfNewLinePlacement, ((IfElseStatement)ifElseStatement.FalseStatement).IfToken);
                }
                FixEmbeddedStatment(policy.StatementBraceStyle, ifElseStatement.ElseToken, policy.AllowIfBlockInline, ifElseStatement.FalseStatement, ifElseStatement.FalseStatement is IfElseStatement);
            }
        }
Пример #2
0
 void IAstVisitor.VisitIfElseStatement(IfElseStatement ifElseStatement)
 {
     Visit(EnterIfElseStatement, LeaveIfElseStatement, ifElseStatement);
 }