By default some packages are imported in a Groovy class. I know that you can add new one with an ImportCustomizer but is there a way to remove them programmatically?
Thanks in advance for your answers.
No. If you look through the code, then you'll see that the standard imports like java.io and java.math.BigDecimal are not handled by ImportCustomizer.
Which is a pity.
The default imports are handled in ResolveVisitor.java. The code doesn't allow to modify the default imports or the method where they are added.
Kudos to andrei-krotkov for finding the code.
It is not a pretty good solution but it works:
Arrays.fill(ResolveVisitor.DEFAULT_IMPORTS, "java.lang.");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With