using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for a Try statement.
///
public sealed class TryBlockStatement : BlockStatement
{
private readonly StatementCollection _CatchBlockStatements;
private readonly FinallyBlockStatement _FinallyBlockStatement;
private readonly EndBlockStatement _EndStatement;
///
/// The Catch statements.
///
public StatementCollection CatchBlockStatements => _CatchBlockStatements;
///
/// The Finally statement, if any.
///
public FinallyBlockStatement FinallyBlockStatement => _FinallyBlockStatement;
///
/// The End Try statement, if any.
///
public EndBlockStatement EndStatement => _EndStatement;
///
/// Constructs a new parse tree for a Try statement.
///
/// The statements in the Try block.
/// The Catch statements.
/// The Finally statement, if any.
/// The End Try statement, if any.
/// The location of the parse tree.
/// The comments of the parse tree.
public TryBlockStatement(StatementCollection statements, StatementCollection catchBlockStatements, FinallyBlockStatement finallyBlockStatement, EndBlockStatement endStatement, Span span, IList comments)
: base(TreeType.TryBlockStatement, statements, span, comments)
{
SetParent(catchBlockStatements);
SetParent(finallyBlockStatement);
SetParent(endStatement);
_CatchBlockStatements = catchBlockStatements;
_FinallyBlockStatement = finallyBlockStatement;
_EndStatement = endStatement;
}
protected override void GetChildTrees(IList childList)
{
base.GetChildTrees(childList);
Tree.AddChild(childList, CatchBlockStatements);
Tree.AddChild(childList, FinallyBlockStatement);
Tree.AddChild(childList, EndStatement);
}
}