aspclassic-core/AspClassic.Parser/UsingBlockStatement.cs
Jelle Luteijn 484dbfc9d9 progress
2022-05-15 11:19:49 +02:00

55 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for a Using block statement.
/// </summary>
public sealed class UsingBlockStatement : ExpressionBlockStatement
{
private readonly VariableDeclaratorCollection _VariableDeclarators;
/// <summary>
/// The variable declarators, if no expression.
/// </summary>
public VariableDeclaratorCollection VariableDeclarators => _VariableDeclarators;
/// <summary>
/// Constructs a new parse tree for a Using statement block with an expression.
/// </summary>
/// <param name="expression">The expression.</param>
/// <param name="statements">The statements in the block.</param>
/// <param name="endStatement">The End statement for the block, if any.</param>
/// <param name="span">The location of the parse tree.</param>
/// <param name="comments">The comments for the parse tree.</param>
public UsingBlockStatement(Expression expression, StatementCollection statements, EndBlockStatement endStatement, Span span, IList<Comment> comments)
: base(TreeType.UsingBlockStatement, expression, statements, endStatement, span, comments)
{
}
/// <summary>
/// Constructs a new parse tree for a Using statement block with variable declarators.
/// </summary>
/// <param name="variableDeclarators">The variable declarators.</param>
/// <param name="statements">The statements in the block.</param>
/// <param name="endStatement">The End statement for the block, if any.</param>
/// <param name="span">The location of the parse tree.</param>
/// <param name="comments">The comments for the parse tree.</param>
public UsingBlockStatement(VariableDeclaratorCollection variableDeclarators, StatementCollection statements, EndBlockStatement endStatement, Span span, IList<Comment> comments)
: base(TreeType.UsingBlockStatement, null, statements, endStatement, span, comments)
{
if (variableDeclarators == null)
{
throw new ArgumentNullException("variableDeclarators");
}
SetParent(variableDeclarators);
_VariableDeclarators = variableDeclarators;
}
protected override void GetChildTrees(IList<Tree> childList)
{
Tree.AddChild(childList, VariableDeclarators);
base.GetChildTrees(childList);
}
}