How to make intellisense more smart by limiting the java api package selection pool?

Is there any way I can limit the selection pool that intellisense uses when it tries to 'guess' the java api package that the user wants to use?
Thank you.

14 comments
Comment actions Permalink

Editor -> Auto Import -> "Exclude from Import and Completion"

Also IntelliJ IDEA will "learn" which classes you prefer, so they will appear first in completion variants after some time.

0
Comment actions Permalink

How long does the learning take? I've been using log4j for past few years, but Intellij always suggests other Logger packages before log4j, always appears in roughly the same place around the middle.

0
Comment actions Permalink

Did you actually write new code using log4j's Logger class?

Also verify that Editor -> Code Completion -> "Sort lookup items lexicographically" is unchecked.

0
Comment actions Permalink

or use small toggle button in code complete popup (bottom right corner)

0
Comment actions Permalink

Thank you!
What a great feature!
Keep up the good work guys!
:)

0
Comment actions Permalink

I've just used this great feature, by entering in the exclude list the following package :
com.sun

Here is the reason why a java developer should do that : http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html

0
Comment actions Permalink

I have a last question on this interesting subject.
When there is only one option for intellisense to use, why is this not done automatically and I have to press alt + enter?
Thank you again for your kind help.

0
Comment actions Permalink

Check Editor->Auto Import->"Add unambigious imports on the fly"


0
Comment actions Permalink

Thank you so much Yann for your help!
:)

0
Comment actions Permalink

Yes yes still using it, although its not a new product and switching would be painful.

Don't see a small lexical buton in the popup? This is the  'Class to Import' popup I typically see as I've got a live template for the Logger declartion. After expaning the template it wants me to import the class.

Did have Code Completion -> "Sort lookup items lexicographically" turned on, but I remember that was mostly out of fustration as sorting it alaphbetically made it possible to find at least. I've turned that off again and added log4j via Class completion a few times and the order is the same. Are Class Imports a different use case?

0
Comment actions Permalink

Just to be clear, the sorting can be toggled on-the-fly using this button (at least in IntelliJ IDEA 12):
sort.png

0
Comment actions Permalink

Ok I'm looking at a different thing then. I meant when I expand a live template and get prompted to "Import Class" for the new Logger usage. Where I get the following unsorted/unpreferenced popup:


Clipboard.png

0
Comment actions Permalink

Ok, I see. How is your live template defined? Do you use FQN for Logger class in it?


0
Comment actions Permalink

Ah no didn't use an FQN. It's a template I've been using for years so is fairly generic, this project has a covention that we only use log4j though with 200 odd transitive dependancies we have plenty of choice..

The live template is global isn't it? not project based.

Maybe just make myself a new log4j specfic live template. Wondering if IDEA will import the package automatcially to shorten the FQN? guess not unless I ask via the intention. Ill have a play about.

0

Please sign in to leave a comment.