private static string GetTranslation(string source) { // Getting the AST node CSharpSyntaxTree tree = ASTExtractor.Extract(source); SyntaxNode node = new NodeLocator(tree).LocateLast(typeof(ClassDeclarationSyntax)); ClassDeclarationSyntax classDeclarationNode = node as ClassDeclarationSyntax; // Creating the walker var astWalker = ClassASTWalker.Create(classDeclarationNode); // Getting the translation unit ITranslationUnit translationUnit = astWalker.Walk(); return(translationUnit.Translate()); }
public string RenderSimpleEmptyClass() { var sourceInfo = SourceGenerator.Generate(SourceOptions.None); string source = sourceInfo.Key; // Getting the AST node CSharpSyntaxTree tree = ASTExtractor.Extract(source); SyntaxNode node = new NodeLocator(tree).LocateLast(typeof(ClassDeclarationSyntax)); ClassDeclarationSyntax classDeclarationNode = node as ClassDeclarationSyntax; // Creating the walker var astWalker = ClassASTWalker.Create(classDeclarationNode); // Getting the translation unit ITranslationUnit translationUnit = astWalker.Walk(); return(translationUnit.Translate()); }
public static MockedClassASTWalker Create(CSharpSyntaxNode node) { return(new MockedClassASTWalker(ClassASTWalker.Create(node))); }