After creating a class using Factory, how can I pretty print the generated class source code ?
Asked
Active
Viewed 176 times
0
-
Please could you add some more information. For example: what have you tried so far? What is the result you are getting? What is the result you are expecting? – James Wilson Nov 18 '19 at 07:41
-
I'm trying to create classes with getFactory().Core().createClass(), and write back the generated classes as java source file (.java) in my maven src folder. @JamesWilson – florent kouame Nov 18 '19 at 11:18
1 Answers
0
You can call toString()
on the AST node:
CtClass c = getFactory().Core().createClass();
// fill c with stuff
System.out.println(c.toString())

Martin Monperrus
- 1,845
- 2
- 19
- 28