102 lines
3.7 KiB
C#
102 lines
3.7 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
public sealed class SwitchSectionSyntax : CSharpSyntaxNode
|
|
{
|
|
private SyntaxNode? labels;
|
|
|
|
private SyntaxNode? statements;
|
|
|
|
public SyntaxList<SwitchLabelSyntax> Labels => new SyntaxList<SwitchLabelSyntax>(((SyntaxNode)this).GetRed(ref labels, 0));
|
|
|
|
public SyntaxList<StatementSyntax> Statements => new SyntaxList<StatementSyntax>(((SyntaxNode)this).GetRed(ref statements, 1));
|
|
|
|
internal SwitchSectionSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)
|
|
: base((GreenNode)(object)green, parent, position)
|
|
{
|
|
}
|
|
|
|
internal override SyntaxNode? GetNodeSlot(int index)
|
|
{
|
|
return (SyntaxNode?)(index switch
|
|
{
|
|
0 => ((SyntaxNode)this).GetRedAtZero(ref labels),
|
|
1 => ((SyntaxNode)this).GetRed(ref statements, 1),
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
|
{
|
|
return (SyntaxNode?)(index switch
|
|
{
|
|
0 => labels,
|
|
1 => statements,
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitSwitchSection(this);
|
|
}
|
|
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitSwitchSection(this);
|
|
}
|
|
|
|
public SwitchSectionSyntax Update(SyntaxList<SwitchLabelSyntax> labels, SyntaxList<StatementSyntax> statements)
|
|
{
|
|
//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_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001d: 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)
|
|
if (labels != Labels || statements != Statements)
|
|
{
|
|
SwitchSectionSyntax switchSectionSyntax = SyntaxFactory.SwitchSection(labels, statements);
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
|
if (annotations == null || annotations.Length == 0)
|
|
{
|
|
return switchSectionSyntax;
|
|
}
|
|
return switchSectionSyntax.WithAnnotations(annotations);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public SwitchSectionSyntax WithLabels(SyntaxList<SwitchLabelSyntax> labels)
|
|
{
|
|
//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)
|
|
return Update(labels, Statements);
|
|
}
|
|
|
|
public SwitchSectionSyntax WithStatements(SyntaxList<StatementSyntax> statements)
|
|
{
|
|
//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)
|
|
return Update(Labels, statements);
|
|
}
|
|
|
|
public SwitchSectionSyntax AddLabels(params SwitchLabelSyntax[] 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 WithLabels(Labels.AddRange((IEnumerable<SwitchLabelSyntax>)items));
|
|
}
|
|
|
|
public SwitchSectionSyntax AddStatements(params StatementSyntax[] 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 WithStatements(Statements.AddRange((IEnumerable<StatementSyntax>)items));
|
|
}
|
|
}
|