241 lines
8.6 KiB
C#
241 lines
8.6 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 CompilationUnitSyntax : CSharpSyntaxNode
|
||
|
|
{
|
||
|
|
internal readonly GreenNode? externs;
|
||
|
|
|
||
|
|
internal readonly GreenNode? usings;
|
||
|
|
|
||
|
|
internal readonly GreenNode? attributeLists;
|
||
|
|
|
||
|
|
internal readonly GreenNode? members;
|
||
|
|
|
||
|
|
internal readonly SyntaxToken endOfFileToken;
|
||
|
|
|
||
|
|
public SyntaxList<ExternAliasDirectiveSyntax> Externs => new SyntaxList<ExternAliasDirectiveSyntax>(externs);
|
||
|
|
|
||
|
|
public SyntaxList<UsingDirectiveSyntax> Usings => new SyntaxList<UsingDirectiveSyntax>(usings);
|
||
|
|
|
||
|
|
public SyntaxList<AttributeListSyntax> AttributeLists => new SyntaxList<AttributeListSyntax>(attributeLists);
|
||
|
|
|
||
|
|
public SyntaxList<MemberDeclarationSyntax> Members => new SyntaxList<MemberDeclarationSyntax>(members);
|
||
|
|
|
||
|
|
public SyntaxToken EndOfFileToken => endOfFileToken;
|
||
|
|
|
||
|
|
internal CompilationUnitSyntax(SyntaxKind kind, GreenNode? externs, GreenNode? usings, GreenNode? attributeLists, GreenNode? members, SyntaxToken endOfFileToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations)
|
||
|
|
: base(kind, diagnostics, annotations)
|
||
|
|
{
|
||
|
|
((GreenNode)this).SlotCount = 5;
|
||
|
|
if (externs != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(externs);
|
||
|
|
this.externs = externs;
|
||
|
|
}
|
||
|
|
if (usings != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(usings);
|
||
|
|
this.usings = usings;
|
||
|
|
}
|
||
|
|
if (attributeLists != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
||
|
|
this.attributeLists = attributeLists;
|
||
|
|
}
|
||
|
|
if (members != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(members);
|
||
|
|
this.members = members;
|
||
|
|
}
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)endOfFileToken);
|
||
|
|
this.endOfFileToken = endOfFileToken;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal CompilationUnitSyntax(SyntaxKind kind, GreenNode? externs, GreenNode? usings, GreenNode? attributeLists, GreenNode? members, SyntaxToken endOfFileToken, SyntaxFactoryContext context)
|
||
|
|
: base(kind)
|
||
|
|
{
|
||
|
|
SetFactoryContext(context);
|
||
|
|
((GreenNode)this).SlotCount = 5;
|
||
|
|
if (externs != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(externs);
|
||
|
|
this.externs = externs;
|
||
|
|
}
|
||
|
|
if (usings != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(usings);
|
||
|
|
this.usings = usings;
|
||
|
|
}
|
||
|
|
if (attributeLists != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
||
|
|
this.attributeLists = attributeLists;
|
||
|
|
}
|
||
|
|
if (members != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(members);
|
||
|
|
this.members = members;
|
||
|
|
}
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)endOfFileToken);
|
||
|
|
this.endOfFileToken = endOfFileToken;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal CompilationUnitSyntax(SyntaxKind kind, GreenNode? externs, GreenNode? usings, GreenNode? attributeLists, GreenNode? members, SyntaxToken endOfFileToken)
|
||
|
|
: base(kind)
|
||
|
|
{
|
||
|
|
((GreenNode)this).SlotCount = 5;
|
||
|
|
if (externs != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(externs);
|
||
|
|
this.externs = externs;
|
||
|
|
}
|
||
|
|
if (usings != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(usings);
|
||
|
|
this.usings = usings;
|
||
|
|
}
|
||
|
|
if (attributeLists != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
||
|
|
this.attributeLists = attributeLists;
|
||
|
|
}
|
||
|
|
if (members != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(members);
|
||
|
|
this.members = members;
|
||
|
|
}
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)endOfFileToken);
|
||
|
|
this.endOfFileToken = endOfFileToken;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override GreenNode? GetSlot(int index)
|
||
|
|
{
|
||
|
|
return (GreenNode?)(index switch
|
||
|
|
{
|
||
|
|
0 => externs,
|
||
|
|
1 => usings,
|
||
|
|
2 => attributeLists,
|
||
|
|
3 => members,
|
||
|
|
4 => endOfFileToken,
|
||
|
|
_ => null,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SyntaxNode CreateRed(SyntaxNode? parent, int position)
|
||
|
|
{
|
||
|
|
return (SyntaxNode)(object)new Microsoft.CodeAnalysis.CSharp.Syntax.CompilationUnitSyntax(this, parent, position);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
||
|
|
{
|
||
|
|
visitor.VisitCompilationUnit(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitCompilationUnit(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public CompilationUnitSyntax Update(SyntaxList<ExternAliasDirectiveSyntax> externs, SyntaxList<UsingDirectiveSyntax> usings, SyntaxList<AttributeListSyntax> attributeLists, SyntaxList<MemberDeclarationSyntax> members, SyntaxToken endOfFileToken)
|
||
|
|
{
|
||
|
|
//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_0043: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0046: 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)
|
||
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001e: 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 (externs != Externs || usings != Usings || attributeLists != AttributeLists || members != Members || endOfFileToken != EndOfFileToken)
|
||
|
|
{
|
||
|
|
CompilationUnitSyntax compilationUnitSyntax = SyntaxFactory.CompilationUnit(externs, usings, attributeLists, members, endOfFileToken);
|
||
|
|
DiagnosticInfo[] diagnostics = ((GreenNode)this).GetDiagnostics();
|
||
|
|
if (diagnostics != null && diagnostics.Length != 0)
|
||
|
|
{
|
||
|
|
compilationUnitSyntax = GreenNodeExtensions.WithDiagnosticsGreen<CompilationUnitSyntax>(compilationUnitSyntax, diagnostics);
|
||
|
|
}
|
||
|
|
SyntaxAnnotation[] annotations = ((GreenNode)this).GetAnnotations();
|
||
|
|
if (annotations != null && annotations.Length != 0)
|
||
|
|
{
|
||
|
|
compilationUnitSyntax = GreenNodeExtensions.WithAnnotationsGreen<CompilationUnitSyntax>(compilationUnitSyntax, (IEnumerable<SyntaxAnnotation>)annotations);
|
||
|
|
}
|
||
|
|
return compilationUnitSyntax;
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics)
|
||
|
|
{
|
||
|
|
return (GreenNode)(object)new CompilationUnitSyntax(base.Kind, externs, usings, attributeLists, members, endOfFileToken, diagnostics, ((GreenNode)this).GetAnnotations());
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations)
|
||
|
|
{
|
||
|
|
return (GreenNode)(object)new CompilationUnitSyntax(base.Kind, externs, usings, attributeLists, members, endOfFileToken, ((GreenNode)this).GetDiagnostics(), annotations);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal CompilationUnitSyntax(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
|
||
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0054: Expected O, but got Unknown
|
||
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0071: Expected O, but got Unknown
|
||
|
|
((GreenNode)this).SlotCount = 5;
|
||
|
|
GreenNode val = (GreenNode)reader.ReadValue();
|
||
|
|
if (val != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(val);
|
||
|
|
externs = val;
|
||
|
|
}
|
||
|
|
GreenNode val2 = (GreenNode)reader.ReadValue();
|
||
|
|
if (val2 != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(val2);
|
||
|
|
usings = val2;
|
||
|
|
}
|
||
|
|
GreenNode val3 = (GreenNode)reader.ReadValue();
|
||
|
|
if (val3 != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(val3);
|
||
|
|
attributeLists = val3;
|
||
|
|
}
|
||
|
|
GreenNode val4 = (GreenNode)reader.ReadValue();
|
||
|
|
if (val4 != null)
|
||
|
|
{
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth(val4);
|
||
|
|
members = val4;
|
||
|
|
}
|
||
|
|
SyntaxToken syntaxToken = (SyntaxToken)reader.ReadValue();
|
||
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken);
|
||
|
|
endOfFileToken = syntaxToken;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override void WriteTo(ObjectWriter writer)
|
||
|
|
{
|
||
|
|
((GreenNode)this).WriteTo(writer);
|
||
|
|
writer.WriteValue((IObjectWritable)(object)externs);
|
||
|
|
writer.WriteValue((IObjectWritable)(object)usings);
|
||
|
|
writer.WriteValue((IObjectWritable)(object)attributeLists);
|
||
|
|
writer.WriteValue((IObjectWritable)(object)members);
|
||
|
|
writer.WriteValue((IObjectWritable)(object)endOfFileToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
static CompilationUnitSyntax()
|
||
|
|
{
|
||
|
|
ObjectBinder.RegisterTypeReader(typeof(CompilationUnitSyntax), (Func<ObjectReader, IObjectWritable>)((ObjectReader r) => (IObjectWritable)(object)new CompilationUnitSyntax(r)));
|
||
|
|
}
|
||
|
|
}
|