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 VarPatternSyntax : PatternSyntax
|
|
{
|
|
private VariableDesignationSyntax? designation;
|
|
|
|
public SyntaxToken VarKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.VarPatternSyntax)(object)((SyntaxNode)this).Green).varKeyword, ((SyntaxNode)this).Position, 0);
|
|
|
|
public VariableDesignationSyntax Designation => ((SyntaxNode)this).GetRed<VariableDesignationSyntax>(ref designation, 1);
|
|
|
|
internal VarPatternSyntax(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<VariableDesignationSyntax>(ref designation, 1);
|
|
}
|
|
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
|
{
|
|
if (index != 1)
|
|
{
|
|
return null;
|
|
}
|
|
return (SyntaxNode?)(object)designation;
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitVarPattern(this);
|
|
}
|
|
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitVarPattern(this);
|
|
}
|
|
|
|
public VarPatternSyntax Update(SyntaxToken varKeyword, VariableDesignationSyntax designation)
|
|
{
|
|
//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 (varKeyword != VarKeyword || designation != Designation)
|
|
{
|
|
VarPatternSyntax varPatternSyntax = SyntaxFactory.VarPattern(varKeyword, designation);
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
|
if (annotations == null || annotations.Length == 0)
|
|
{
|
|
return varPatternSyntax;
|
|
}
|
|
return varPatternSyntax.WithAnnotations(annotations);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public VarPatternSyntax WithVarKeyword(SyntaxToken varKeyword)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(varKeyword, Designation);
|
|
}
|
|
|
|
public VarPatternSyntax WithDesignation(VariableDesignationSyntax designation)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(VarKeyword, designation);
|
|
}
|
|
}
|