How do I pretty print generated source in maven project using spoon?

192 Views Asked by At

After creating a class using Factory, how can I pretty print the generated class source code ?

1

There are 1 best solutions below

0
Martin Monperrus On

You can call toString() on the AST node:

CtClass c = getFactory().Core().createClass();
// fill c with stuff

System.out.println(c.toString())