Files
2026-08-27 10:56:38 -06:00

117 lines
4.4 KiB
C#

using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
public sealed class CatchClauseSyntax : CSharpSyntaxNode
{
private CatchDeclarationSyntax? declaration;
private CatchFilterClauseSyntax? filter;
private BlockSyntax? block;
public SyntaxToken CatchKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CatchClauseSyntax)(object)((SyntaxNode)this).Green).catchKeyword, ((SyntaxNode)this).Position, 0);
public CatchDeclarationSyntax? Declaration => ((SyntaxNode)this).GetRed<CatchDeclarationSyntax>(ref declaration, 1);
public CatchFilterClauseSyntax? Filter => ((SyntaxNode)this).GetRed<CatchFilterClauseSyntax>(ref filter, 2);
public BlockSyntax Block => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 3);
internal CatchClauseSyntax(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
{
1 => ((SyntaxNode)this).GetRed<CatchDeclarationSyntax>(ref declaration, 1),
2 => ((SyntaxNode)this).GetRed<CatchFilterClauseSyntax>(ref filter, 2),
3 => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 3),
_ => null,
});
}
internal override SyntaxNode? GetCachedSlot(int index)
{
return (SyntaxNode?)(index switch
{
1 => declaration,
2 => filter,
3 => block,
_ => null,
});
}
public override void Accept(CSharpSyntaxVisitor visitor)
{
visitor.VisitCatchClause(this);
}
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
{
return visitor.VisitCatchClause(this);
}
public CatchClauseSyntax Update(SyntaxToken catchKeyword, CatchDeclarationSyntax? declaration, CatchFilterClauseSyntax? filter, BlockSyntax block)
{
//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_002a: Unknown result type (might be due to invalid IL or missing references)
if (catchKeyword != CatchKeyword || declaration != Declaration || filter != Filter || block != Block)
{
CatchClauseSyntax catchClauseSyntax = SyntaxFactory.CatchClause(catchKeyword, declaration, filter, block);
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
if (annotations == null || annotations.Length == 0)
{
return catchClauseSyntax;
}
return catchClauseSyntax.WithAnnotations(annotations);
}
return this;
}
public CatchClauseSyntax WithCatchKeyword(SyntaxToken catchKeyword)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return Update(catchKeyword, Declaration, Filter, Block);
}
public CatchClauseSyntax WithDeclaration(CatchDeclarationSyntax? declaration)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return Update(CatchKeyword, declaration, Filter, Block);
}
public CatchClauseSyntax WithFilter(CatchFilterClauseSyntax? filter)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return Update(CatchKeyword, Declaration, filter, Block);
}
public CatchClauseSyntax WithBlock(BlockSyntax block)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return Update(CatchKeyword, Declaration, Filter, block);
}
public CatchClauseSyntax AddBlockAttributeLists(params AttributeListSyntax[] items)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
return WithBlock(Block.WithAttributeLists(Block.AttributeLists.AddRange((IEnumerable<AttributeListSyntax>)items)));
}
public CatchClauseSyntax AddBlockStatements(params StatementSyntax[] items)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
return WithBlock(Block.WithStatements(Block.Statements.AddRange((IEnumerable<StatementSyntax>)items)));
}
}