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?
You can configure the IDE to automatically add import statements if there are no options to choose from. In the Settings/Preferences dialog ( Ctrl+Alt+S ), click Editor | General | Auto Import. Select the Add unambiguous imports on the fly checkbox, and apply the changes.
Call File | Manage IDE Settings | Import Settings from the main menu. Select the ZIP archive that contains your settings in the dialog that opens. Select the settings you want to apply in the Select Components to Import dialog that opens and click OK.
Launch IntelliJ IDEA. If the Welcome screen opens, press Ctrl+Shift+A , type project from existing sources , and click the Import project from existing sources action in the popup. Otherwise, from the main menu, select File | New | Project from Existing Sources.
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.
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