using System; using System.Collections.Generic; namespace AspClassic.Parser; /// /// A parse tree for a line If statement. /// public sealed class LineIfStatement : Statement { private readonly Expression _Expression; private readonly Location _ThenLocation; private readonly StatementCollection _IfStatements; private readonly Location _ElseLocation; private readonly StatementCollection _ElseStatements; /// /// The conditional expression. /// public Expression Expression => _Expression; /// /// The location of the 'Then'. /// public Location ThenLocation => _ThenLocation; /// /// The If statements. /// public StatementCollection IfStatements => _IfStatements; /// /// The location of the 'Else', if any. /// public Location ElseLocation => _ElseLocation; /// /// The Else statements. /// public StatementCollection ElseStatements => _ElseStatements; /// /// Constructs a new parse tree for a line If statement. /// /// The conditional expression. /// The location of the 'Then'. /// The If statements. /// The location of the 'Else', if any. /// The Else statements. /// The location of the parse tree. /// The comments for the parse tree. public LineIfStatement(Expression expression, Location thenLocation, StatementCollection ifStatements, Location elseLocation, StatementCollection elseStatements, Span span, IList comments) : base(TreeType.LineIfBlockStatement, span, comments) { if (expression == null) { throw new ArgumentNullException("expression"); } SetParent(expression); SetParent(ifStatements); SetParent(elseStatements); _Expression = expression; _ThenLocation = thenLocation; _IfStatements = ifStatements; _ElseLocation = elseLocation; _ElseStatements = elseStatements; } protected override void GetChildTrees(IList childList) { Tree.AddChild(childList, Expression); Tree.AddChild(childList, IfStatements); Tree.AddChild(childList, ElseStatements); } }