116 lines
5.2 KiB
C#
116 lines
5.2 KiB
C#
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
|
||
|
|
public sealed class InterpolationSyntax : InterpolatedStringContentSyntax
|
||
|
|
{
|
||
|
|
private ExpressionSyntax? expression;
|
||
|
|
|
||
|
|
private InterpolationAlignmentClauseSyntax? alignmentClause;
|
||
|
|
|
||
|
|
private InterpolationFormatClauseSyntax? formatClause;
|
||
|
|
|
||
|
|
public SyntaxToken OpenBraceToken => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.InterpolationSyntax)(object)((SyntaxNode)this).Green).openBraceToken, ((SyntaxNode)this).Position, 0);
|
||
|
|
|
||
|
|
public ExpressionSyntax Expression => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expression, 1);
|
||
|
|
|
||
|
|
public InterpolationAlignmentClauseSyntax? AlignmentClause => ((SyntaxNode)this).GetRed<InterpolationAlignmentClauseSyntax>(ref alignmentClause, 2);
|
||
|
|
|
||
|
|
public InterpolationFormatClauseSyntax? FormatClause => ((SyntaxNode)this).GetRed<InterpolationFormatClauseSyntax>(ref formatClause, 3);
|
||
|
|
|
||
|
|
public SyntaxToken CloseBraceToken => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.InterpolationSyntax)(object)((SyntaxNode)this).Green).closeBraceToken, ((SyntaxNode)this).GetChildPosition(4), ((SyntaxNode)this).GetChildIndex(4));
|
||
|
|
|
||
|
|
internal InterpolationSyntax(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
|
||
|
|
{
|
||
|
|
1 => ((SyntaxNode)this).GetRed<ExpressionSyntax>(ref expression, 1),
|
||
|
|
2 => ((SyntaxNode)this).GetRed<InterpolationAlignmentClauseSyntax>(ref alignmentClause, 2),
|
||
|
|
3 => ((SyntaxNode)this).GetRed<InterpolationFormatClauseSyntax>(ref formatClause, 3),
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
||
|
|
{
|
||
|
|
return (SyntaxNode?)(index switch
|
||
|
|
{
|
||
|
|
1 => expression,
|
||
|
|
2 => alignmentClause,
|
||
|
|
3 => formatClause,
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitInterpolation(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitInterpolation(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public InterpolationSyntax Update(SyntaxToken openBraceToken, ExpressionSyntax expression, InterpolationAlignmentClauseSyntax? alignmentClause, InterpolationFormatClauseSyntax? formatClause, SyntaxToken closeBraceToken)
|
||
|
|
{
|
||
|
|
//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_003e: 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)
|
||
|
|
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (openBraceToken != OpenBraceToken || expression != Expression || alignmentClause != AlignmentClause || formatClause != FormatClause || closeBraceToken != CloseBraceToken)
|
||
|
|
{
|
||
|
|
InterpolationSyntax interpolationSyntax = SyntaxFactory.Interpolation(openBraceToken, expression, alignmentClause, formatClause, closeBraceToken);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return interpolationSyntax;
|
||
|
|
}
|
||
|
|
return interpolationSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public InterpolationSyntax WithOpenBraceToken(SyntaxToken openBraceToken)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(openBraceToken, Expression, AlignmentClause, FormatClause, CloseBraceToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public InterpolationSyntax WithExpression(ExpressionSyntax expression)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(OpenBraceToken, expression, AlignmentClause, FormatClause, CloseBraceToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public InterpolationSyntax WithAlignmentClause(InterpolationAlignmentClauseSyntax? alignmentClause)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(OpenBraceToken, Expression, alignmentClause, FormatClause, CloseBraceToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public InterpolationSyntax WithFormatClause(InterpolationFormatClauseSyntax? formatClause)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(OpenBraceToken, Expression, AlignmentClause, formatClause, CloseBraceToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public InterpolationSyntax WithCloseBraceToken(SyntaxToken closeBraceToken)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(OpenBraceToken, Expression, AlignmentClause, FormatClause, closeBraceToken);
|
||
|
|
}
|
||
|
|
}
|