I'm using Intellij 10.5 and I'd like to be able to use the automatic generation of import lines to allow for inner classes, but I don't see it as a settings preference. Is this possible?
Example's worth a thousand words:
public class Foo {
public static class Bar {
}
}
I'm writing some code that needs to use an instance of Bar:
Bar bar = new Bar();
Intellij correctly brings up Bar as one of the suggestions for importing, but when I select it, it does the following:
import package.Foo;
Foo.Bar bar = new Foo.Bar();
whereas what I'd like is:
import package.Foo.Bar;
Bar bar = new Bar();
Thanks!
Automatically add import statements 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.
The auto import for classes is working if you enable it under "Settings > Editor > General > Auto Import".
You can disable auto-import on completion and use quick-fixes instead: In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | General | Auto Import. On the Auto Import page that opens, use the checkboxes in the TypeScript/JavaScript area to enable or disable import generation on code completion.
The solution is to go to Preferences ( ⌘ + , on macOS / Ctrl + Alt + S on Windows and Linux) > Editor > Code Style > Java > Imports tab set Class count to use import with '*' and Names count to use static import with '*' to a higher value. Any value over 99 seems to work fine.
Check the checkbox under Settings > Editor > Code Style > Java > Imports > Insert imports for inner classes
:
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