Search code examples
intellij-ideaintellij-14

How can I change IntelliJ "Class to Import" order?


Code - before:

import org.junit.Assert;
...
Assert.assertEquals(a,b);
Assert.assertEquals(c,d);

Steps:

  1. I remove the first Assert.:

    assertEquals(a,b);
    Assert.assertEquals(c,d);
    

    Now the first assertEquals is red.

  2. Now I click on the first assertEquals and I hit Alt + Enter

    enter image description here

  3. I select "Static import method..." and I see the following popup: enter image description here

    If I click on the last line (the blue line) all lines containing Assert.assertEquals... become assertEquals....

Code - after:

import static org.junit.Assert.assertEquals;
...
assertEquals(a,b);
assertEquals(c,d);

Questions

Is it possible to change the order in the "Class to Import" window? I always want to see the blue line (org.junit) in the first place.

Or is it possible to remove the other options? For every assert I want to use org.junit.Assert.

Details:

  • Windows 7
  • IntelliJ IDEA 14.1.3

Solution

  • You can go to File -> Settings... (Ctrl + Alt + S) -> Editor -> General -> Auto Import and add packages to Exclude from Import and Completion that you don't want to see.

    enter image description here