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 ArrayCreationExpressionSyntax : ExpressionSyntax
|
||
|
|
{
|
||
|
|
private ArrayTypeSyntax? type;
|
||
|
|
|
||
|
|
private InitializerExpressionSyntax? initializer;
|
||
|
|
|
||
|
|
public SyntaxToken NewKeyword => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ArrayCreationExpressionSyntax)(object)((SyntaxNode)this).Green).newKeyword, ((SyntaxNode)this).Position, 0);
|
||
|
|
|
||
|
|
public ArrayTypeSyntax Type => ((SyntaxNode)this).GetRed<ArrayTypeSyntax>(ref type, 1);
|
||
|
|
|
||
|
|
public InitializerExpressionSyntax? Initializer => ((SyntaxNode)this).GetRed<InitializerExpressionSyntax>(ref initializer, 2);
|
||
|
|
|
||
|
|
internal ArrayCreationExpressionSyntax(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<ArrayTypeSyntax>(ref type, 1),
|
||
|
|
2 => ((SyntaxNode)this).GetRed<InitializerExpressionSyntax>(ref initializer, 2),
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
||
|
|
{
|
||
|
|
return (SyntaxNode?)(index switch
|
||
|
|
{
|
||
|
|
1 => type,
|
||
|
|
2 => initializer,
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitArrayCreationExpression(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitArrayCreationExpression(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ArrayCreationExpressionSyntax Update(SyntaxToken newKeyword, ArrayTypeSyntax type, InitializerExpressionSyntax? initializer)
|
||
|
|
{
|
||
|
|
//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_0020: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (newKeyword != NewKeyword || type != Type || initializer != Initializer)
|
||
|
|
{
|
||
|
|
ArrayCreationExpressionSyntax arrayCreationExpressionSyntax = SyntaxFactory.ArrayCreationExpression(newKeyword, type, initializer);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return arrayCreationExpressionSyntax;
|
||
|
|
}
|
||
|
|
return arrayCreationExpressionSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public ArrayCreationExpressionSyntax WithNewKeyword(SyntaxToken newKeyword)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(newKeyword, Type, Initializer);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ArrayCreationExpressionSyntax WithType(ArrayTypeSyntax type)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(NewKeyword, type, Initializer);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ArrayCreationExpressionSyntax WithInitializer(InitializerExpressionSyntax? initializer)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(NewKeyword, Type, initializer);
|
||
|
|
}
|
||
|
|
|
||
|
|
public ArrayCreationExpressionSyntax AddTypeRankSpecifiers(params ArrayRankSpecifierSyntax[] 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 WithType(Type.WithRankSpecifiers(Type.RankSpecifiers.AddRange((IEnumerable<ArrayRankSpecifierSyntax>)items)));
|
||
|
|
}
|
||
|
|
}
|