#define DEBUG using System; using System.Collections.Generic; using System.Diagnostics; namespace AspClassic.Parser; /// /// A parse tree for a block declaration. /// public abstract class BlockDeclaration : ModifiedDeclaration { private readonly Location _KeywordLocation; private readonly SimpleName _Name; private readonly DeclarationCollection _Declarations; private readonly EndBlockDeclaration _EndDeclaration; /// /// The location of the keyword. /// public Location KeywordLocation => _KeywordLocation; /// /// The name of the declaration. /// public SimpleName Name => _Name; /// /// The declarations in the block. /// public DeclarationCollection Declarations => _Declarations; /// /// The End statement for the block. /// public EndBlockDeclaration EndDeclaration => _EndDeclaration; protected BlockDeclaration(TreeType type, AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, DeclarationCollection declarations, EndBlockDeclaration endDeclaration, Span span, IList comments) : base(type, attributes, modifiers, span, comments) { Debug.Assert(type == TreeType.ClassDeclaration || type == TreeType.ModuleDeclaration || type == TreeType.InterfaceDeclaration || type == TreeType.StructureDeclaration || type == TreeType.EnumDeclaration); if (name == null) { throw new ArgumentNullException("name"); } SetParent(name); SetParent(declarations); SetParent(endDeclaration); _KeywordLocation = keywordLocation; _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); } }