This commit is contained in:
Jelle Luteijn 2022-05-15 11:19:49 +02:00
parent 16e76d6b31
commit 484dbfc9d9
529 changed files with 113694 additions and 0 deletions

View file

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for an attribute usage.
/// </summary>
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;
/// <summary>
/// The target type of the attribute.
/// </summary>
public AttributeTypes AttributeType => _AttributeType;
/// <summary>
/// The location of the attribute type, if any.
/// </summary>
public Location AttributeTypeLocation => _AttributeTypeLocation;
/// <summary>
/// The location of the ':', if any.
/// </summary>
public Location ColonLocation => _ColonLocation;
/// <summary>
/// The name of the attribute being applied.
/// </summary>
public Name Name => _Name;
/// <summary>
/// The arguments to the attribute.
/// </summary>
public ArgumentCollection Arguments => _Arguments;
/// <summary>
/// Constructs a new attribute parse tree.
/// </summary>
/// <param name="attributeType">The target type of the attribute.</param>
/// <param name="attributeTypeLocation">The location of the attribute type.</param>
/// <param name="colonLocation">The location of the ':'.</param>
/// <param name="name">The name of the attribute being applied.</param>
/// <param name="arguments">The arguments to the attribute.</param>
/// <param name="span">The location of the parse tree.</param>
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<Tree> childList)
{
Tree.AddChild(childList, Name);
Tree.AddChild(childList, Arguments);
}
}