107 lines
3.9 KiB
C#
107 lines
3.9 KiB
C#
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
||
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
||
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
|
||
|
|
public sealed class GenericNameSyntax : SimpleNameSyntax
|
||
|
|
{
|
||
|
|
private TypeArgumentListSyntax? typeArgumentList;
|
||
|
|
|
||
|
|
public bool IsUnboundGenericName => TypeArgumentList.Arguments.Any<TypeSyntax>(SyntaxKind.OmittedTypeArgument);
|
||
|
|
|
||
|
|
public override SyntaxToken Identifier => new SyntaxToken((SyntaxNode)(object)this, (GreenNode)(object)((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.GenericNameSyntax)(object)((SyntaxNode)this).Green).identifier, ((SyntaxNode)this).Position, 0);
|
||
|
|
|
||
|
|
public TypeArgumentListSyntax TypeArgumentList => ((SyntaxNode)this).GetRed<TypeArgumentListSyntax>(ref typeArgumentList, 1);
|
||
|
|
|
||
|
|
internal override string ErrorDisplayName()
|
||
|
|
{
|
||
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
PooledStringBuilder instance = PooledStringBuilder.GetInstance();
|
||
|
|
StringBuilder builder = instance.Builder;
|
||
|
|
SyntaxToken identifier = Identifier;
|
||
|
|
builder.Append(((SyntaxToken)(ref identifier)).ValueText).Append("<").Append(',', base.Arity - 1)
|
||
|
|
.Append(">");
|
||
|
|
return instance.ToStringAndFree();
|
||
|
|
}
|
||
|
|
|
||
|
|
internal GenericNameSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)
|
||
|
|
: base(green, parent, position)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetNodeSlot(int index)
|
||
|
|
{
|
||
|
|
if (index != 1)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return (SyntaxNode?)(object)((SyntaxNode)this).GetRed<TypeArgumentListSyntax>(ref typeArgumentList, 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode? GetCachedSlot(int index)
|
||
|
|
{
|
||
|
|
if (index != 1)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return (SyntaxNode?)(object)typeArgumentList;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitGenericName(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitGenericName(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public GenericNameSyntax Update(SyntaxToken identifier, TypeArgumentListSyntax typeArgumentList)
|
||
|
|
{
|
||
|
|
//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_0017: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (identifier != Identifier || typeArgumentList != TypeArgumentList)
|
||
|
|
{
|
||
|
|
GenericNameSyntax genericNameSyntax = SyntaxFactory.GenericName(identifier, typeArgumentList);
|
||
|
|
SyntaxAnnotation[] annotations = ((SyntaxNode)this).GetAnnotations();
|
||
|
|
if (annotations == null || annotations.Length == 0)
|
||
|
|
{
|
||
|
|
return genericNameSyntax;
|
||
|
|
}
|
||
|
|
return genericNameSyntax.WithAnnotations(annotations);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SimpleNameSyntax WithIdentifierCore(SyntaxToken identifier)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return WithIdentifier(identifier);
|
||
|
|
}
|
||
|
|
|
||
|
|
public new GenericNameSyntax WithIdentifier(SyntaxToken identifier)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(identifier, TypeArgumentList);
|
||
|
|
}
|
||
|
|
|
||
|
|
public GenericNameSyntax WithTypeArgumentList(TypeArgumentListSyntax typeArgumentList)
|
||
|
|
{
|
||
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return Update(Identifier, typeArgumentList);
|
||
|
|
}
|
||
|
|
|
||
|
|
public GenericNameSyntax AddTypeArgumentListArguments(params TypeSyntax[] 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 WithTypeArgumentList(TypeArgumentList.WithArguments(TypeArgumentList.Arguments.AddRange((IEnumerable<TypeSyntax>)items)));
|
||
|
|
}
|
||
|
|
}
|