Faulty optimize imports

Hi,
When I copy/paste source files from one package to another, the optimize imports will remove imports that are definitely used by the code (they should not be removed) and are available on the classpath. Has anyone else seen this? Then to correct this, I have to manually open up each file (and this project is big) and re-add the import. This is insanely unproductive. Is there a way to automatically resolve import issues for a scope of files/packages? or, better yet, configure (or fix) optimize imports to not remove these import statements in the first place?

3 comments
Comment actions Permalink

Hi Christian,
do you copy/paste inside one module? If no - do you have dependencies correct dependencies in the target module? I need steps to reproduce as it works here
Thank you

0
Comment actions Permalink

On Thu, 28 Apr 2011 21:25:33 MSD, Christian Posta
<no_reply@jetbrains.com> wrote, quoted or indirectly quoted someone
who said :

>When I copy/paste source files from one package to another, the optimize imports will remove imports that are definitely used by the code (they should not be removed) and are available on the classpath. Has anyone else seen this? Then to correct this, I have to manually open up each file (and this project is big) and re-add the import. This is insanely unproductive. Is there a way to automatically resolve import issues for a scope of files/packages? or, better yet, configure (or fix) optimize imports to not remove these import statements in the first place?

one kludge to deal with IntelliJ improperly dropping imports is to
create hunk of source with every conceivable import in it.  When
IntelliJ throws out imports, insert this giant block (which will
duplicate imports already there) and do a reformat with import tidy
and it will toss ones not needed.

The problem comes when you have a syntax error. It hides the fact some
imports are needed. Never reformat unless you have just had a clean
compile. This also prevents reformat from scrambling text with insane
indents.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Politicians complain that Kindles and iBooks are killing jobs by
destroying the paper book industry.  I see it that they have create a way
to produce books for less than a third the cost without destroying forests
and emitting greenhouse gases in the process.  They have created wealth. 
They are encouraging literacy and cutting the costs of education. 


0
Comment actions Permalink

Anna,

I am copying/pasting from one module to another.
I am refactoring a project so I have two modules (which have almost he same source) with one being the original, the second being the refactored version (a non-maven project to a maven project).

It seems as though IntelliJ becomes confused (on this issue, and a few others that I've noticed) when a project contains modules that has similar source code and package names, even when the modules' dependencies and scopes are set properly and should be treated independent of each other (per the documentation and eclipse migration FAQ).

0

Please sign in to leave a comment.