Package imports disappearing when typing /*
Sometimes I type /* first and then */, to comment out some part of the code. After I did that, suddenly lots of things become red in the file, and in random places of the file vareous things require me to press Alt+Enter because suddenly their package imports are gone.
I think that maybe because I type /*, IntelliJ thinks the complete file is commented out (even though there's no matching */ yet), and then automatically stops importing all packages that are "commented". But shouldn't it wait until I typed the */ before concluding that some part of the document is commented out and it can go remove these packages?
I like it if it automatically removes unused imports (I would even want it to automatically add them too without pressing alt enter if there's no confusion possible), but the above is a bug, right?
请先登录再写评论。
Hello L,
I wouldn't call this a bug, but indeed the logic of "optimize imports on
the fly" can be improved to handle this situation. JIRA issue is welcome.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Under Code Style->Imports there is a "Add unambigious imports on the fly" setting that may help mitigate this. (and is generally pretty handy, not sure why it isn't on by default). You may still have to add imports for classes that have multple matches but may help some.