Files

166 lines
6.4 KiB
C#
Raw Permalink Normal View History

2026-08-27 10:56:38 -06:00
using System;
using System.Collections.Generic;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
internal sealed class LoadDirectiveTriviaSyntax : DirectiveTriviaSyntax
{
internal readonly SyntaxToken hashToken;
internal readonly SyntaxToken loadKeyword;
internal readonly SyntaxToken file;
internal readonly SyntaxToken endOfDirectiveToken;
internal readonly bool isActive;
public override SyntaxToken HashToken => hashToken;
public SyntaxToken LoadKeyword => loadKeyword;
public SyntaxToken File => file;
public override SyntaxToken EndOfDirectiveToken => endOfDirectiveToken;
public override bool IsActive => isActive;
internal LoadDirectiveTriviaSyntax(SyntaxKind kind, SyntaxToken hashToken, SyntaxToken loadKeyword, SyntaxToken file, SyntaxToken endOfDirectiveToken, bool isActive, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations)
: base(kind, diagnostics, annotations)
{
((GreenNode)this).SlotCount = 4;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)hashToken);
this.hashToken = hashToken;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)loadKeyword);
this.loadKeyword = loadKeyword;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)file);
this.file = file;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)endOfDirectiveToken);
this.endOfDirectiveToken = endOfDirectiveToken;
this.isActive = isActive;
}
internal LoadDirectiveTriviaSyntax(SyntaxKind kind, SyntaxToken hashToken, SyntaxToken loadKeyword, SyntaxToken file, SyntaxToken endOfDirectiveToken, bool isActive, SyntaxFactoryContext context)
: base(kind)
{
SetFactoryContext(context);
((GreenNode)this).SlotCount = 4;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)hashToken);
this.hashToken = hashToken;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)loadKeyword);
this.loadKeyword = loadKeyword;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)file);
this.file = file;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)endOfDirectiveToken);
this.endOfDirectiveToken = endOfDirectiveToken;
this.isActive = isActive;
}
internal LoadDirectiveTriviaSyntax(SyntaxKind kind, SyntaxToken hashToken, SyntaxToken loadKeyword, SyntaxToken file, SyntaxToken endOfDirectiveToken, bool isActive)
: base(kind)
{
((GreenNode)this).SlotCount = 4;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)hashToken);
this.hashToken = hashToken;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)loadKeyword);
this.loadKeyword = loadKeyword;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)file);
this.file = file;
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)endOfDirectiveToken);
this.endOfDirectiveToken = endOfDirectiveToken;
this.isActive = isActive;
}
internal override GreenNode? GetSlot(int index)
{
return (GreenNode?)(index switch
{
0 => hashToken,
1 => loadKeyword,
2 => file,
3 => endOfDirectiveToken,
_ => null,
});
}
internal override SyntaxNode CreateRed(SyntaxNode? parent, int position)
{
return (SyntaxNode)(object)new Microsoft.CodeAnalysis.CSharp.Syntax.LoadDirectiveTriviaSyntax(this, parent, position);
}
public override void Accept(CSharpSyntaxVisitor visitor)
{
visitor.VisitLoadDirectiveTrivia(this);
}
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
{
return visitor.VisitLoadDirectiveTrivia(this);
}
public LoadDirectiveTriviaSyntax Update(SyntaxToken hashToken, SyntaxToken loadKeyword, SyntaxToken file, SyntaxToken endOfDirectiveToken, bool isActive)
{
if (hashToken != HashToken || loadKeyword != LoadKeyword || file != File || endOfDirectiveToken != EndOfDirectiveToken)
{
LoadDirectiveTriviaSyntax loadDirectiveTriviaSyntax = SyntaxFactory.LoadDirectiveTrivia(hashToken, loadKeyword, file, endOfDirectiveToken, isActive);
DiagnosticInfo[] diagnostics = ((GreenNode)this).GetDiagnostics();
if (diagnostics != null && diagnostics.Length != 0)
{
loadDirectiveTriviaSyntax = GreenNodeExtensions.WithDiagnosticsGreen<LoadDirectiveTriviaSyntax>(loadDirectiveTriviaSyntax, diagnostics);
}
SyntaxAnnotation[] annotations = ((GreenNode)this).GetAnnotations();
if (annotations != null && annotations.Length != 0)
{
loadDirectiveTriviaSyntax = GreenNodeExtensions.WithAnnotationsGreen<LoadDirectiveTriviaSyntax>(loadDirectiveTriviaSyntax, (IEnumerable<SyntaxAnnotation>)annotations);
}
return loadDirectiveTriviaSyntax;
}
return this;
}
internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics)
{
return (GreenNode)(object)new LoadDirectiveTriviaSyntax(base.Kind, hashToken, loadKeyword, file, endOfDirectiveToken, isActive, diagnostics, ((GreenNode)this).GetAnnotations());
}
internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations)
{
return (GreenNode)(object)new LoadDirectiveTriviaSyntax(base.Kind, hashToken, loadKeyword, file, endOfDirectiveToken, isActive, ((GreenNode)this).GetDiagnostics(), annotations);
}
internal LoadDirectiveTriviaSyntax(ObjectReader reader)
: base(reader)
{
((GreenNode)this).SlotCount = 4;
SyntaxToken syntaxToken = (SyntaxToken)reader.ReadValue();
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken);
hashToken = syntaxToken;
SyntaxToken syntaxToken2 = (SyntaxToken)reader.ReadValue();
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken2);
loadKeyword = syntaxToken2;
SyntaxToken syntaxToken3 = (SyntaxToken)reader.ReadValue();
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken3);
file = syntaxToken3;
SyntaxToken syntaxToken4 = (SyntaxToken)reader.ReadValue();
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken4);
endOfDirectiveToken = syntaxToken4;
isActive = reader.ReadBoolean();
}
internal override void WriteTo(ObjectWriter writer)
{
((GreenNode)this).WriteTo(writer);
writer.WriteValue((IObjectWritable)(object)hashToken);
writer.WriteValue((IObjectWritable)(object)loadKeyword);
writer.WriteValue((IObjectWritable)(object)file);
writer.WriteValue((IObjectWritable)(object)endOfDirectiveToken);
writer.WriteBoolean(isActive);
}
static LoadDirectiveTriviaSyntax()
{
ObjectBinder.RegisterTypeReader(typeof(LoadDirectiveTriviaSyntax), (Func<ObjectReader, IObjectWritable>)((ObjectReader r) => (IObjectWritable)(object)new LoadDirectiveTriviaSyntax(r)));
}
}