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.

Bug 57960 - [50cat] Import automatically added as class instead of package
Summary: [50cat] Import automatically added as class instead of package
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 4.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-17 11:36 UTC by gugrim
Modified: 2013-09-02 14:23 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gugrim 2005-04-17 11:36:27 UTC
[ 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?
Comment 1 Jesse Glick 2005-05-12 18:33:27 UTC
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.
Comment 2 gugrim 2005-05-12 19:36:41 UTC
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.
Comment 3 Miloslav Metelka 2005-11-04 11:51:33 UTC
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.
Comment 4 jrojcek 2005-11-08 13:25:38 UTC
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.
Comment 5 gugrim 2005-12-19 17:21:53 UTC
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?
Comment 6 zeljkot 2008-04-24 09:27:31 UTC
*** Issue 61022 has been marked as a duplicate of this issue. ***
Comment 7 Jesse Glick 2011-10-19 15:31:31 UTC
Probably this is now fixed in 7.1 since you can configure import policy as part of formatting?