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 21413 - Have the IDE reorganize imports automatically
Summary: Have the IDE reorganize imports automatically
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Windows 3.1/NT
: P2 blocker (vote)
Assignee: Tomas Hurka
URL:
Keywords: UI
Depends on: 19167
Blocks: 22904
  Show dependency tree
 
Reported: 2002-03-11 10:08 UTC by Pavel Buzek
Modified: 2007-09-26 09:14 UTC (History)
1 user (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 Pavel Buzek 2002-03-11 10:08:42 UTC
Have the IDE to reorganize imports automatically and check them automatically (on save).
Comment 1 Tomas Hurka 2002-04-17 17:30:02 UTC
I propose the following implementation.
First this feature will be disabled by default. It can be enabled in
Tools->Options->Editing->Java Sources->Import Management Tool
Settings.
It will work as follow. When save action is invoked on Java source
file Import Management Tool is invoked and it will check if there are
any unresolved identifiers. If there are all identifiers resolved it
ends immediately (without invoking IMT Wizard) and java source file is
saved. If there are some unresolved identifiers the IMT starts its
Wizard (the same way as it is invoked manually from menu). After
Wizards completes the java source file is modified by IMT and then
saved. Note that Save action can be invoked implicitly for example by
Compile Action or by Exit Action or by renaming package and so on.  
Alternative solution is to run IMT silently together with automatic
source parsing and then somehow (?) notify the user that there are
some changes IMT can do. This includes resolving unresolved
identifiers, changing usage of fully qualified names to simple names
etc. 
Comment 2 Pavel Buzek 2002-04-18 10:12:56 UTC
Tomas, I suggest that for 3.4 you implement the issue as you described (disableed by default, when 
enabled check the file on Save and bring wizard if needed) and close this request. 

Then please file a new request for enhancement for more advanced version that would check status of 
imports when the user is editing source and let's plan this for some next version (4.0).
Comment 3 Tomas Hurka 2002-04-25 12:45:25 UTC
Import sorting was implemented by issue #19167,  automatic invoking of
IMT was canceled, since it can irritate lots of users. For more
details see this discussion on nbui:
http://www.netbeans.org/servlets/ReadMsg?msgId=305091&listName=nbui
Comment 4 Pavel Buzek 2002-04-26 08:58:07 UTC
We could get back to this in 4.0. I filed:
http://www.netbeans.org/issues/show_bug.cgi?id=22843
Comment 5 Svata Dedic 2002-05-22 13:22:48 UTC
If this issue was cancelled, shouldn't the proper resolution status be
"WONTFIX" or "INVALID" ?
Comment 6 Pavel Buzek 2003-07-02 09:25:32 UTC
Even if the proposed solution was not implemented (because it
irritated users) IMO the requirement is still valid. I would restate
it as follows: Assist the user to keep the imports up to date. There
can be different solutions then a complex IMT.

Please reconsider this and mark it as WONTFIX if you do not plan to
support this feature (as Svata suggested). I will not verify that this
has been fixed ;-)
Comment 7 Rich Unger 2004-02-19 00:14:45 UTC
Is it possible to resurrect this old issue for 4.0?  The eclipse
implementation of this is a killer feature.  No complex IMT Wizard. 
Just press a hotkey sequence and:

Any unresolved classes for which there exists only one possibility in
the classpath gets an import statement.

Any unresolved classes for which there exists multiple possibilities
in the classpath pop open a quick selection dialog.

Any import statements that are not used in the source file are deleted.

For extra credit, a configuration option:
Number of imports needed for .* (e.g. org.openide.*)
Comment 8 Tomas Hurka 2004-02-20 07:50:36 UTC
Yes, we would like to address this in 4.0.
Comment 9 Rich Unger 2004-08-17 19:31:01 UTC
Did someone fix this?  I just tried the Alt-Shift-F cmd, and this
seems to do everything outlined here.  Should we mark this fixed?
Comment 10 Martin Matula 2004-08-17 20:08:10 UTC
Yes, thanks for catching this.