using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for a variable declarator (e.g. "x As Integer")
///
public sealed class VariableDeclarator : Tree
{
private readonly VariableNameCollection _VariableNames;
private readonly Location _AsLocation;
private readonly Location _NewLocation;
private readonly TypeName _VariableType;
private readonly ArgumentCollection _Arguments;
private readonly Location _EqualsLocation;
private readonly Initializer _Initializer;
///
/// The variable names being declared.
///
public VariableNameCollection VariableNames => _VariableNames;
///
/// The location of the 'As', if any.
///
public Location AsLocation => _AsLocation;
///
/// The location of the 'New', if any.
///
public Location NewLocation => _NewLocation;
///
/// The type of the variables being declared, if any.
///
public TypeName VariableType => _VariableType;
///
/// The arguments to the constructor, if any.
///
public ArgumentCollection Arguments => _Arguments;
///
/// The location of the '=', if any.
///
public Location EqualsLocation => _EqualsLocation;
///
/// The variable initializer, if any.
///
public Initializer Initializer => _Initializer;
///
/// Constructs a new parse tree for a variable declarator.
///
/// The names of the variables being declared.
/// The location of the 'As', if any.
/// The location of the 'New', if any.
/// The type of the variables being declared, if any.
/// The arguments of the constructor, if any.
/// The location of the '=', if any.
/// The variable initializer, if any.
/// The location of the parse tree.
public VariableDeclarator(VariableNameCollection variableNames, Location asLocation, Location newLocation, TypeName variableType, ArgumentCollection arguments, Location equalsLocation, Initializer initializer, Span span)
: base(TreeType.VariableDeclarator, span)
{
if (variableNames == null)
{
throw new ArgumentNullException("variableNames");
}
SetParent(variableNames);
SetParent(variableType);
SetParent(arguments);
SetParent(initializer);
_VariableNames = variableNames;
_AsLocation = asLocation;
_NewLocation = newLocation;
_VariableType = variableType;
_Arguments = arguments;
_EqualsLocation = equalsLocation;
_Initializer = initializer;
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, VariableNames);
Tree.AddChild(childList, VariableType);
Tree.AddChild(childList, Arguments);
Tree.AddChild(childList, Initializer);
}
}