English 中文(简体)
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.

最佳回答

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

问题回答

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.

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





相关问题
high load on mysql DB how to avoid?

I have a table contain the city around the worlds it contain more than 70,000 cities. and also have auto suggest input in my home page - which used intensively in my home page-, that make a sql query ...

Fast Javascript String Replacement

Hey there geniuses of SO! This is for an autocomplete plugin that needs to accept data as an array of arrays and convert it using a format string (or regex). The format string could be any format. ...

Categorized results – jQuery autocomplete plugin

I m looking for an autocomplete plugin that makes it easy to categorize search results. If that s unclear, take a look at Apple.com s search bar (top right). I know that script.aculo.us autocomplete ...

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, ...

热门标签