IntelliJ IDEA 13.1 Web Help

The list of imports suggested by IntelliJ IDEA can be sometimes far too wide, and can include the classes you don't actually need. For example, some of the class names in your project can match the names of internal SDK or unrelated library classes.

IntelliJ IDEA lets you configure the classes to be excluded from import assistance and code completion, thus helping avoid unintentional use of the wrong classes. Besides that, IntelliJ IDEA provides an intention action that allows you to exclude unnecessary classes on-the-fly.

Note

These settings apply to code completion as well. The classes and packages specified as the ones to be ignored by the code completion feature, will not be added to the suggestion list.

To configure classes to be excluded from import
  1. Open the Project Settings dialog box, and under the Editor node, click Auto-Import.
  2. On the Editor | Auto-Import page, click add (Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter).
  3. In the dialog box that opens, type the name of the class or a whole package to be excluded, and click OK.

    Use add (Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter) and delete (Alt+DeleteAlt+DeleteAlt+DeleteAlt+DeleteAlt+DeleteAlt+DeleteAlt+DeleteAlt+DeleteAlt+DeleteCommand Delete or Command BackspaceCommand DeleteCommand Delete or Command Backspace) to manage the list of classes and packages that IntelliJ IDEA shouldn't place to the suggestion list.

  4. Apply changes and close the Settings dialog.
To exclude classes from imports in the fly
  1. Start typing a name in the editor, and use intention action as described in the section Creating Imports:

    import assistance

  2. In the Class to Import suggestion list, select the class you want to be ignored, and click the right arrow to reveal the nested list of intention actions. IntelliJ IDEA suggests you to exclude specific class or the whole containing package:

    import3.png

  3. Click the desired class or package to be excluded.

See Also

Procedures:

Reference:

Web Resources: