IntelliJ IDEA: how to enable import for inner classes

When I insert a piece of code with the name of an internal object (class or enumeration) in it in IDEA 12, I get a dialog offer to import this package of objects. If the class I'm working on and the entity are in the same package, IDEA simply writes the name of the outer class and the dot before the entity name. This source of bloating is much worse than if the object was imported in the import section when the file started. How to disable this behavior and force IDEA to import everything exclusively in the import section?

+4
source share
1 answer

Honestly, when using inner classes outside of its parent, JUST makes sense to refer to the outer class instead of importing the inner class at the top level, otherwise, why is this class an inner class instead of the top level? From my point of view, if you consume the inner class outside your parent in the party (you say 100 times), do you not think that you should reconsider your design?

In any case, you can control Auto-Import in IntelliJ at Settings > Editor > Auto Import .

On the other hand, if you want to have import for your inner classes , go to Settings > Code Style > Java > Imports and check the Insert imports for inner classes check box.

+15
source

All Articles