This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
[ BUILD # : 200514131930 ] [ JDK VERSION : 1.5.0_02 ] Just discovered that a new feature has been added to code completion; An import statement is now automatically added when a class is selected. Nice idea but the import statement only specifies the specific class instead of the whole package. Shouldn't it give you the dialog you get when you use fast import, so that you are given a chance to choose between class import, package import and FQN?
IMHO this is as designed - Fix Imports also imports just classes, not package wildcards. Since you can hide all imports in a code fold anyway, there is little reason any more to import package wildcards, I think... anyway, it is being consistent with the behavior of Fix Imports, so if there is a bug (rather RFE) it is that neither provides an option for another mode of operation.
Yes, perhaps it is an RFE, but before this auto import feature was added you did have a choice, because you had to call upp fast import which allows you to choose and remembers the last choice. Since I usually want a package imports, and sometimes even an FQN, this new feature is just annoying.
As Jesse said this is as designed so changing this to enhancement. We think that it would be disturbing to show a dialog after choosing from the completion window. Instead we would like to allow to configure the rules for automatic imports management e.g. specify the number of classes from a package which, when reached, would turn the particular class imports into package imports etc. There is an issue 47599 for this. Still I understand that you may want to use FQN. I'm wondering what would be best solution for this case. The new completion API allows us to define an extra shortcut(s) for each completion item so we could define e.g. Alt-F to paste the class item (like on Enter) but using FQN. This could be mentioned at the begining of the javadoc so that it would be discoverable by the users. Adding Jano R. to cc to check this from the ui point of view.
I agree with what you said here: --- We think that it would be disturbing to show a dialog after choosing from the completion window. Instead we would like to allow to configure the rules for automatic imports management e.g. specify the number of classes from a package which, when reached, would turn the particular class imports into package imports etc. There is an issue 47599 for this. --- If you want to deal with it for 5.0, I would rather give an option to not do the automatic import from code completion than to introduce a new shortcut. This option would be removed when we do the automatic import management and introduce a set of option for managing the auto import.
I agree with jrojcek that this automatic import should be optional, but I think you don't need to remove it even after automatic import management is in place. I (and perhaps others) prefer to use fast-import. Not a big deal but if you add the option, why remove it later?
*** Issue 61022 has been marked as a duplicate of this issue. ***
Probably this is now fixed in 7.1 since you can configure import policy as part of formatting?