TL;DR: Is there a preference setting for Eclipse Juno for "leave static imports the hell alone"?
Nearly all of our developers who are using Eclipse have Organize Imports in the list of their Save Actions. Which is fine, and quite useful.
The trouble is with static imports. Our project needs to have its static imports managed carefully, so we'd strongly prefer to have them listed explicitly:
import static thing.foo;
import static thing.bar;
import static thing.baz;
Unfortunately, depending on the threshold number in Organize Imports "Number of static imports needed for .*"
, this block occasionally gets collapsed into
import static thing.*;
Cranking the threshold up to a large number leaves the list of statics alone... as long as the Eclipse editor thinks that there's a reference to that static present. Then we get scenarios like this, to pick the simplest example:
- Developer makes a typo in code completely unrelated to the statically imported symbols, presses Save, tries to build.
- Eclipse gets a parse error.
- Developer fixes part of broken code, presses Save.
- Eclipse no longer has its list of static references because of failed build, so the Save Actions helpfully removes the "unused" static imports.
- Developer finishes fixes, presses Save, tries to build.
- Eclipse gets new errors due to all these now-unknown symbols.
- Developer rages at Eclipse, blows off steam complaining to other developers.
Go through the cycle enough times over the months, and eventually we arrive at step 8, Senior developer gives up hacking at Eclipse's code and posts on SO.
There are SO questions like this one which mention the problem as an aside, but nothing else.
Is there some magic combination of preferences or build settings that tells Eclipse to keep doing its thing for normal imports, but just stop flailing around at managing the static imports?