using System; using System.Collections.Generic; namespace AspClassic.Parser; /// /// A parse tree for a parameter. /// 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; /// /// The attributes on the parameter. /// public AttributeBlockCollection Attributes => _Attributes; /// /// The modifiers on the parameter. /// public ModifierCollection Modifiers => _Modifiers; /// /// The name of the parameter. /// public VariableName VariableName => _VariableName; /// /// The location of the 'As', if any. /// public Location AsLocation => _AsLocation; /// /// The parameter type, if any. /// public TypeName ParameterType => _ParameterType; /// /// The location of the '=', if any. /// public Location EqualsLocation => _EqualsLocation; /// /// The initializer for the parameter, if any. /// public Initializer Initializer => _Initializer; /// /// Constructs a new parameter parse tree. /// /// The attributes on the parameter. /// The modifiers on the parameter. /// The name of the parameter. /// The location of the 'As'. /// The type of the parameter. Can be Nothing. /// The location of the '='. /// The initializer for the parameter. Can be Nothing. /// The location of the parse tree. 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 childList) { Tree.AddChild(childList, Attributes); Tree.AddChild(childList, Modifiers); Tree.AddChild(childList, VariableName); Tree.AddChild(childList, ParameterType); Tree.AddChild(childList, Initializer); } }