258 lines
9.2 KiB
C#
258 lines
9.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.CodeAnalysis.Syntax.InternalSyntax;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
internal sealed class AccessorDeclarationSyntax : CSharpSyntaxNode
|
|
{
|
|
internal readonly GreenNode? attributeLists;
|
|
|
|
internal readonly GreenNode? modifiers;
|
|
|
|
internal readonly SyntaxToken keyword;
|
|
|
|
internal readonly BlockSyntax? body;
|
|
|
|
internal readonly ArrowExpressionClauseSyntax? expressionBody;
|
|
|
|
internal readonly SyntaxToken? semicolonToken;
|
|
|
|
public SyntaxList<AttributeListSyntax> AttributeLists => new SyntaxList<AttributeListSyntax>(attributeLists);
|
|
|
|
public SyntaxList<SyntaxToken> Modifiers => new SyntaxList<SyntaxToken>(modifiers);
|
|
|
|
public SyntaxToken Keyword => keyword;
|
|
|
|
public BlockSyntax? Body => body;
|
|
|
|
public ArrowExpressionClauseSyntax? ExpressionBody => expressionBody;
|
|
|
|
public SyntaxToken? SemicolonToken => semicolonToken;
|
|
|
|
internal AccessorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken keyword, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations)
|
|
: base(kind, diagnostics, annotations)
|
|
{
|
|
((GreenNode)this).SlotCount = 6;
|
|
if (attributeLists != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
|
this.attributeLists = attributeLists;
|
|
}
|
|
if (modifiers != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(modifiers);
|
|
this.modifiers = modifiers;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)keyword);
|
|
this.keyword = keyword;
|
|
if (body != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)body);
|
|
this.body = body;
|
|
}
|
|
if (expressionBody != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)expressionBody);
|
|
this.expressionBody = expressionBody;
|
|
}
|
|
if (semicolonToken != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)semicolonToken);
|
|
this.semicolonToken = semicolonToken;
|
|
}
|
|
}
|
|
|
|
internal AccessorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken keyword, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, SyntaxFactoryContext context)
|
|
: base(kind)
|
|
{
|
|
SetFactoryContext(context);
|
|
((GreenNode)this).SlotCount = 6;
|
|
if (attributeLists != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
|
this.attributeLists = attributeLists;
|
|
}
|
|
if (modifiers != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(modifiers);
|
|
this.modifiers = modifiers;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)keyword);
|
|
this.keyword = keyword;
|
|
if (body != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)body);
|
|
this.body = body;
|
|
}
|
|
if (expressionBody != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)expressionBody);
|
|
this.expressionBody = expressionBody;
|
|
}
|
|
if (semicolonToken != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)semicolonToken);
|
|
this.semicolonToken = semicolonToken;
|
|
}
|
|
}
|
|
|
|
internal AccessorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken keyword, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken)
|
|
: base(kind)
|
|
{
|
|
((GreenNode)this).SlotCount = 6;
|
|
if (attributeLists != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
|
this.attributeLists = attributeLists;
|
|
}
|
|
if (modifiers != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(modifiers);
|
|
this.modifiers = modifiers;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)keyword);
|
|
this.keyword = keyword;
|
|
if (body != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)body);
|
|
this.body = body;
|
|
}
|
|
if (expressionBody != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)expressionBody);
|
|
this.expressionBody = expressionBody;
|
|
}
|
|
if (semicolonToken != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)semicolonToken);
|
|
this.semicolonToken = semicolonToken;
|
|
}
|
|
}
|
|
|
|
internal override GreenNode? GetSlot(int index)
|
|
{
|
|
return (GreenNode?)(index switch
|
|
{
|
|
0 => attributeLists,
|
|
1 => modifiers,
|
|
2 => keyword,
|
|
3 => body,
|
|
4 => expressionBody,
|
|
5 => semicolonToken,
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
internal override SyntaxNode CreateRed(SyntaxNode? parent, int position)
|
|
{
|
|
return (SyntaxNode)(object)new Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax(this, parent, position);
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitAccessorDeclaration(this);
|
|
}
|
|
|
|
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitAccessorDeclaration(this);
|
|
}
|
|
|
|
public AccessorDeclarationSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxList<SyntaxToken> modifiers, SyntaxToken keyword, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken)
|
|
{
|
|
//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_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
if (attributeLists != AttributeLists || modifiers != Modifiers || keyword != Keyword || body != Body || expressionBody != ExpressionBody || semicolonToken != SemicolonToken)
|
|
{
|
|
AccessorDeclarationSyntax accessorDeclarationSyntax = SyntaxFactory.AccessorDeclaration(base.Kind, attributeLists, modifiers, keyword, body, expressionBody, semicolonToken);
|
|
DiagnosticInfo[] diagnostics = ((GreenNode)this).GetDiagnostics();
|
|
if (diagnostics != null && diagnostics.Length != 0)
|
|
{
|
|
accessorDeclarationSyntax = GreenNodeExtensions.WithDiagnosticsGreen<AccessorDeclarationSyntax>(accessorDeclarationSyntax, diagnostics);
|
|
}
|
|
SyntaxAnnotation[] annotations = ((GreenNode)this).GetAnnotations();
|
|
if (annotations != null && annotations.Length != 0)
|
|
{
|
|
accessorDeclarationSyntax = GreenNodeExtensions.WithAnnotationsGreen<AccessorDeclarationSyntax>(accessorDeclarationSyntax, (IEnumerable<SyntaxAnnotation>)annotations);
|
|
}
|
|
return accessorDeclarationSyntax;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics)
|
|
{
|
|
return (GreenNode)(object)new AccessorDeclarationSyntax(base.Kind, attributeLists, modifiers, keyword, body, expressionBody, semicolonToken, diagnostics, ((GreenNode)this).GetAnnotations());
|
|
}
|
|
|
|
internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations)
|
|
{
|
|
return (GreenNode)(object)new AccessorDeclarationSyntax(base.Kind, attributeLists, modifiers, keyword, body, expressionBody, semicolonToken, ((GreenNode)this).GetDiagnostics(), annotations);
|
|
}
|
|
|
|
internal AccessorDeclarationSyntax(ObjectReader reader)
|
|
: base(reader)
|
|
{
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001a: Expected O, but got Unknown
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0037: Expected O, but got Unknown
|
|
((GreenNode)this).SlotCount = 6;
|
|
GreenNode val = (GreenNode)reader.ReadValue();
|
|
if (val != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(val);
|
|
attributeLists = val;
|
|
}
|
|
GreenNode val2 = (GreenNode)reader.ReadValue();
|
|
if (val2 != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(val2);
|
|
modifiers = val2;
|
|
}
|
|
SyntaxToken syntaxToken = (SyntaxToken)reader.ReadValue();
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken);
|
|
keyword = syntaxToken;
|
|
BlockSyntax blockSyntax = (BlockSyntax)reader.ReadValue();
|
|
if (blockSyntax != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)blockSyntax);
|
|
body = blockSyntax;
|
|
}
|
|
ArrowExpressionClauseSyntax arrowExpressionClauseSyntax = (ArrowExpressionClauseSyntax)reader.ReadValue();
|
|
if (arrowExpressionClauseSyntax != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)arrowExpressionClauseSyntax);
|
|
expressionBody = arrowExpressionClauseSyntax;
|
|
}
|
|
SyntaxToken syntaxToken2 = (SyntaxToken)reader.ReadValue();
|
|
if (syntaxToken2 != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken2);
|
|
semicolonToken = syntaxToken2;
|
|
}
|
|
}
|
|
|
|
internal override void WriteTo(ObjectWriter writer)
|
|
{
|
|
((GreenNode)this).WriteTo(writer);
|
|
writer.WriteValue((IObjectWritable)(object)attributeLists);
|
|
writer.WriteValue((IObjectWritable)(object)modifiers);
|
|
writer.WriteValue((IObjectWritable)(object)keyword);
|
|
writer.WriteValue((IObjectWritable)(object)body);
|
|
writer.WriteValue((IObjectWritable)(object)expressionBody);
|
|
writer.WriteValue((IObjectWritable)(object)semicolonToken);
|
|
}
|
|
|
|
static AccessorDeclarationSyntax()
|
|
{
|
|
ObjectBinder.RegisterTypeReader(typeof(AccessorDeclarationSyntax), (Func<ObjectReader, IObjectWritable>)((ObjectReader r) => (IObjectWritable)(object)new AccessorDeclarationSyntax(r)));
|
|
}
|
|
}
|