using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for an End declaration.
///
public sealed class EndBlockDeclaration : Declaration
{
private readonly BlockType _EndType;
private readonly Location _EndArgumentLocation;
///
/// The type of block the declaration ends.
///
public BlockType EndType => _EndType;
///
/// The location of the end block argument.
///
public Location EndArgumentLocation => _EndArgumentLocation;
///
/// Creates a new parse tree for an End block declaration.
///
/// The type of the block the statement ends.
/// The location of the end block argument.
/// The location of the parse tree.
/// The comments for the parse tree.
public EndBlockDeclaration(BlockType endType, Location endArgumentLocation, Span span, IList comments)
: base(TreeType.EndBlockDeclaration, span, comments)
{
if (endType < BlockType.Sub && endType > BlockType.Namespace)
{
throw new ArgumentOutOfRangeException("endType");
}
_EndType = endType;
_EndArgumentLocation = endArgumentLocation;
}
internal EndBlockDeclaration(EndBlockStatement endBlockStatement)
: base(TreeType.EndBlockDeclaration, endBlockStatement.Span, endBlockStatement.Comments)
{
BlockType endType = endBlockStatement.EndType;
if ((uint)(endType - 10) <= 2u || (uint)(endType - 14) <= 4u)
{
_EndType = endBlockStatement.EndType;
_EndArgumentLocation = endBlockStatement.EndArgumentLocation;
return;
}
throw new ArgumentException("Invalid EndBlockStatement type.");
}
}