115 lines
4.6 KiB
C#
115 lines
4.6 KiB
C#
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
public sealed class CasePatternSwitchLabelSyntax : SwitchLabelSyntax
|
|
{
|
|
private PatternSyntax? pattern;
|
|
|
|
private WhenClauseSyntax? whenClause;
|
|
|
|
public override SyntaxToken Keyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CasePatternSwitchLabelSyntax)(object)((SyntaxNode)this).Green).keyword, ((SyntaxNode)this).Position, 0);
|
|
|
|
public PatternSyntax Pattern => ((SyntaxNode)this).GetRed<PatternSyntax>(ref pattern, 1);
|
|
|
|
public WhenClauseSyntax? WhenClause => ((SyntaxNode)this).GetRed<WhenClauseSyntax>(ref whenClause, 2);
|
|
|
|
public override SyntaxToken ColonToken => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CasePatternSwitchLabelSyntax)(object)((SyntaxNode)this).Green).colonToken, ((SyntaxNode)this).GetChildPosition(3), ((SyntaxNode)this).GetChildIndex(3));
|
|
|
|
internal CasePatternSwitchLabelSyntax(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<PatternSyntax>(ref pattern, 1),
|
|
2 => ((SyntaxNode)this).GetRed<WhenClauseSyntax>(ref whenClause, 2),
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
|
{
|
|
return (SyntaxNode?)(index switch
|
|
{
|
|
1 => pattern,
|
|
2 => whenClause,
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitCasePatternSwitchLabel(this);
|
|
}
|
|
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitCasePatternSwitchLabel(this);
|
|
}
|
|
|
|
public CasePatternSwitchLabelSyntax Update(SyntaxToken keyword, PatternSyntax pattern, WhenClauseSyntax? whenClause, SyntaxToken colonToken)
|
|
{
|
|
//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_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
|
if (keyword != Keyword || pattern != Pattern || whenClause != WhenClause || colonToken != ColonToken)
|
|
{
|
|
CasePatternSwitchLabelSyntax casePatternSwitchLabelSyntax = SyntaxFactory.CasePatternSwitchLabel(keyword, pattern, whenClause, colonToken);
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
|
if (annotations == null || annotations.Length == 0)
|
|
{
|
|
return casePatternSwitchLabelSyntax;
|
|
}
|
|
return casePatternSwitchLabelSyntax.WithAnnotations(annotations);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
internal override SwitchLabelSyntax WithKeywordCore(SyntaxToken keyword)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return WithKeyword(keyword);
|
|
}
|
|
|
|
public new CasePatternSwitchLabelSyntax WithKeyword(SyntaxToken keyword)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(keyword, Pattern, WhenClause, ColonToken);
|
|
}
|
|
|
|
public CasePatternSwitchLabelSyntax WithPattern(PatternSyntax pattern)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(Keyword, pattern, WhenClause, ColonToken);
|
|
}
|
|
|
|
public CasePatternSwitchLabelSyntax WithWhenClause(WhenClauseSyntax? whenClause)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(Keyword, Pattern, whenClause, ColonToken);
|
|
}
|
|
|
|
internal override SwitchLabelSyntax WithColonTokenCore(SyntaxToken colonToken)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return WithColonToken(colonToken);
|
|
}
|
|
|
|
public new CasePatternSwitchLabelSyntax WithColonToken(SyntaxToken colonToken)
|
|
{
|
|
//IL_0002: 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)
|
|
return Update(Keyword, Pattern, WhenClause, colonToken);
|
|
}
|
|
}
|