using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for a For Each statement.
///
public sealed class ForEachBlockStatement : BlockStatement
{
private readonly Location _EachLocation;
private readonly Expression _ControlExpression;
private readonly VariableDeclarator _ControlVariableDeclarator;
private readonly Location _InLocation;
private readonly Expression _CollectionExpression;
private readonly NextStatement _NextStatement;
///
/// The location of the 'Each'.
///
public Location EachLocation => _EachLocation;
///
/// The control expression.
///
public Expression ControlExpression => _ControlExpression;
///
/// The control variable declarator, if any.
///
public VariableDeclarator ControlVariableDeclarator => _ControlVariableDeclarator;
///
/// The location of the 'In'.
///
public Location InLocation => _InLocation;
///
/// The collection expression.
///
public Expression CollectionExpression => _CollectionExpression;
///
/// The Next statement, if any.
///
public NextStatement NextStatement => _NextStatement;
///
/// Constructs a new parse tree for a For Each statement.
///
/// The location of the 'Each'.
/// The control expression.
/// The control variable declarator, if any.
/// The location of the 'In'.
/// The collection expression.
/// The statements in the block.
/// The Next statement, if any.
/// The location of the parse tree.
/// The comments for the parse tree.
public ForEachBlockStatement(Location eachLocation, Expression controlExpression, VariableDeclarator controlVariableDeclarator, Location inLocation, Expression collectionExpression, StatementCollection statements, NextStatement nextStatement, Span span, IList comments)
: base(TreeType.ForEachBlockStatement, statements, span, comments)
{
if (controlExpression == null)
{
throw new ArgumentNullException("controlExpression");
}
SetParent(controlExpression);
SetParent(controlVariableDeclarator);
SetParent(collectionExpression);
SetParent(nextStatement);
_EachLocation = eachLocation;
_ControlExpression = controlExpression;
_ControlVariableDeclarator = controlVariableDeclarator;
_InLocation = inLocation;
_CollectionExpression = collectionExpression;
_NextStatement = nextStatement;
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, ControlExpression);
Tree.AddChild(childList, ControlVariableDeclarator);
Tree.AddChild(childList, CollectionExpression);
base.GetChildTrees(childList);
Tree.AddChild(childList, NextStatement);
}
}