97 lines
3.6 KiB
C#
97 lines
3.6 KiB
C#
using System.Collections.Generic;
|
|||
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
|
||
|
|
public sealed class WithExpressionSyntax : ExpressionSyntax
|
||
|
|
{
|
||
|
|
private ExpressionSyntax? expression;
|
||
|
|
|
||
|
|
private InitializerExpressionSyntax? initializer;
|
||
|
|
|
||
|
|
public ExpressionSyntax Expression => ((SyntaxNode)this).GetRedAtZero<ExpressionSyntax>(ref expression);
|
||
|
|
|
||
|
|
public SyntaxToken WithKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.WithExpressionSyntax)(object)((SyntaxNode)this).Green).withKeyword, ((SyntaxNode)this).GetChildPosition(1), ((SyntaxNode)this).GetChildIndex(1));
|
||
|
|
|
||
|
|
public InitializerExpressionSyntax Initializer => ((SyntaxNode)this).GetRed<InitializerExpressionSyntax>(ref initializer, 2);
|
||
|
|
|
||
|
|
internal WithExpressionSyntax(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<ExpressionSyntax>(ref expression),
|
||
|
|
2 => ((SyntaxNode)this).GetRed<InitializerExpressionSyntax>(ref initializer, 2),
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
||
|
|
{
|
||
|
|
return (SyntaxNode?)(index switch
|
||
|
|
{
|
||
|
|
0 => expression,
|
||
|
|
2 => initializer,
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitWithExpression(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitWithExpression(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public WithExpressionSyntax Update(ExpressionSyntax expression, SyntaxToken withKeyword, InitializerExpressionSyntax initializer)
|
||
|
|
{
|
||
|
|
//IL_0021: 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)
|
||
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (expression != Expression || withKeyword != WithKeyword || initializer != Initializer)
|
||
|
|
{
|
||
|
|
WithExpressionSyntax withExpressionSyntax = SyntaxFactory.WithExpression(expression, withKeyword, initializer);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return withExpressionSyntax;
|
||
|
|
}
|
||
|
|
return withExpressionSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public WithExpressionSyntax WithExpression(ExpressionSyntax expression)
|
||
|
|
{
|
||
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(expression, WithKeyword, Initializer);
|
||
|
|
}
|
||
|
|
|
||
|
|
public WithExpressionSyntax WithWithKeyword(SyntaxToken withKeyword)
|
||
|
|
{
|
||
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(Expression, withKeyword, Initializer);
|
||
|
|
}
|
||
|
|
|
||
|
|
public WithExpressionSyntax WithInitializer(InitializerExpressionSyntax initializer)
|
||
|
|
{
|
||
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(Expression, WithKeyword, initializer);
|
||
|
|
}
|
||
|
|
|
||
|
|
public WithExpressionSyntax AddInitializerExpressions(params ExpressionSyntax[] 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 WithInitializer(Initializer.WithExpressions(Initializer.Expressions.AddRange((IEnumerable<ExpressionSyntax>)items)));
|
||
|
|
}
|
||
|
|
}
|