Last active
November 20, 2015 18:18
-
-
Save JoshVarty/9f39297aa269594d9149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DeeperWalker : CSharpSyntaxWalker | |
{ | |
static int Tabs = 0; | |
//NOTE: Make sure you invoke the base constructor with | |
//the correct SyntaxWalkerDepth. Otherwise VisitToken() | |
//will never get run. | |
public DeeperWalker() : base(SyntaxWalkerDepth.Token) | |
{ | |
} | |
public override void Visit(SyntaxNode node) | |
{ | |
Tabs++; | |
var indents = new String('\t', Tabs); | |
Console.WriteLine(indents + node.Kind()); | |
base.Visit(node); | |
Tabs--; | |
} | |
public override void VisitToken(SyntaxToken token) | |
{ | |
var indents = new String('\t', Tabs); | |
Console.WriteLine(indents + token); | |
base.VisitToken(token); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment