311 lines
14 KiB
C#
311 lines
14 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
public sealed class SimpleLambdaExpressionSyntax : LambdaExpressionSyntax
|
|
{
|
|
private SyntaxNode? attributeLists;
|
|
|
|
private ParameterSyntax? parameter;
|
|
|
|
private BlockSyntax? block;
|
|
|
|
private ExpressionSyntax? expressionBody;
|
|
|
|
public override SyntaxToken AsyncKeyword => Modifiers.FirstOrDefault(SyntaxKind.AsyncKeyword);
|
|
|
|
public override SyntaxList<AttributeListSyntax> AttributeLists => new SyntaxList<AttributeListSyntax>(((SyntaxNode)this).GetRed(ref attributeLists, 0));
|
|
|
|
public override SyntaxTokenList Modifiers
|
|
{
|
|
get
|
|
{
|
|
//IL_002a: 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(1);
|
|
if (slot == null)
|
|
{
|
|
return default(SyntaxTokenList);
|
|
}
|
|
return new SyntaxTokenList((SyntaxNode)(object)this, slot, ((SyntaxNode)this).GetChildPosition(1), ((SyntaxNode)this).GetChildIndex(1));
|
|
}
|
|
}
|
|
|
|
public ParameterSyntax Parameter => ((SyntaxNode)this).GetRed<ParameterSyntax>(ref parameter, 2);
|
|
|
|
public override SyntaxToken ArrowToken => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SimpleLambdaExpressionSyntax)(object)((SyntaxNode)this).Green).arrowToken, ((SyntaxNode)this).GetChildPosition(3), ((SyntaxNode)this).GetChildIndex(3));
|
|
|
|
public override BlockSyntax? Block => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 4);
|
|
|
|
public override ExpressionSyntax? ExpressionBody => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expressionBody, 5);
|
|
|
|
public new SimpleLambdaExpressionSyntax WithBody(CSharpSyntaxNode body)
|
|
{
|
|
if (!(body is BlockSyntax blockSyntax))
|
|
{
|
|
return WithExpressionBody((ExpressionSyntax)body).WithBlock(null);
|
|
}
|
|
return WithBlock(blockSyntax).WithExpressionBody(null);
|
|
}
|
|
|
|
public SimpleLambdaExpressionSyntax Update(SyntaxToken asyncKeyword, ParameterSyntax parameter, SyntaxToken arrowToken, CSharpSyntaxNode body)
|
|
{
|
|
//IL_001e: 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_000c: 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)
|
|
if (!(body is BlockSyntax blockSyntax))
|
|
{
|
|
return Update(asyncKeyword, parameter, arrowToken, null, (ExpressionSyntax)body);
|
|
}
|
|
return Update(asyncKeyword, parameter, arrowToken, 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 SimpleLambdaExpressionSyntax WithAsyncKeyword(SyntaxToken asyncKeyword)
|
|
{
|
|
//IL_0001: 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(asyncKeyword, Parameter, ArrowToken, Block, ExpressionBody);
|
|
}
|
|
|
|
public SimpleLambdaExpressionSyntax Update(SyntaxToken asyncKeyword, ParameterSyntax parameter, SyntaxToken arrowToken, 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_0009: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(UpdateAsyncKeyword(asyncKeyword), parameter, arrowToken, block, expressionBody);
|
|
}
|
|
|
|
public SimpleLambdaExpressionSyntax Update(SyntaxTokenList modifiers, ParameterSyntax parameter, SyntaxToken arrowToken, BlockSyntax? block, ExpressionSyntax? expressionBody)
|
|
{
|
|
//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, modifiers, parameter, arrowToken, block, expressionBody);
|
|
}
|
|
|
|
internal SimpleLambdaExpressionSyntax(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<ParameterSyntax>(ref parameter, 2),
|
|
4 => ((SyntaxNode)this).GetRed<BlockSyntax>(ref block, 4),
|
|
5 => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expressionBody, 5),
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
|
{
|
|
return (SyntaxNode?)(index switch
|
|
{
|
|
0 => attributeLists,
|
|
2 => parameter,
|
|
4 => block,
|
|
5 => expressionBody,
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitSimpleLambdaExpression(this);
|
|
}
|
|
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitSimpleLambdaExpression(this);
|
|
}
|
|
|
|
public SimpleLambdaExpressionSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, ParameterSyntax parameter, SyntaxToken arrowToken, 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_0048: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: 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 || modifiers != Modifiers || parameter != Parameter || arrowToken != ArrowToken || block != Block || expressionBody != ExpressionBody)
|
|
{
|
|
SimpleLambdaExpressionSyntax simpleLambdaExpressionSyntax = SyntaxFactory.SimpleLambdaExpression(attributeLists, modifiers, parameter, arrowToken, block, expressionBody);
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
|
if (annotations == null || annotations.Length == 0)
|
|
{
|
|
return simpleLambdaExpressionSyntax;
|
|
}
|
|
return simpleLambdaExpressionSyntax.WithAnnotations(annotations);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
internal override LambdaExpressionSyntax WithAttributeListsCore(SyntaxList<AttributeListSyntax> attributeLists)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return WithAttributeLists(attributeLists);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax 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, Modifiers, Parameter, ArrowToken, Block, ExpressionBody);
|
|
}
|
|
|
|
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 SimpleLambdaExpressionSyntax WithModifiers(SyntaxTokenList modifiers)
|
|
{
|
|
//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, modifiers, Parameter, ArrowToken, Block, ExpressionBody);
|
|
}
|
|
|
|
public SimpleLambdaExpressionSyntax WithParameter(ParameterSyntax parameter)
|
|
{
|
|
//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, Modifiers, parameter, ArrowToken, Block, ExpressionBody);
|
|
}
|
|
|
|
internal override LambdaExpressionSyntax WithArrowTokenCore(SyntaxToken arrowToken)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return WithArrowToken(arrowToken);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax WithArrowToken(SyntaxToken arrowToken)
|
|
{
|
|
//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, Modifiers, Parameter, arrowToken, Block, ExpressionBody);
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax WithBlockCore(BlockSyntax? block)
|
|
{
|
|
return WithBlock(block);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax 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_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(AttributeLists, Modifiers, Parameter, ArrowToken, block, ExpressionBody);
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax WithExpressionBodyCore(ExpressionSyntax? expressionBody)
|
|
{
|
|
return WithExpressionBody(expressionBody);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax 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)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
return Update(AttributeLists, Modifiers, Parameter, ArrowToken, Block, expressionBody);
|
|
}
|
|
|
|
internal override LambdaExpressionSyntax AddAttributeListsCore(params AttributeListSyntax[] items)
|
|
{
|
|
return AddAttributeLists(items);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax 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));
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax AddModifiersCore(params SyntaxToken[] items)
|
|
{
|
|
return AddModifiers(items);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax 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 SimpleLambdaExpressionSyntax AddParameterAttributeLists(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 WithParameter(Parameter.WithAttributeLists(Parameter.AttributeLists.AddRange((IEnumerable<AttributeListSyntax>)items)));
|
|
}
|
|
|
|
public SimpleLambdaExpressionSyntax AddParameterModifiers(params SyntaxToken[] 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)
|
|
ParameterSyntax parameterSyntax = Parameter;
|
|
SyntaxTokenList modifiers = Parameter.Modifiers;
|
|
return WithParameter(parameterSyntax.WithModifiers(((SyntaxTokenList)(ref modifiers)).AddRange((IEnumerable<SyntaxToken>)items)));
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax AddBlockAttributeListsCore(params AttributeListSyntax[] items)
|
|
{
|
|
return AddBlockAttributeLists(items);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax AddBlockAttributeLists(params AttributeListSyntax[] 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)
|
|
BlockSyntax blockSyntax = Block ?? SyntaxFactory.Block();
|
|
return WithBlock(blockSyntax.WithAttributeLists(blockSyntax.AttributeLists.AddRange((IEnumerable<AttributeListSyntax>)items)));
|
|
}
|
|
|
|
internal override AnonymousFunctionExpressionSyntax AddBlockStatementsCore(params StatementSyntax[] items)
|
|
{
|
|
return AddBlockStatements(items);
|
|
}
|
|
|
|
public new SimpleLambdaExpressionSyntax AddBlockStatements(params StatementSyntax[] 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)
|
|
BlockSyntax blockSyntax = Block ?? SyntaxFactory.Block();
|
|
return WithBlock(blockSyntax.WithStatements(blockSyntax.Statements.AddRange((IEnumerable<StatementSyntax>)items)));
|
|
}
|
|
}
|