Add unambiguous imports on Optimize Imports ?

I'm trying to find a set of options that makes the auto import behavior work for me and I can't find one.

The issue is that I can only seem to have "Add unambigious imports on the fly" or not at all, but neither of those are particulaly helpful to me.

It's common for me to create a new class simply by referencing it in my code, and then using "Command + Enter" to "Create Class ... "
Typically that works fine, but sometimes (and often enough) it fails in a very annoying way.

In a large project, it's common to have lots of dependencies. There's a chance that one of those libraries happens to have a class with the same name as I'm trying to create.

If I have "Add unambigious imports on the fly" turned on, then IDEA will automagically import that class for me, even though that's not what I want (and if I go and delete the import, it just adds it again, so I'd need to add that class as an exclude, which all just ends up being harder than simply going to the project view and creating a new class from there)

But with  "Add unambigous imports ..." off, adding imports is a total pain. Even simple things like list = ArrayList<>(); will not auto-import (even when I select "Optimize Imports", so I need to cycle through each one and "Command + Enter" > "Import Class"

What I'd like to be able to do is turn off "Add unambigious imports on the fly" (because it gets in the way), but still be able to "Add unambigious imports when Optimizing Imports" (Opt + Shift + O)
i.e. Don't get in my way and import things while I'm still typing, but still do the right thing when I ask for it.

Is there anyway to get IDEA to do that ("that other IDE" does what I want in this respect)

1 comment

Hi Tim,

IntelliJ IDEA doesn't provide that functionality. Created corresponding feature request at the tracker - http://youtrack.jetbrains.com/issue/IDEA-105339. However, it has a low priority at the moment. Feel free to watch its progress/vote it up.

Denis

0

Please sign in to leave a comment.