using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for a Select statement.
///
public sealed class SelectBlockStatement : BlockStatement
{
private readonly Location _CaseLocation;
private readonly Expression _Expression;
private readonly StatementCollection _CaseBlockStatements;
private readonly CaseElseBlockStatement _CaseElseBlockStatement;
private readonly EndBlockStatement _EndStatement;
///
/// The location of the 'Case', if any.
///
public Location CaseLocation => _CaseLocation;
///
/// The location of the select expression.
///
public Expression Expression => _Expression;
///
/// The Case statements.
///
public StatementCollection CaseBlockStatements => _CaseBlockStatements;
///
/// The Case Else statement, if any.
///
public CaseElseBlockStatement CaseElseBlockStatement => _CaseElseBlockStatement;
///
/// The End Select statement, if any.
///
public EndBlockStatement EndStatement => _EndStatement;
///
/// Constructs a new parse tree for a Select statement.
///
/// The location of the 'Case', if any.
/// The select expression.
/// The Case statements.
/// The Case Else statement, if any.
/// The End Select statement, if any.
/// The location of the parse tree.
/// The comments for the parse tree.
public SelectBlockStatement(Location caseLocation, Expression expression, StatementCollection statements, StatementCollection caseBlockStatements, CaseElseBlockStatement caseElseBlockStatement, EndBlockStatement endStatement, Span span, IList comments)
: base(TreeType.SelectBlockStatement, statements, span, comments)
{
if (expression == null)
{
throw new ArgumentNullException("expression");
}
SetParent(expression);
SetParent(caseBlockStatements);
SetParent(caseElseBlockStatement);
SetParent(endStatement);
_CaseLocation = caseLocation;
_Expression = expression;
_CaseBlockStatements = caseBlockStatements;
_CaseElseBlockStatement = caseElseBlockStatement;
_EndStatement = endStatement;
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, Expression);
Tree.AddChild(childList, CaseBlockStatements);
Tree.AddChild(childList, CaseElseBlockStatement);
Tree.AddChild(childList, EndStatement);
}
}