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 RelationalPatternSyntax : PatternSyntax
|
||
|
|
{
|
||
|
|
private ExpressionSyntax? expression;
|
||
|
|
|
||
|
|
public SyntaxToken OperatorToken => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.RelationalPatternSyntax)(object)((SyntaxNode)this).Green).operatorToken, ((SyntaxNode)this).Position, 0);
|
||
|
|
|
||
|
|
public ExpressionSyntax Expression => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expression, 1);
|
||
|
|
|
||
|
|
internal RelationalPatternSyntax(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.VisitRelationalPattern(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitRelationalPattern(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public RelationalPatternSyntax Update(SyntaxToken operatorToken, 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 (operatorToken != OperatorToken || expression != Expression)
|
||
|
|
{
|
||
|
|
RelationalPatternSyntax relationalPatternSyntax = SyntaxFactory.RelationalPattern(operatorToken, expression);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return relationalPatternSyntax;
|
||
|
|
}
|
||
|
|
return relationalPatternSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public RelationalPatternSyntax WithOperatorToken(SyntaxToken operatorToken)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(operatorToken, Expression);
|
||
|
|
}
|
||
|
|
|
||
|
|
public RelationalPatternSyntax WithExpression(ExpressionSyntax expression)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(OperatorToken, expression);
|
||
|
|
}
|
||
|
|
}
|