126 lines
4.8 KiB
C#
126 lines
4.8 KiB
C#
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
public abstract class CSharpSyntaxWalker : CSharpSyntaxVisitor
|
|
{
|
|
private int _recursionDepth;
|
|
|
|
protected SyntaxWalkerDepth Depth { get; }
|
|
|
|
protected CSharpSyntaxWalker(SyntaxWalkerDepth depth = (SyntaxWalkerDepth)0)
|
|
{
|
|
//IL_0007: 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)
|
|
Depth = depth;
|
|
}
|
|
|
|
public override void Visit(SyntaxNode? node)
|
|
{
|
|
if (node != null)
|
|
{
|
|
_recursionDepth++;
|
|
StackGuard.EnsureSufficientExecutionStack(_recursionDepth);
|
|
((CSharpSyntaxNode)(object)node).Accept(this);
|
|
_recursionDepth--;
|
|
}
|
|
}
|
|
|
|
public override void DefaultVisit(SyntaxNode node)
|
|
{
|
|
//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_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001d: 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_0049: Invalid comparison between Unknown and I4
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0036: Invalid comparison between Unknown and I4
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
|
ChildSyntaxList val = node.ChildNodesAndTokens();
|
|
int count = ((ChildSyntaxList)(ref val)).Count;
|
|
int num = 0;
|
|
do
|
|
{
|
|
SyntaxNodeOrToken val2 = ChildSyntaxList.ItemInternal((SyntaxNode)(object)(CSharpSyntaxNode)(object)node, num);
|
|
num++;
|
|
SyntaxNode val3 = ((SyntaxNodeOrToken)(ref val2)).AsNode();
|
|
if (val3 != null)
|
|
{
|
|
if ((int)Depth >= 0)
|
|
{
|
|
Visit(val3);
|
|
}
|
|
}
|
|
else if ((int)Depth >= 1)
|
|
{
|
|
VisitToken(((SyntaxNodeOrToken)(ref val2)).AsToken());
|
|
}
|
|
}
|
|
while (num < count);
|
|
}
|
|
|
|
public virtual void VisitToken(SyntaxToken token)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Invalid comparison between Unknown and I4
|
|
//IL_000a: 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)
|
|
if ((int)Depth >= 2)
|
|
{
|
|
VisitLeadingTrivia(token);
|
|
VisitTrailingTrivia(token);
|
|
}
|
|
}
|
|
|
|
public virtual void VisitLeadingTrivia(SyntaxToken token)
|
|
{
|
|
//IL_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
if (((SyntaxToken)(ref token)).HasLeadingTrivia)
|
|
{
|
|
SyntaxTriviaList leadingTrivia = ((SyntaxToken)(ref token)).LeadingTrivia;
|
|
Enumerator enumerator = ((SyntaxTriviaList)(ref leadingTrivia)).GetEnumerator();
|
|
while (((Enumerator)(ref enumerator)).MoveNext())
|
|
{
|
|
SyntaxTrivia current = ((Enumerator)(ref enumerator)).Current;
|
|
VisitTrivia(current);
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void VisitTrailingTrivia(SyntaxToken token)
|
|
{
|
|
//IL_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
if (((SyntaxToken)(ref token)).HasTrailingTrivia)
|
|
{
|
|
SyntaxTriviaList trailingTrivia = ((SyntaxToken)(ref token)).TrailingTrivia;
|
|
Enumerator enumerator = ((SyntaxTriviaList)(ref trailingTrivia)).GetEnumerator();
|
|
while (((Enumerator)(ref enumerator)).MoveNext())
|
|
{
|
|
SyntaxTrivia current = ((Enumerator)(ref enumerator)).Current;
|
|
VisitTrivia(current);
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void VisitTrivia(SyntaxTrivia trivia)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Invalid comparison between Unknown and I4
|
|
if ((int)Depth >= 3 && ((SyntaxTrivia)(ref trivia)).HasStructure)
|
|
{
|
|
Visit((SyntaxNode?)(object)(CSharpSyntaxNode)(object)((SyntaxTrivia)(ref trivia)).GetStructure());
|
|
}
|
|
}
|
|
}
|