133 lines
5.8 KiB
C#
133 lines
5.8 KiB
C#
using System.Collections.Generic;
|
|||
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
|
||
|
|
public sealed class ListPatternSyntax : PatternSyntax
|
||
|
|
{
|
||
|
|
private SyntaxNode? patterns;
|
||
|
|
|
||
|
|
private VariableDesignationSyntax? designation;
|
||
|
|
|
||
|
|
public SyntaxToken OpenBracketToken => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ListPatternSyntax)(object)((SyntaxNode)this).Green).openBracketToken, ((SyntaxNode)this).Position, 0);
|
||
|
|
|
||
|
|
public SeparatedSyntaxList<PatternSyntax> Patterns
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxNode red = ((SyntaxNode)this).GetRed(ref patterns, 1);
|
||
|
|
if (red == null)
|
||
|
|
{
|
||
|
|
return default(SeparatedSyntaxList<PatternSyntax>);
|
||
|
|
}
|
||
|
|
return new SeparatedSyntaxList<PatternSyntax>(red, ((SyntaxNode)this).GetChildIndex(1));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public SyntaxToken CloseBracketToken => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ListPatternSyntax)(object)((SyntaxNode)this).Green).closeBracketToken, ((SyntaxNode)this).GetChildPosition(2), ((SyntaxNode)this).GetChildIndex(2));
|
||
|
|
|
||
|
|
public VariableDesignationSyntax? Designation => ((SyntaxNode)this).GetRed<VariableDesignationSyntax>(ref designation, 3);
|
||
|
|
|
||
|
|
internal ListPatternSyntax(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
|
||
|
|
{
|
||
|
|
1 => ((SyntaxNode)this).GetRed(ref patterns, 1),
|
||
|
|
3 => ((SyntaxNode)this).GetRed<VariableDesignationSyntax>(ref designation, 3),
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
||
|
|
{
|
||
|
|
return (SyntaxNode?)(index switch
|
||
|
|
{
|
||
|
|
1 => patterns,
|
||
|
|
3 => designation,
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitListPattern(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitListPattern(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ListPatternSyntax Update(SyntaxToken openBracketToken, SeparatedSyntaxList<PatternSyntax> patterns, SyntaxToken closeBracketToken, 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_0034: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (openBracketToken != OpenBracketToken || patterns != Patterns || closeBracketToken != CloseBracketToken || designation != Designation)
|
||
|
|
{
|
||
|
|
ListPatternSyntax listPatternSyntax = SyntaxFactory.ListPattern(openBracketToken, patterns, closeBracketToken, designation);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return listPatternSyntax;
|
||
|
|
}
|
||
|
|
return listPatternSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public ListPatternSyntax WithOpenBracketToken(SyntaxToken openBracketToken)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0003: 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)
|
||
|
|
return Update(openBracketToken, Patterns, CloseBracketToken, Designation);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ListPatternSyntax WithPatterns(SeparatedSyntaxList<PatternSyntax> patterns)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0007: 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)
|
||
|
|
return Update(OpenBracketToken, patterns, CloseBracketToken, Designation);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ListPatternSyntax WithCloseBracketToken(SyntaxToken closeBracketToken)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(OpenBracketToken, Patterns, closeBracketToken, Designation);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ListPatternSyntax WithDesignation(VariableDesignationSyntax? designation)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(OpenBracketToken, Patterns, CloseBracketToken, designation);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ListPatternSyntax AddPatterns(params PatternSyntax[] items)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0007: 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)
|
||
|
|
return WithPatterns(Patterns.AddRange((IEnumerable<PatternSyntax>)items));
|
||
|
|
}
|
||
|
|
}
|