aspclassic-core/AspClassic.Parser/TryBlockStatement.cs
Jelle Luteijn 484dbfc9d9 progress
2022-05-15 11:19:49 +02:00

58 lines
2 KiB
C#

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