How to set the launcher or something that can remain original used import statements?
It's happy to see the redundant imports in Java files are removed after processing,
but I'm confused that all the useful imports are inserted into the class body like below.
How can I remain the classical imports format?
import spoon.reflect.code.CtComment;.......CtComment comment = new CtJavaDocImpl()();
------>
spoon.reflect.code.CtComment comment = new code.demo.CtJavaDocImpl();
Here the comment is a FieldType belongs to a class.
Thanks a lot!
auto imports should do want you want.
launcher.getEnvironment() for getting the evironment object
Oh thanks!
I initiate the launcher by doing this:
init(ConstantUtil.PROCESSOR_ROOT_PATH); launcher.setArgs(args);
init()is a method with static and public modifiers,I set some environment properties in it, including setAutoImports(), it just doesn't work at all.
I reversed the order of these two statements just now and it worked, I guess the setArgs() method may reset some options of launcher.
Thank you MartinWitt!
You could have a look at the FluentLauncher with easy methods for often used settings.
Yeah I saw it just a few days ago, it seems like a new feature and it's quite convenient to use. Anyway, thanks for your help again, wish you have a good day.