Reputation: 5947
When I paste a code snippet with inner entity's(class or enum) name in it in IDEA 12 I get a dialog offering to import that entity's package. If class I'm working on and entity are in same package, IDEA just writes outer class name and a dot before entity's name. That bloats source much worse than if entity was imported in the import section at the file start. How to disable this kind of behaviour and force IDEA to import everything exclusively in import section?
Upvotes: 14
Views: 8239
Reputation: 7858
Honestly, when using inner classes outside its parent it JUST makes sense to reference the outer class instead of importing the inner class at the top level, otherwise, why is that class an inner class instead of a top level one? From my point of view, if you are consuming a inner class outside its parent at lot (you say 100 times) then, don't you think you should review your design?
Anyway, you can control the Auto-Import feature in IntelliJ at Settings > Editor > General > Auto Import
.
In the other hand, if you want to have imports for your inner classes then go to Settings > Editor > Code Style > Java > Imports
and mark the Insert imports for inner classes
checkbox.
Upvotes: 32