88 lines
3.0 KiB
C#
88 lines
3.0 KiB
C#
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
public sealed class IsPatternExpressionSyntax : ExpressionSyntax
|
|
{
|
|
private ExpressionSyntax? expression;
|
|
|
|
private PatternSyntax? pattern;
|
|
|
|
public ExpressionSyntax Expression => ((SyntaxNode)this).GetRedAtZero<ExpressionSyntax>(ref expression);
|
|
|
|
public SyntaxToken IsKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.IsPatternExpressionSyntax)(object)((SyntaxNode)this).Green).isKeyword, ((SyntaxNode)this).GetChildPosition(1), ((SyntaxNode)this).GetChildIndex(1));
|
|
|
|
public PatternSyntax Pattern => ((SyntaxNode)this).GetRed<PatternSyntax>(ref pattern, 2);
|
|
|
|
internal IsPatternExpressionSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)
|
|
: base(green, parent, position)
|
|
{
|
|
}
|
|
|
|
internal override SyntaxNode? GetNodeSlot(int index)
|
|
{
|
|
return (SyntaxNode?)(index switch
|
|
{
|
|
0 => ((SyntaxNode)this).GetRedAtZero<ExpressionSyntax>(ref expression),
|
|
2 => ((SyntaxNode)this).GetRed<PatternSyntax>(ref pattern, 2),
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
|
{
|
|
return (SyntaxNode?)(index switch
|
|
{
|
|
0 => expression,
|
|
2 => pattern,
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitIsPatternExpression(this);
|
|
}
|
|
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitIsPatternExpression(this);
|
|
}
|
|
|
|
public IsPatternExpressionSyntax Update(ExpressionSyntax expression, SyntaxToken isKeyword, PatternSyntax pattern)
|
|
{
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
if (expression != Expression || isKeyword != IsKeyword || pattern != Pattern)
|
|
{
|
|
IsPatternExpressionSyntax isPatternExpressionSyntax = SyntaxFactory.IsPatternExpression(expression, isKeyword, pattern);
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
|
if (annotations == null || annotations.Length == 0)
|
|
{
|
|
return isPatternExpressionSyntax;
|
|
}
|
|
return isPatternExpressionSyntax.WithAnnotations(annotations);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public IsPatternExpressionSyntax WithExpression(ExpressionSyntax expression)
|
|
{
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(expression, IsKeyword, Pattern);
|
|
}
|
|
|
|
public IsPatternExpressionSyntax WithIsKeyword(SyntaxToken isKeyword)
|
|
{
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(Expression, isKeyword, Pattern);
|
|
}
|
|
|
|
public IsPatternExpressionSyntax WithPattern(PatternSyntax pattern)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(Expression, IsKeyword, pattern);
|
|
}
|
|
}
|