459 lines
21 KiB
C#
459 lines
21 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
using Microsoft.CodeAnalysis.ErrorReporting;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
public abstract class CSharpSyntaxNode : SyntaxNode, IFormattable
|
|
{
|
|
internal SyntaxTree SyntaxTree => base._syntaxTree ?? ComputeSyntaxTree(this);
|
|
|
|
internal CSharpSyntaxNode? Parent => (CSharpSyntaxNode)(object)((SyntaxNode)this).Parent;
|
|
|
|
internal CSharpSyntaxNode? ParentOrStructuredTriviaParent => (CSharpSyntaxNode)(object)((SyntaxNode)this).ParentOrStructuredTriviaParent;
|
|
|
|
internal Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode CsGreen => (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode)(object)((SyntaxNode)this).Green;
|
|
|
|
public override string Language => "C#";
|
|
|
|
protected override SyntaxTree SyntaxTreeCore => SyntaxTree;
|
|
|
|
internal CSharpSyntaxNode(GreenNode green, SyntaxNode? parent, int position)
|
|
: base(green, parent, position)
|
|
{
|
|
}
|
|
|
|
internal CSharpSyntaxNode(GreenNode green, int position, SyntaxTree syntaxTree)
|
|
: base(green, position, syntaxTree)
|
|
{
|
|
}
|
|
|
|
private static SyntaxTree ComputeSyntaxTree(CSharpSyntaxNode node)
|
|
{
|
|
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
|
|
ArrayBuilder<CSharpSyntaxNode> val = null;
|
|
SyntaxTree val2 = null;
|
|
while (true)
|
|
{
|
|
val2 = ((SyntaxNode)node)._syntaxTree;
|
|
if (val2 != null)
|
|
{
|
|
break;
|
|
}
|
|
CSharpSyntaxNode parent = node.Parent;
|
|
if (parent == null)
|
|
{
|
|
Interlocked.CompareExchange(ref ((SyntaxNode)node)._syntaxTree, CSharpSyntaxTree.CreateWithoutClone(node), null);
|
|
val2 = ((SyntaxNode)node)._syntaxTree;
|
|
break;
|
|
}
|
|
val2 = ((SyntaxNode)parent)._syntaxTree;
|
|
if (val2 != null)
|
|
{
|
|
((SyntaxNode)node)._syntaxTree = val2;
|
|
break;
|
|
}
|
|
(val ?? (val = ArrayBuilder<CSharpSyntaxNode>.GetInstance())).Add(node);
|
|
node = parent;
|
|
}
|
|
if (val != null)
|
|
{
|
|
Enumerator<CSharpSyntaxNode> enumerator = val.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
CSharpSyntaxNode current = enumerator.Current;
|
|
if (((SyntaxNode)current)._syntaxTree != null)
|
|
{
|
|
break;
|
|
}
|
|
((SyntaxNode)current)._syntaxTree = val2;
|
|
}
|
|
val.Free();
|
|
}
|
|
return val2;
|
|
}
|
|
|
|
public abstract TResult? Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor);
|
|
|
|
public abstract void Accept(CSharpSyntaxVisitor visitor);
|
|
|
|
public SyntaxKind Kind()
|
|
{
|
|
return (SyntaxKind)((SyntaxNode)this).Green.RawKind;
|
|
}
|
|
|
|
public SyntaxTriviaList GetLeadingTrivia()
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken firstToken = GetFirstToken(includeZeroWidth: true);
|
|
return ((SyntaxToken)(ref firstToken)).LeadingTrivia;
|
|
}
|
|
|
|
public SyntaxTriviaList GetTrailingTrivia()
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken lastToken = GetLastToken(includeZeroWidth: true);
|
|
return ((SyntaxToken)(ref lastToken)).TrailingTrivia;
|
|
}
|
|
|
|
[Obsolete("Syntax serialization support is deprecated and will be removed in a future version of this API", false)]
|
|
public static SyntaxNode DeserializeFrom(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
|
|
{
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002d: Expected O, but got Unknown
|
|
if (stream == null)
|
|
{
|
|
throw new ArgumentNullException("stream");
|
|
}
|
|
if (!stream.CanRead)
|
|
{
|
|
throw new InvalidOperationException(CodeAnalysisResources.TheStreamCannotBeReadFrom);
|
|
}
|
|
FatalError.ReportNonFatalError((Exception)new SerializationDeprecationException(), (ErrorSeverity)0, false);
|
|
ObjectReader val = ObjectReader.TryGetReader(stream, true, cancellationToken);
|
|
try
|
|
{
|
|
if (val == null)
|
|
{
|
|
throw new ArgumentException(CodeAnalysisResources.Stream_contains_invalid_data, "stream");
|
|
}
|
|
return ((GreenNode)(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode)val.ReadValue()).CreateRed();
|
|
}
|
|
finally
|
|
{
|
|
((IDisposable)val)?.Dispose();
|
|
}
|
|
}
|
|
|
|
public Location GetLocation()
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Expected O, but got Unknown
|
|
return (Location)new SourceLocation((SyntaxNode)(object)this);
|
|
}
|
|
|
|
internal SyntaxReference GetReference()
|
|
{
|
|
return SyntaxTree.GetReference((SyntaxNode)(object)this);
|
|
}
|
|
|
|
public IEnumerable<Diagnostic> GetDiagnostics()
|
|
{
|
|
return SyntaxTree.GetDiagnostics((SyntaxNode)(object)this);
|
|
}
|
|
|
|
internal IList<Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax> GetDirectives(Func<Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax, bool>? filter = null)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxNodeOrToken val = SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)this);
|
|
return ((SyntaxNodeOrToken)(ref val)).GetDirectives<Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax>(filter);
|
|
}
|
|
|
|
public Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax? GetFirstDirective(Func<Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax, bool>? predicate = null)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0009: 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_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
|
|
ChildSyntaxList val = ((SyntaxNode)this).ChildNodesAndTokens();
|
|
Enumerator enumerator = ((ChildSyntaxList)(ref val)).GetEnumerator();
|
|
SyntaxNode node = default(SyntaxNode);
|
|
while (((Enumerator)(ref enumerator)).MoveNext())
|
|
{
|
|
SyntaxNodeOrToken current = ((Enumerator)(ref enumerator)).Current;
|
|
if (!((SyntaxNodeOrToken)(ref current)).ContainsDirectives)
|
|
{
|
|
continue;
|
|
}
|
|
if (((SyntaxNodeOrToken)(ref current)).AsNode(ref node))
|
|
{
|
|
Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax firstDirective = node.GetFirstDirective(predicate);
|
|
if (firstDirective != null)
|
|
{
|
|
return firstDirective;
|
|
}
|
|
continue;
|
|
}
|
|
SyntaxToken val2 = ((SyntaxNodeOrToken)(ref current)).AsToken();
|
|
SyntaxTriviaList leadingTrivia = ((SyntaxToken)(ref val2)).LeadingTrivia;
|
|
Enumerator enumerator2 = ((SyntaxTriviaList)(ref leadingTrivia)).GetEnumerator();
|
|
while (((Enumerator)(ref enumerator2)).MoveNext())
|
|
{
|
|
SyntaxTrivia current2 = ((Enumerator)(ref enumerator2)).Current;
|
|
if (((SyntaxTrivia)(ref current2)).IsDirective)
|
|
{
|
|
Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax directiveTriviaSyntax = (Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax)(object)((SyntaxTrivia)(ref current2)).GetStructure();
|
|
if (predicate == null || predicate(directiveTriviaSyntax))
|
|
{
|
|
return directiveTriviaSyntax;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax? GetLastDirective(Func<Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax, bool>? predicate = null)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0009: 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_0011: 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)
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
|
|
ChildSyntaxList val = ((SyntaxNode)this).ChildNodesAndTokens();
|
|
Reversed val2 = ((ChildSyntaxList)(ref val)).Reverse();
|
|
Enumerator enumerator = ((Reversed)(ref val2)).GetEnumerator();
|
|
SyntaxNode node = default(SyntaxNode);
|
|
while (((Enumerator)(ref enumerator)).MoveNext())
|
|
{
|
|
SyntaxNodeOrToken current = ((Enumerator)(ref enumerator)).Current;
|
|
if (!((SyntaxNodeOrToken)(ref current)).ContainsDirectives)
|
|
{
|
|
continue;
|
|
}
|
|
if (((SyntaxNodeOrToken)(ref current)).AsNode(ref node))
|
|
{
|
|
Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax lastDirective = node.GetLastDirective(predicate);
|
|
if (lastDirective != null)
|
|
{
|
|
return lastDirective;
|
|
}
|
|
continue;
|
|
}
|
|
SyntaxToken val3 = ((SyntaxNodeOrToken)(ref current)).AsToken();
|
|
SyntaxTriviaList leadingTrivia = ((SyntaxToken)(ref val3)).LeadingTrivia;
|
|
Reversed val4 = ((SyntaxTriviaList)(ref leadingTrivia)).Reverse();
|
|
Enumerator enumerator2 = ((Reversed)(ref val4)).GetEnumerator();
|
|
while (((Enumerator)(ref enumerator2)).MoveNext())
|
|
{
|
|
SyntaxTrivia current2 = ((Enumerator)(ref enumerator2)).Current;
|
|
if (((SyntaxTrivia)(ref current2)).IsDirective)
|
|
{
|
|
Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax directiveTriviaSyntax = (Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax)(object)((SyntaxTrivia)(ref current2)).GetStructure();
|
|
if (predicate == null || predicate(directiveTriviaSyntax))
|
|
{
|
|
return directiveTriviaSyntax;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public SyntaxToken GetFirstToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((SyntaxNode)this).GetFirstToken(includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
|
|
}
|
|
|
|
internal SyntaxToken GetFirstToken(Func<SyntaxToken, bool>? predicate, Func<SyntaxTrivia, bool>? stepInto = null)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
return SyntaxNavigator.Instance.GetFirstToken((SyntaxNode)(object)this, predicate, stepInto);
|
|
}
|
|
|
|
public SyntaxToken GetLastToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((SyntaxNode)this).GetLastToken(includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
|
|
}
|
|
|
|
public SyntaxToken FindToken(int position, bool findInsideTrivia = false)
|
|
{
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((SyntaxNode)this).FindToken(position, findInsideTrivia);
|
|
}
|
|
|
|
internal SyntaxToken FindTokenIncludingCrefAndNameAttributes(int position)
|
|
{
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//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)
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken result = FindToken(position);
|
|
SyntaxTrivia triviaFromSyntaxToken = SyntaxNode.GetTriviaFromSyntaxToken(position, ref result);
|
|
if (!SyntaxFacts.IsDocumentationCommentTrivia(triviaFromSyntaxToken.Kind()))
|
|
{
|
|
return result;
|
|
}
|
|
SyntaxToken result2 = ((SyntaxNode)(CSharpSyntaxNode)(object)((SyntaxTrivia)(ref triviaFromSyntaxToken)).GetStructure()).FindTokenInternal(position);
|
|
for (CSharpSyntaxNode cSharpSyntaxNode = (CSharpSyntaxNode)(object)((SyntaxToken)(ref result2)).Parent; cSharpSyntaxNode != null; cSharpSyntaxNode = cSharpSyntaxNode.Parent)
|
|
{
|
|
if (cSharpSyntaxNode.Kind() == SyntaxKind.XmlCrefAttribute || cSharpSyntaxNode.Kind() == SyntaxKind.XmlNameAttribute)
|
|
{
|
|
if (!LookupPosition.IsInXmlAttributeValue(position, (Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax)cSharpSyntaxNode))
|
|
{
|
|
return result;
|
|
}
|
|
return result2;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public SyntaxTrivia FindTrivia(int position, Func<SyntaxTrivia, bool> stepInto)
|
|
{
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((SyntaxNode)this).FindTrivia(position, stepInto);
|
|
}
|
|
|
|
public SyntaxTrivia FindTrivia(int position, bool findInsideTrivia = false)
|
|
{
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((SyntaxNode)this).FindTrivia(position, findInsideTrivia);
|
|
}
|
|
|
|
protected override bool EquivalentToCore(SyntaxNode other)
|
|
{
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxNode.cs", 475);
|
|
}
|
|
|
|
protected internal override SyntaxNode ReplaceCore<TNode>(IEnumerable<TNode>? nodes = null, Func<TNode, TNode, SyntaxNode>? computeReplacementNode = null, IEnumerable<SyntaxToken>? tokens = null, Func<SyntaxToken, SyntaxToken, SyntaxToken>? computeReplacementToken = null, IEnumerable<SyntaxTrivia>? trivia = null, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia = null)
|
|
{
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom(SyntaxReplacer.Replace((SyntaxNode)(object)this, nodes, computeReplacementNode, tokens, computeReplacementToken, trivia, computeReplacementTrivia), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode ReplaceNodeInListCore(SyntaxNode originalNode, IEnumerable<SyntaxNode> replacementNodes)
|
|
{
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom(SyntaxReplacer.ReplaceNodeInList((SyntaxNode)(object)this, originalNode, replacementNodes), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode InsertNodesInListCore(SyntaxNode nodeInList, IEnumerable<SyntaxNode> nodesToInsert, bool insertBefore)
|
|
{
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom(SyntaxReplacer.InsertNodeInList((SyntaxNode)(object)this, nodeInList, nodesToInsert, insertBefore), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode ReplaceTokenInListCore(SyntaxToken originalToken, IEnumerable<SyntaxToken> newTokens)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom(SyntaxReplacer.ReplaceTokenInList((SyntaxNode)(object)this, originalToken, newTokens), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode InsertTokensInListCore(SyntaxToken originalToken, IEnumerable<SyntaxToken> newTokens, bool insertBefore)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom(SyntaxReplacer.InsertTokenInList((SyntaxNode)(object)this, originalToken, newTokens, insertBefore), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode ReplaceTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom(SyntaxReplacer.ReplaceTriviaInList((SyntaxNode)(object)this, originalTrivia, newTrivia), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode InsertTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom(SyntaxReplacer.InsertTriviaInList((SyntaxNode)(object)this, originalTrivia, newTrivia, insertBefore), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode? RemoveNodesCore(IEnumerable<SyntaxNode> nodes, SyntaxRemoveOptions options)
|
|
{
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom((SyntaxNode)(object)SyntaxNodeRemover.RemoveNodes(this, (IEnumerable<SyntaxNode>)nodes.Cast<CSharpSyntaxNode>(), options), SyntaxTree);
|
|
}
|
|
|
|
protected internal override SyntaxNode NormalizeWhitespaceCore(string indentation, string eol, bool elasticTrivia)
|
|
{
|
|
return SyntaxNodeExtensions.AsRootOfNewTreeWithOptionsFrom((SyntaxNode)(object)SyntaxNormalizer.Normalize(this, indentation, eol, elasticTrivia), SyntaxTree);
|
|
}
|
|
|
|
protected override bool IsEquivalentToCore(SyntaxNode node, bool topLevel = false)
|
|
{
|
|
return SyntaxFactory.AreEquivalent((SyntaxNode?)(object)this, (SyntaxNode?)(object)(CSharpSyntaxNode)(object)node, topLevel);
|
|
}
|
|
|
|
internal override bool ShouldCreateWeakList()
|
|
{
|
|
if (Kind() == SyntaxKind.Block)
|
|
{
|
|
CSharpSyntaxNode parent = Parent;
|
|
if (parent is Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax || parent is Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
string IFormattable.ToString(string? format, IFormatProvider? formatProvider)
|
|
{
|
|
return ((object)this).ToString();
|
|
}
|
|
|
|
internal string Dump()
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return TreeDumper.DumpCompact(makeTree(SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)this)));
|
|
static TreeDumperNode makeTree(SyntaxNodeOrToken nodeOrToken)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0072: Expected O, but got Unknown
|
|
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005b: Expected O, but got Unknown
|
|
string text = nodeOrToken.Kind().ToString();
|
|
SyntaxNode val = default(SyntaxNode);
|
|
if (((SyntaxNodeOrToken)(ref nodeOrToken)).AsNode(ref val) && !(val is Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax))
|
|
{
|
|
return new TreeDumperNode(text, (object)null, ((IEnumerable<SyntaxNodeOrToken>)(object)val.ChildNodesAndTokens()).Select(makeTree));
|
|
}
|
|
return new TreeDumperNode(text + " " + stringOrMissing(nodeOrToken));
|
|
}
|
|
static string stringOrMissing(SyntaxNodeOrToken nodeOrToken)
|
|
{
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
if (!((SyntaxNodeOrToken)(ref nodeOrToken)).IsMissing)
|
|
{
|
|
return $"\"{nodeOrToken}\"";
|
|
}
|
|
return "<missing>";
|
|
}
|
|
}
|
|
}
|