76 lines
2.4 KiB
C#
76 lines
2.4 KiB
C#
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
public sealed class WhenClauseSyntax : CSharpSyntaxNode
|
|
{
|
|
private ExpressionSyntax? condition;
|
|
|
|
public SyntaxToken WhenKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.WhenClauseSyntax)(object)((SyntaxNode)this).Green).whenKeyword, ((SyntaxNode)this).Position, 0);
|
|
|
|
public ExpressionSyntax Condition => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref condition, 1);
|
|
|
|
internal WhenClauseSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)
|
|
: base((GreenNode)(object)green, parent, position)
|
|
{
|
|
}
|
|
|
|
internal override SyntaxNode? GetNodeSlot(int index)
|
|
{
|
|
if (index != 1)
|
|
{
|
|
return null;
|
|
}
|
|
return (SyntaxNode?)(object)((SyntaxNode)this).GetRed<ExpressionSyntax>(ref condition, 1);
|
|
}
|
|
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
|
{
|
|
if (index != 1)
|
|
{
|
|
return null;
|
|
}
|
|
return (SyntaxNode?)(object)condition;
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitWhenClause(this);
|
|
}
|
|
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitWhenClause(this);
|
|
}
|
|
|
|
public WhenClauseSyntax Update(SyntaxToken whenKeyword, ExpressionSyntax condition)
|
|
{
|
|
//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 (whenKeyword != WhenKeyword || condition != Condition)
|
|
{
|
|
WhenClauseSyntax whenClauseSyntax = SyntaxFactory.WhenClause(whenKeyword, condition);
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
|
if (annotations == null || annotations.Length == 0)
|
|
{
|
|
return whenClauseSyntax;
|
|
}
|
|
return whenClauseSyntax.WithAnnotations(annotations);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public WhenClauseSyntax WithWhenKeyword(SyntaxToken whenKeyword)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(whenKeyword, Condition);
|
|
}
|
|
|
|
public WhenClauseSyntax WithCondition(ExpressionSyntax condition)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(WhenKeyword, condition);
|
|
}
|
|
}
|