130 lines
3.8 KiB
C#
130 lines
3.8 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 XmlTextSyntax : XmlNodeSyntax
|
|
{
|
|
internal readonly GreenNode? textTokens;
|
|
|
|
public SyntaxList<SyntaxToken> TextTokens => new SyntaxList<SyntaxToken>(textTokens);
|
|
|
|
internal XmlTextSyntax(SyntaxKind kind, GreenNode? textTokens, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations)
|
|
: base(kind, diagnostics, annotations)
|
|
{
|
|
((GreenNode)this).SlotCount = 1;
|
|
if (textTokens != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(textTokens);
|
|
this.textTokens = textTokens;
|
|
}
|
|
}
|
|
|
|
internal XmlTextSyntax(SyntaxKind kind, GreenNode? textTokens, SyntaxFactoryContext context)
|
|
: base(kind)
|
|
{
|
|
SetFactoryContext(context);
|
|
((GreenNode)this).SlotCount = 1;
|
|
if (textTokens != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(textTokens);
|
|
this.textTokens = textTokens;
|
|
}
|
|
}
|
|
|
|
internal XmlTextSyntax(SyntaxKind kind, GreenNode? textTokens)
|
|
: base(kind)
|
|
{
|
|
((GreenNode)this).SlotCount = 1;
|
|
if (textTokens != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(textTokens);
|
|
this.textTokens = textTokens;
|
|
}
|
|
}
|
|
|
|
internal override GreenNode? GetSlot(int index)
|
|
{
|
|
if (index != 0)
|
|
{
|
|
return null;
|
|
}
|
|
return textTokens;
|
|
}
|
|
|
|
internal override SyntaxNode CreateRed(SyntaxNode? parent, int position)
|
|
{
|
|
return (SyntaxNode)(object)new Microsoft.CodeAnalysis.CSharp.Syntax.XmlTextSyntax(this, parent, position);
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitXmlText(this);
|
|
}
|
|
|
|
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitXmlText(this);
|
|
}
|
|
|
|
public XmlTextSyntax Update(SyntaxList<SyntaxToken> textTokens)
|
|
{
|
|
//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_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
if (textTokens != TextTokens)
|
|
{
|
|
XmlTextSyntax xmlTextSyntax = SyntaxFactory.XmlText(textTokens);
|
|
DiagnosticInfo[] diagnostics = ((GreenNode)this).GetDiagnostics();
|
|
if (diagnostics != null && diagnostics.Length != 0)
|
|
{
|
|
xmlTextSyntax = GreenNodeExtensions.WithDiagnosticsGreen<XmlTextSyntax>(xmlTextSyntax, diagnostics);
|
|
}
|
|
SyntaxAnnotation[] annotations = ((GreenNode)this).GetAnnotations();
|
|
if (annotations != null && annotations.Length != 0)
|
|
{
|
|
xmlTextSyntax = GreenNodeExtensions.WithAnnotationsGreen<XmlTextSyntax>(xmlTextSyntax, (IEnumerable<SyntaxAnnotation>)annotations);
|
|
}
|
|
return xmlTextSyntax;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics)
|
|
{
|
|
return (GreenNode)(object)new XmlTextSyntax(base.Kind, textTokens, diagnostics, ((GreenNode)this).GetAnnotations());
|
|
}
|
|
|
|
internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations)
|
|
{
|
|
return (GreenNode)(object)new XmlTextSyntax(base.Kind, textTokens, ((GreenNode)this).GetDiagnostics(), annotations);
|
|
}
|
|
|
|
internal XmlTextSyntax(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
|
|
((GreenNode)this).SlotCount = 1;
|
|
GreenNode val = (GreenNode)reader.ReadValue();
|
|
if (val != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(val);
|
|
textTokens = val;
|
|
}
|
|
}
|
|
|
|
internal override void WriteTo(ObjectWriter writer)
|
|
{
|
|
((GreenNode)this).WriteTo(writer);
|
|
writer.WriteValue((IObjectWritable)(object)textTokens);
|
|
}
|
|
|
|
static XmlTextSyntax()
|
|
{
|
|
ObjectBinder.RegisterTypeReader(typeof(XmlTextSyntax), (Func<ObjectReader, IObjectWritable>)((ObjectReader r) => (IObjectWritable)(object)new XmlTextSyntax(r)));
|
|
}
|
|
}
|