180 lines
8.0 KiB
C#
180 lines
8.0 KiB
C#
using System.Collections.Generic;
|
|||
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
|
||
|
|
public sealed class TryStatementSyntax : StatementSyntax
|
||
|
|
{
|
||
|
|
private SyntaxNode? attributeLists;
|
||
|
|
|
||
|
|
private BlockSyntax? block;
|
||
|
|
|
||
|
|
private SyntaxNode? catches;
|
||
|
|
|
||
|
|
private FinallyClauseSyntax? @finally;
|
||
|
|
|
||
|
|
public override SyntaxList<AttributeListSyntax> AttributeLists => new SyntaxList<AttributeListSyntax>(((SyntaxNode)this).GetRed(ref attributeLists, 0));
|
||
|
|
|
||
|
|
public SyntaxToken TryKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.TryStatementSyntax)(object)((SyntaxNode)this).Green).tryKeyword, ((SyntaxNode)this).GetChildPosition(1), ((SyntaxNode)this).GetChildIndex(1));
|
||
|
|
|
||
|
|
public BlockSyntax Block => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 2);
|
||
|
|
|
||
|
|
public SyntaxList<CatchClauseSyntax> Catches => new SyntaxList<CatchClauseSyntax>(((SyntaxNode)this).GetRed(ref catches, 3));
|
||
|
|
|
||
|
|
public FinallyClauseSyntax? Finally => ((SyntaxNode)this).GetRed<FinallyClauseSyntax>(ref @finally, 4);
|
||
|
|
|
||
|
|
public TryStatementSyntax Update(SyntaxToken tryKeyword, BlockSyntax block, SyntaxList<CatchClauseSyntax> catches, FinallyClauseSyntax @finally)
|
||
|
|
{
|
||
|
|
//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(AttributeLists, tryKeyword, block, catches, @finally);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal TryStatementSyntax(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
|
||
|
|
{
|
||
|
|
0 => ((SyntaxNode)this).GetRedAtZero(ref attributeLists),
|
||
|
|
2 => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 2),
|
||
|
|
3 => ((SyntaxNode)this).GetRed(ref catches, 3),
|
||
|
|
4 => ((SyntaxNode)this).GetRed<FinallyClauseSyntax>(ref @finally, 4),
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
||
|
|
{
|
||
|
|
return (SyntaxNode?)(index switch
|
||
|
|
{
|
||
|
|
0 => attributeLists,
|
||
|
|
2 => block,
|
||
|
|
3 => catches,
|
||
|
|
4 => @finally,
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitTryStatement(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitTryStatement(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public TryStatementSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxToken tryKeyword, BlockSyntax block, SyntaxList<CatchClauseSyntax> catches, FinallyClauseSyntax? @finally)
|
||
|
|
{
|
||
|
|
//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_003e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0041: 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_0025: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (attributeLists != AttributeLists || tryKeyword != TryKeyword || block != Block || catches != Catches || @finally != Finally)
|
||
|
|
{
|
||
|
|
TryStatementSyntax tryStatementSyntax = SyntaxFactory.TryStatement(attributeLists, tryKeyword, block, catches, @finally);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return tryStatementSyntax;
|
||
|
|
}
|
||
|
|
return tryStatementSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override StatementSyntax WithAttributeListsCore(SyntaxList<AttributeListSyntax> attributeLists)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return WithAttributeLists(attributeLists);
|
||
|
|
}
|
||
|
|
|
||
|
|
public new TryStatementSyntax WithAttributeLists(SyntaxList<AttributeListSyntax> attributeLists)
|
||
|
|
{
|
||
|
|
//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_000f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(attributeLists, TryKeyword, Block, Catches, Finally);
|
||
|
|
}
|
||
|
|
|
||
|
|
public TryStatementSyntax WithTryKeyword(SyntaxToken tryKeyword)
|
||
|
|
{
|
||
|
|
//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_000f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(AttributeLists, tryKeyword, Block, Catches, Finally);
|
||
|
|
}
|
||
|
|
|
||
|
|
public TryStatementSyntax WithBlock(BlockSyntax block)
|
||
|
|
{
|
||
|
|
//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_000f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(AttributeLists, TryKeyword, block, Catches, Finally);
|
||
|
|
}
|
||
|
|
|
||
|
|
public TryStatementSyntax WithCatches(SyntaxList<CatchClauseSyntax> catches)
|
||
|
|
{
|
||
|
|
//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_0013: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(AttributeLists, TryKeyword, Block, catches, Finally);
|
||
|
|
}
|
||
|
|
|
||
|
|
public TryStatementSyntax WithFinally(FinallyClauseSyntax? @finally)
|
||
|
|
{
|
||
|
|
//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_0014: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(AttributeLists, TryKeyword, Block, Catches, @finally);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override StatementSyntax AddAttributeListsCore(params AttributeListSyntax[] items)
|
||
|
|
{
|
||
|
|
return AddAttributeLists(items);
|
||
|
|
}
|
||
|
|
|
||
|
|
public new TryStatementSyntax AddAttributeLists(params AttributeListSyntax[] 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 WithAttributeLists(AttributeLists.AddRange((IEnumerable<AttributeListSyntax>)items));
|
||
|
|
}
|
||
|
|
|
||
|
|
public TryStatementSyntax 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 TryStatementSyntax 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)));
|
||
|
|
}
|
||
|
|
|
||
|
|
public TryStatementSyntax AddCatches(params CatchClauseSyntax[] 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 WithCatches(Catches.AddRange((IEnumerable<CatchClauseSyntax>)items));
|
||
|
|
}
|
||
|
|
}
|