Idea for improving "auto-import unambiguous" setting

Sometimes IDEA auto-imports classes that I've never heard of and
definitely don't want to import. For example, I typed "Assert x !=
null;" (I accidentally capitalized "assert") and IDEA imported an inner
class com.sun.tools.javac.tree.Tree.Assert. I obviously didn't want this.

I had an idea - maybe IDEA should keep a list of classes which you have
chosen to import, and only auto-import those. That way, IDEA will never
auto-import a class that you aren't familiar with, because you will have
chosen to import it at least once.

What do you think? Does anyone have any better ideas for fixing this
annoyance?

4 comments
Comment actions Permalink

Keith Lea wrote:

I had an idea - maybe IDEA should keep a list of classes which you have
chosen to import, and only auto-import those. That way, IDEA will never
auto-import a class that you aren't familiar with, because you will have
chosen to import it at least once.


One thing that's starting to drive me insane with this, is I had an
instance where the jar files referenced by the plugin no longer existed
on disc, and during editing a piece of code, IDEA kept on insisting to
change it to an import of a class that was now umabiguous, and any
attempt to paste the correct one in, kept getting automatically
optimized, and the unambiguous one replaced.

Talk about fustrating.

The jar including the "correct" class was configured with the project,
and still cached, but no longer on disc ( started playing with ivy, so
deleting jars, and having them pulled down as part of the build ).

I guess this is more a problem with the automatic optimization of
imports, rather than unambiguous imports. Mmmm

0
Comment actions Permalink

This is closely related:
http://www.jetbrains.net/jira/browse/IDEABKL-2448

IMHO auto-import should only ever trigger on code you just edited (changed/pasted).

0
Comment actions Permalink

Closely related:

http://www.jetbrains.net/jira/browse/IDEABKL-2783

That and forbidding some packages (com.sun.*) by default for new projects would be really nice.

0
Comment actions Permalink

I've had a question about this request. What is a dependency rule? Why
would my project have a dependency rule against java.awt.List? Just for
this hiding imports purpose?

Marcus Brito wrote:

Closely related:

http://www.jetbrains.net/jira/browse/IDEABKL-2783

That and forbidding some packages (com.sun.*) by default for new projects would be really nice.

0

Please sign in to leave a comment.