using System; using System.Collections.Generic; namespace AspClassic.Parser; /// /// A parse tree for a namespace declaration. /// public sealed class NamespaceDeclaration : ModifiedDeclaration { private readonly Location _NamespaceLocation; private readonly Name _Name; private readonly DeclarationCollection _Declarations; private readonly EndBlockDeclaration _EndDeclaration; /// /// The location of 'Namespace'. /// public Location NamespaceLocation => _NamespaceLocation; /// /// The name of the namespace. /// public Name Name => _Name; /// /// The declarations in the namespace. /// public DeclarationCollection Declarations => _Declarations; /// /// The End Namespace declaration, if any. /// public EndBlockDeclaration EndDeclaration => _EndDeclaration; /// /// Constructs a parse tree for a namespace declaration. /// /// The attributes on the declaration. /// The modifiers on the declaration. /// The location of 'Namespace'. /// The name of the namespace. /// The declarations in the namespace. /// The End Namespace statement, if any. /// The location of the parse tree. /// The comments for the parse tree. public NamespaceDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location namespaceLocation, Name name, DeclarationCollection declarations, EndBlockDeclaration endDeclaration, Span span, IList comments) : base(TreeType.NamespaceDeclaration, attributes, modifiers, span, comments) { if (name == null) { throw new ArgumentNullException("name"); } SetParent(name); SetParent(declarations); SetParent(endDeclaration); _NamespaceLocation = namespaceLocation; _Name = name; _Declarations = declarations; _EndDeclaration = endDeclaration; } protected override void GetChildTrees(IList childList) { base.GetChildTrees(childList); Tree.AddChild(childList, Name); Tree.AddChild(childList, Declarations); Tree.AddChild(childList, EndDeclaration); } }