Last active
November 20, 2015 18:17
-
-
Save JoshVarty/2c0585e63419ad1e7254 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 CustomWalker : CSharpSyntaxWalker | |
{ | |
static int Tabs = 0; | |
public override void Visit(SyntaxNode node) | |
{ | |
Tabs++; | |
var indents = new String('\t', Tabs); | |
Console.WriteLine(indents + node.Kind()); | |
base.Visit(node); | |
Tabs--; | |
} | |
} | |
static void Main(string[] args) | |
{ | |
var tree = CSharpSyntaxTree.ParseText(@" | |
public class MyClass | |
{ | |
public void MyMethod() | |
{ | |
} | |
public void MyMethod(int n) | |
{ | |
} | |
"); | |
var walker = new CustomWalker(); | |
walker.Visit(tree.GetRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment