100 lines
2.9 KiB
C#
100 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AspClassic.Parser;
|
|
|
|
/// <summary>
|
|
/// A parse tree for a parameter.
|
|
/// </summary>
|
|
public sealed class Parameter : Tree
|
|
{
|
|
private readonly AttributeBlockCollection _Attributes;
|
|
|
|
private readonly ModifierCollection _Modifiers;
|
|
|
|
private readonly VariableName _VariableName;
|
|
|
|
private readonly Location _AsLocation;
|
|
|
|
private readonly TypeName _ParameterType;
|
|
|
|
private readonly Location _EqualsLocation;
|
|
|
|
private readonly Initializer _Initializer;
|
|
|
|
/// <summary>
|
|
/// The attributes on the parameter.
|
|
/// </summary>
|
|
public AttributeBlockCollection Attributes => _Attributes;
|
|
|
|
/// <summary>
|
|
/// The modifiers on the parameter.
|
|
/// </summary>
|
|
public ModifierCollection Modifiers => _Modifiers;
|
|
|
|
/// <summary>
|
|
/// The name of the parameter.
|
|
/// </summary>
|
|
public VariableName VariableName => _VariableName;
|
|
|
|
/// <summary>
|
|
/// The location of the 'As', if any.
|
|
/// </summary>
|
|
public Location AsLocation => _AsLocation;
|
|
|
|
/// <summary>
|
|
/// The parameter type, if any.
|
|
/// </summary>
|
|
public TypeName ParameterType => _ParameterType;
|
|
|
|
/// <summary>
|
|
/// The location of the '=', if any.
|
|
/// </summary>
|
|
public Location EqualsLocation => _EqualsLocation;
|
|
|
|
/// <summary>
|
|
/// The initializer for the parameter, if any.
|
|
/// </summary>
|
|
public Initializer Initializer => _Initializer;
|
|
|
|
/// <summary>
|
|
/// Constructs a new parameter parse tree.
|
|
/// </summary>
|
|
/// <param name="attributes">The attributes on the parameter.</param>
|
|
/// <param name="modifiers">The modifiers on the parameter.</param>
|
|
/// <param name="variableName">The name of the parameter.</param>
|
|
/// <param name="asLocation">The location of the 'As'.</param>
|
|
/// <param name="parameterType">The type of the parameter. Can be Nothing.</param>
|
|
/// <param name="equalsLocation">The location of the '='.</param>
|
|
/// <param name="initializer">The initializer for the parameter. Can be Nothing.</param>
|
|
/// <param name="span">The location of the parse tree.</param>
|
|
public Parameter(AttributeBlockCollection attributes, ModifierCollection modifiers, VariableName variableName, Location asLocation, TypeName parameterType, Location equalsLocation, Initializer initializer, Span span)
|
|
: base(TreeType.Parameter, span)
|
|
{
|
|
if (variableName == null)
|
|
{
|
|
throw new ArgumentNullException("variableName");
|
|
}
|
|
SetParent(attributes);
|
|
SetParent(modifiers);
|
|
SetParent(variableName);
|
|
SetParent(parameterType);
|
|
SetParent(initializer);
|
|
_Attributes = attributes;
|
|
_Modifiers = modifiers;
|
|
_VariableName = variableName;
|
|
_AsLocation = asLocation;
|
|
_ParameterType = parameterType;
|
|
_EqualsLocation = equalsLocation;
|
|
_Initializer = initializer;
|
|
}
|
|
|
|
protected override void GetChildTrees(IList<Tree> childList)
|
|
{
|
|
Tree.AddChild(childList, Attributes);
|
|
Tree.AddChild(childList, Modifiers);
|
|
Tree.AddChild(childList, VariableName);
|
|
Tree.AddChild(childList, ParameterType);
|
|
Tree.AddChild(childList, Initializer);
|
|
}
|
|
}
|