Andrew Flynn
Andrew Flynn

Reputation: 1516

Intellij auto import for inner classes

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!

Upvotes: 26

Views: 6474

Answers (1)

Oleg Mikheev
Oleg Mikheev

Reputation: 17444

Check the checkbox under Settings > Editor > Code Style > Java > Imports > Insert imports for inner classes:

enter image description here

Upvotes: 49

Related Questions