a paid nerd
a paid nerd

Reputation: 31502

Limiting IntelliJ IDEA import suggestions on completion

When I type the name of a class which will need to be imported, IntelliJ lovingly pops up with a list of suggestions. However, most of the time those suggestions are things I'd never want to import, especially by accident -- like java.awt.*.

Is there a way to prevent the packages I'll never import from appearing in the completion list?

I've scoured the options but I haven't found anything.

Upvotes: 11

Views: 4965

Answers (3)

ahmed hamdy
ahmed hamdy

Reputation: 5169

in IntelliJ version 13.* and 14.* to Excluding Classes from Auto-Import

Steps:

1) Open the Settings dialog box, and under the Editor node, click Auto-Import.

2) On the Editor | Auto-Import page, click +

3) In the dialog box that opens, type the name of the class or a whole package to be excluded [ in your case write java.awt.* ], and click OK. Use + and - 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.

For More information about Excluding Classes from Auto-Import See helping Doc for IntelliJ

Upvotes: 1

Gamlor
Gamlor

Reputation: 13238

I'm not sure since when this feature exists. It certainly in the upcoming version 9.0:

When the import-popup shows you can navigate from there to two ignore-option. For example when you type List it could be 'ignore java.awt.List from auto-import' and 'ignore java.awt from auto import'

Or you can configure it in the settings: Editor->Auto-Import: There you can add and remove ignored packages and classes.

Upvotes: 2

Gerd Klima
Gerd Klima

Reputation: 1392

Depending on the IDEA version: Yes.

In 7.0.5 use menu File -> Settings choose Code Completion and then Exclude from Import and Completion and add the package or class that you don't want to have in your suggestions.

In version 8 and version 9 use menu File -> Settings type "Auto import" into the search box and use the Exclude from Import and Completion box there.

In version 9 you also have the option of adding Classes and Packages to the exclude-list directly from the import suggestions context-menu:

alt text

Upvotes: 15

Related Questions