244 lines
11 KiB
C#
244 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
public sealed class AnonymousMethodExpressionSyntax : AnonymousFunctionExpressionSyntax
|
|
{
|
|
private ParameterListSyntax? parameterList;
|
|
|
|
private BlockSyntax? block;
|
|
|
|
private ExpressionSyntax? expressionBody;
|
|
|
|
public override SyntaxToken AsyncKeyword => Modifiers.FirstOrDefault(SyntaxKind.AsyncKeyword);
|
|
|
|
public override SyntaxTokenList Modifiers
|
|
{
|
|
get
|
|
{
|
|
//IL_0023: 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_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
GreenNode slot = ((SyntaxNode)this).Green.GetSlot(0);
|
|
if (slot == null)
|
|
{
|
|
return default(SyntaxTokenList);
|
|
}
|
|
return new SyntaxTokenList((SyntaxNode)(object)this, slot, ((SyntaxNode)this).Position, 0);
|
|
}
|
|
}
|
|
|
|
public SyntaxToken DelegateKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.AnonymousMethodExpressionSyntax)(object)((SyntaxNode)this).Green).delegateKeyword, ((SyntaxNode)this).GetChildPosition(1), ((SyntaxNode)this).GetChildIndex(1));
|
|
|
|
public ParameterListSyntax? ParameterList => ((SyntaxNode)this).GetRed<ParameterListSyntax>(ref parameterList, 2);
|
|
|
|
public override BlockSyntax Block => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 3);
|
|
|
|
public override ExpressionSyntax? ExpressionBody => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expressionBody, 4);
|
|
|
|
public new AnonymousMethodExpressionSyntax WithBody(CSharpSyntaxNode body)
|
|
{
|
|
if (!(body is BlockSyntax blockSyntax))
|
|
{
|
|
return WithExpressionBody((ExpressionSyntax)body).WithBlock(null);
|
|
}
|
|
return WithBlock(blockSyntax).WithExpressionBody(null);
|
|
}
|
|
|
|
public AnonymousMethodExpressionSyntax Update(SyntaxToken asyncKeyword, SyntaxToken delegateKeyword, ParameterListSyntax parameterList, CSharpSyntaxNode body)
|
|
{
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000c: 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)
|
|
if (!(body is BlockSyntax blockSyntax))
|
|
{
|
|
return Update(asyncKeyword, delegateKeyword, parameterList, null, (ExpressionSyntax)body);
|
|
}
|
|
return Update(asyncKeyword, delegateKeyword, parameterList, blockSyntax, null);
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax WithAsyncKeywordCore(SyntaxToken asyncKeyword)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return WithAsyncKeyword(asyncKeyword);
|
|
}
|
|
|
|
public new AnonymousMethodExpressionSyntax WithAsyncKeyword(SyntaxToken asyncKeyword)
|
|
{
|
|
//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(asyncKeyword, DelegateKeyword, ParameterList, Block, ExpressionBody);
|
|
}
|
|
|
|
public AnonymousMethodExpressionSyntax Update(SyntaxToken asyncKeyword, SyntaxToken delegateKeyword, ParameterListSyntax parameterList, BlockSyntax block, ExpressionSyntax expressionBody)
|
|
{
|
|
//IL_0002: 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_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(UpdateAsyncKeyword(asyncKeyword), delegateKeyword, parameterList, block, expressionBody);
|
|
}
|
|
|
|
internal AnonymousMethodExpressionSyntax(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
|
|
{
|
|
2 => ((SyntaxNode)this).GetRed<ParameterListSyntax>(ref parameterList, 2),
|
|
3 => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 3),
|
|
4 => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expressionBody, 4),
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
|
{
|
|
return (SyntaxNode?)(index switch
|
|
{
|
|
2 => parameterList,
|
|
3 => block,
|
|
4 => expressionBody,
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitAnonymousMethodExpression(this);
|
|
}
|
|
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitAnonymousMethodExpression(this);
|
|
}
|
|
|
|
public AnonymousMethodExpressionSyntax Update(SyntaxTokenList modifiers, SyntaxToken delegateKeyword, ParameterListSyntax? parameterList, BlockSyntax block, ExpressionSyntax? expressionBody)
|
|
{
|
|
//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_0039: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003a: 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 (modifiers != Modifiers || delegateKeyword != DelegateKeyword || parameterList != ParameterList || block != Block || expressionBody != ExpressionBody)
|
|
{
|
|
AnonymousMethodExpressionSyntax anonymousMethodExpressionSyntax = SyntaxFactory.AnonymousMethodExpression(modifiers, delegateKeyword, parameterList, block, expressionBody);
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
|
if (annotations == null || annotations.Length == 0)
|
|
{
|
|
return anonymousMethodExpressionSyntax;
|
|
}
|
|
return anonymousMethodExpressionSyntax.WithAnnotations(annotations);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax WithModifiersCore(SyntaxTokenList modifiers)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return WithModifiers(modifiers);
|
|
}
|
|
|
|
public new AnonymousMethodExpressionSyntax WithModifiers(SyntaxTokenList modifiers)
|
|
{
|
|
//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(modifiers, DelegateKeyword, ParameterList, Block, ExpressionBody);
|
|
}
|
|
|
|
public AnonymousMethodExpressionSyntax WithDelegateKeyword(SyntaxToken delegateKeyword)
|
|
{
|
|
//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(Modifiers, delegateKeyword, ParameterList, Block, ExpressionBody);
|
|
}
|
|
|
|
public AnonymousMethodExpressionSyntax WithParameterList(ParameterListSyntax? parameterList)
|
|
{
|
|
//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)
|
|
return Update(Modifiers, DelegateKeyword, parameterList, Block, ExpressionBody);
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax WithBlockCore(BlockSyntax? block)
|
|
{
|
|
return WithBlock(block ?? throw new ArgumentNullException("block"));
|
|
}
|
|
|
|
public new AnonymousMethodExpressionSyntax 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)
|
|
return Update(Modifiers, DelegateKeyword, ParameterList, block, ExpressionBody);
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax WithExpressionBodyCore(ExpressionSyntax? expressionBody)
|
|
{
|
|
return WithExpressionBody(expressionBody);
|
|
}
|
|
|
|
public new AnonymousMethodExpressionSyntax WithExpressionBody(ExpressionSyntax? expressionBody)
|
|
{
|
|
//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)
|
|
return Update(Modifiers, DelegateKeyword, ParameterList, Block, expressionBody);
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax AddModifiersCore(params SyntaxToken[] items)
|
|
{
|
|
return AddModifiers(items);
|
|
}
|
|
|
|
public new AnonymousMethodExpressionSyntax AddModifiers(params SyntaxToken[] 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)
|
|
SyntaxTokenList modifiers = Modifiers;
|
|
return WithModifiers(((SyntaxTokenList)(ref modifiers)).AddRange((IEnumerable<SyntaxToken>)items));
|
|
}
|
|
|
|
public AnonymousMethodExpressionSyntax AddParameterListParameters(params ParameterSyntax[] items)
|
|
{
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: 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_000c: 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)
|
|
ParameterListSyntax parameterListSyntax = ParameterList ?? SyntaxFactory.ParameterList();
|
|
return WithParameterList(parameterListSyntax.WithParameters(parameterListSyntax.Parameters.AddRange((IEnumerable<ParameterSyntax>)items)));
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax AddBlockAttributeListsCore(params AttributeListSyntax[] items)
|
|
{
|
|
return AddBlockAttributeLists(items);
|
|
}
|
|
|
|
public new AnonymousMethodExpressionSyntax 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)));
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax AddBlockStatementsCore(params StatementSyntax[] items)
|
|
{
|
|
return AddBlockStatements(items);
|
|
}
|
|
|
|
public new AnonymousMethodExpressionSyntax 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)));
|
|
}
|
|
}
|