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

58 lines
1.4 KiB
C#

#define DEBUG
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for an AddHandler or RemoveHandler statement.
/// </summary>
public abstract class HandlerStatement : Statement
{
private readonly Expression _Name;
private readonly Location _CommaLocation;
private readonly Expression _DelegateExpression;
/// <summary>
/// The event name.
/// </summary>
public Expression Name => _Name;
/// <summary>
/// The location of the ','.
/// </summary>
public Location CommaLocation => _CommaLocation;
/// <summary>
/// The delegate expression.
/// </summary>
public Expression DelegateExpression => _DelegateExpression;
protected HandlerStatement(TreeType type, Expression name, Location commaLocation, Expression delegateExpression, Span span, IList<Comment> comments)
: base(type, span, comments)
{
Debug.Assert(type == TreeType.AddHandlerStatement || type == TreeType.RemoveHandlerStatement);
if (name == null)
{
throw new ArgumentNullException("name");
}
if (delegateExpression == null)
{
throw new ArgumentNullException("delegateExpression");
}
SetParent(name);
SetParent(delegateExpression);
_Name = name;
_CommaLocation = commaLocation;
_DelegateExpression = delegateExpression;
}
protected override void GetChildTrees(IList<Tree> childList)
{
Tree.AddChild(childList, Name);
Tree.AddChild(childList, DelegateExpression);
}
}