using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for an attribute usage.
///
public sealed class Attribute : Tree
{
private readonly AttributeTypes _AttributeType;
private readonly Location _AttributeTypeLocation;
private readonly Location _ColonLocation;
private readonly Name _Name;
private readonly ArgumentCollection _Arguments;
///
/// The target type of the attribute.
///
public AttributeTypes AttributeType => _AttributeType;
///
/// The location of the attribute type, if any.
///
public Location AttributeTypeLocation => _AttributeTypeLocation;
///
/// The location of the ':', if any.
///
public Location ColonLocation => _ColonLocation;
///
/// The name of the attribute being applied.
///
public Name Name => _Name;
///
/// The arguments to the attribute.
///
public ArgumentCollection Arguments => _Arguments;
///
/// Constructs a new attribute parse tree.
///
/// The target type of the attribute.
/// The location of the attribute type.
/// The location of the ':'.
/// The name of the attribute being applied.
/// The arguments to the attribute.
/// The location of the parse tree.
public Attribute(AttributeTypes attributeType, Location attributeTypeLocation, Location colonLocation, Name name, ArgumentCollection arguments, Span span)
: base(TreeType.Attribute, span)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
SetParent(name);
SetParent(arguments);
_AttributeType = attributeType;
_AttributeTypeLocation = attributeTypeLocation;
_ColonLocation = colonLocation;
_Name = name;
_Arguments = arguments;
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, Name);
Tree.AddChild(childList, Arguments);
}
}