76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
|
||
|
|
public sealed class ThrowExpressionSyntax : ExpressionSyntax
|
||
|
|
{
|
||
|
|
private ExpressionSyntax? expression;
|
||
|
|
|
||
|
|
public SyntaxToken ThrowKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ThrowExpressionSyntax)(object)((SyntaxNode)this).Green).throwKeyword, ((SyntaxNode)this).Position, 0);
|
||
|
|
|
||
|
|
public ExpressionSyntax Expression => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expression, 1);
|
||
|
|
|
||
|
|
internal ThrowExpressionSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)
|
||
|
|
: base(green, parent, position)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetNodeSlot(int index)
|
||
|
|
{
|
||
|
|
if (index != 1)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return (SyntaxNode?)(object)((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expression, 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
||
|
|
{
|
||
|
|
if (index != 1)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return (SyntaxNode?)(object)expression;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitThrowExpression(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitThrowExpression(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ThrowExpressionSyntax Update(SyntaxToken throwKeyword, ExpressionSyntax expression)
|
||
|
|
{
|
||
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (throwKeyword != ThrowKeyword || expression != Expression)
|
||
|
|
{
|
||
|
|
ThrowExpressionSyntax throwExpressionSyntax = SyntaxFactory.ThrowExpression(throwKeyword, expression);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return throwExpressionSyntax;
|
||
|
|
}
|
||
|
|
return throwExpressionSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public ThrowExpressionSyntax WithThrowKeyword(SyntaxToken throwKeyword)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(throwKeyword, Expression);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ThrowExpressionSyntax WithExpression(ExpressionSyntax expression)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(ThrowKeyword, expression);
|
||
|
|
}
|
||
|
|
}
|