Files
2026-08-27 10:56:38 -06:00

103 lines
3.4 KiB
C#

using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
public sealed class VariableDeclarationSyntax : CSharpSyntaxNode
{
private TypeSyntax? type;
private SyntaxNode? variables;
public TypeSyntax Type => ((SyntaxNode)this).GetRedAtZero<TypeSyntax>(ref type);
public SeparatedSyntaxList<VariableDeclaratorSyntax> Variables
{
get
{
//IL_0023: 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)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
SyntaxNode red = ((SyntaxNode)this).GetRed(ref variables, 1);
if (red == null)
{
return default(SeparatedSyntaxList<VariableDeclaratorSyntax>);
}
return new SeparatedSyntaxList<VariableDeclaratorSyntax>(red, ((SyntaxNode)this).GetChildIndex(1));
}
}
internal VariableDeclarationSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)
: base((GreenNode)(object)green, parent, position)
{
}
internal override SyntaxNode? GetNodeSlot(int index)
{
return (SyntaxNode?)(index switch
{
0 => ((SyntaxNode)this).GetRedAtZero<TypeSyntax>(ref type),
1 => ((SyntaxNode)this).GetRed(ref variables, 1),
_ => null,
});
}
internal override SyntaxNode? GetCachedSlot(int index)
{
return (SyntaxNode?)(index switch
{
0 => type,
1 => variables,
_ => null,
});
}
public override void Accept(CSharpSyntaxVisitor visitor)
{
visitor.VisitVariableDeclaration(this);
}
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
{
return visitor.VisitVariableDeclaration(this);
}
public VariableDeclarationSyntax Update(TypeSyntax type, SeparatedSyntaxList<VariableDeclaratorSyntax> variables)
{
//IL_0018: 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 (type != Type || variables != Variables)
{
VariableDeclarationSyntax variableDeclarationSyntax = SyntaxFactory.VariableDeclaration(type, variables);
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
if (annotations == null || annotations.Length == 0)
{
return variableDeclarationSyntax;
}
return variableDeclarationSyntax.WithAnnotations(annotations);
}
return this;
}
public VariableDeclarationSyntax WithType(TypeSyntax type)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return Update(type, Variables);
}
public VariableDeclarationSyntax WithVariables(SeparatedSyntaxList<VariableDeclaratorSyntax> variables)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return Update(Type, variables);
}
public VariableDeclarationSyntax AddVariables(params VariableDeclaratorSyntax[] 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 WithVariables(Variables.AddRange((IEnumerable<VariableDeclaratorSyntax>)items));
}
}