use of org.codehaus.groovy.antlr.treewalker.SourceCodeTraversal in project groovy by apache.
the class Java2GroovyProcessor method mindmap.
public static String mindmap(String input) throws Exception {
JavaRecognizer parser = getJavaParser(input);
String[] tokenNames = parser.getTokenNames();
parser.compilationUnit();
AST ast = parser.getAST();
// modify the Java AST into a Groovy AST
modifyJavaASTintoGroovyAST(tokenNames, ast);
String[] groovyTokenNames = getGroovyTokenNames(input);
// groovify the fat Java-Like Groovy AST
groovifyFatJavaLikeGroovyAST(ast, groovyTokenNames);
// now output
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Visitor visitor = new MindMapPrinter(new PrintStream(baos), groovyTokenNames);
AntlrASTProcessor traverser = new SourceCodeTraversal(visitor);
traverser.process(ast);
return new String(baos.toByteArray());
}
Aggregations