2024-04-26 10:18:49 +08:00
|
|
|
|
using Canon.Core.Abstractions;
|
2024-04-21 22:24:35 +08:00
|
|
|
|
using Canon.Core.Enums;
|
2024-04-07 16:47:28 +08:00
|
|
|
|
|
|
|
|
|
namespace Canon.Core.SyntaxNodes;
|
|
|
|
|
|
2024-04-26 10:18:49 +08:00
|
|
|
|
public class OnParameterGeneratorEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
public required ExpressionList Parameters { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 16:47:28 +08:00
|
|
|
|
public class IdentifierVarPart : NonTerminatedSyntaxNode
|
|
|
|
|
{
|
|
|
|
|
public override NonTerminatorType Type => NonTerminatorType.IdVarPart;
|
|
|
|
|
|
2024-04-26 10:18:49 +08:00
|
|
|
|
public override void PreVisit(SyntaxNodeVisitor visitor)
|
2024-04-07 16:47:28 +08:00
|
|
|
|
{
|
2024-04-26 10:18:49 +08:00
|
|
|
|
visitor.PreVisit(this);
|
|
|
|
|
RaiseEvent();
|
|
|
|
|
}
|
2024-04-07 16:47:28 +08:00
|
|
|
|
|
2024-04-26 10:18:49 +08:00
|
|
|
|
public override void PostVisit(SyntaxNodeVisitor visitor)
|
|
|
|
|
{
|
|
|
|
|
visitor.PostVisit(this);
|
|
|
|
|
RaiseEvent();
|
2024-04-07 16:47:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-26 10:18:49 +08:00
|
|
|
|
public event EventHandler<OnParameterGeneratorEventArgs>? OnParameterGenerator;
|
|
|
|
|
|
2024-04-07 16:47:28 +08:00
|
|
|
|
public static IdentifierVarPart Create(List<SyntaxNodeBase> children)
|
|
|
|
|
{
|
2024-04-26 10:18:49 +08:00
|
|
|
|
return new IdentifierVarPart { Children = children };
|
|
|
|
|
}
|
2024-04-07 16:47:28 +08:00
|
|
|
|
|
2024-04-26 10:18:49 +08:00
|
|
|
|
private void RaiseEvent()
|
|
|
|
|
{
|
|
|
|
|
if (Children.Count == 3)
|
2024-04-07 16:47:28 +08:00
|
|
|
|
{
|
2024-04-26 10:18:49 +08:00
|
|
|
|
OnParameterGenerator?.Invoke(this, new OnParameterGeneratorEventArgs
|
|
|
|
|
{
|
|
|
|
|
Parameters = Children[1].Convert<ExpressionList>()
|
|
|
|
|
});
|
2024-04-07 16:47:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-26 10:18:49 +08:00
|
|
|
|
OnParameterGenerator = null;
|
2024-04-07 16:47:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|