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

54 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for a local declaration statement.
/// </summary>
public sealed class LocalDeclarationStatement : Statement
{
private readonly ModifierCollection _Modifiers;
private readonly VariableDeclaratorCollection _VariableDeclarators;
/// <summary>
/// The statement modifiers.
/// </summary>
public ModifierCollection Modifiers => _Modifiers;
/// <summary>
/// The variable declarators.
/// </summary>
public VariableDeclaratorCollection VariableDeclarators => _VariableDeclarators;
/// <summary>
/// Constructs a new parse tree for a local declaration statement.
/// </summary>
/// <param name="modifiers">The statement modifiers.</param>
/// <param name="variableDeclarators">The variable declarators.</param>
/// <param name="span">The location of the parse tree.</param>
/// <param name="comments">The comments for the parse tree.</param>
public LocalDeclarationStatement(ModifierCollection modifiers, VariableDeclaratorCollection variableDeclarators, Span span, IList<Comment> comments)
: base(TreeType.LocalDeclarationStatement, span, comments)
{
if (modifiers == null)
{
throw new ArgumentNullException("modifers");
}
if (variableDeclarators == null)
{
throw new ArgumentNullException("variableDeclarators");
}
SetParent(modifiers);
SetParent(variableDeclarators);
_Modifiers = modifiers;
_VariableDeclarators = variableDeclarators;
}
protected override void GetChildTrees(IList<Tree> childList)
{
Tree.AddChild(childList, Modifiers);
Tree.AddChild(childList, VariableDeclarators);
}
}