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 18621 - Import Management and Fast Import tool should sort import statements
Summary: Import Management and Fast Import tool should sort import statements
Status: CLOSED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Windows 3.1/NT
: P4 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-12-13 14:45 UTC by tkellerer
Modified: 2007-09-26 09:14 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Patch to make Fast Import insert new statements in Alphabetic order (2.37 KB, patch)
2002-03-18 17:41 UTC, K.C. Baltz
Details | Diff
patch in jar form (4.25 KB, application/octet-stream)
2002-03-22 16:32 UTC, K.C. Baltz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tkellerer 2001-12-13 14:45:31 UTC
It would be nice if the "Import management tool" and the "Fast import" tool
could sort the import statements, so that imports to the same package appear
next to each other. 

The package imports should also be "grouped": when an import to a different
package starts, a blank line should be inserted. 
The threshold when a new "package" starts should be user configurable, so the
user can define the package "level" (java.util would be 2 levels,
javax.swing.border would 3 levels) on which the grouping should occur. 

Example: package level set to 2, the following import sorting should be generated.

import java.sql.ResultSet;
import java.sql.Statement;

import java.util.HashMap;
import java.util.Map;

If the "threshold" was set to level 3 the above 4 lines would be "grouped"
together without the blank line.
Comment 1 gthb 2002-02-21 12:02:47 UTC

*** This issue has been marked as a duplicate of 19167 ***
Comment 2 K.C. Baltz 2002-03-18 17:41:03 UTC
Created attachment 5080 [details]
Patch to make Fast Import insert new statements in Alphabetic order
Comment 3 K.C. Baltz 2002-03-18 17:44:25 UTC
I reopened this because the supposedly duplicate issue makes no 
reference to the Fast Import tool.  Also, the patch I just submitted 
only fixes (to some degree) the Fast Import part of the issue.  

Note, the FI patch does not respect whitespace.  It will always 
insert a new statement in the first correct alphabetic location, but 
it will not respect blank lines separating package groups.  I'd love 
to know how to do that.  
Comment 4 K.C. Baltz 2002-03-22 16:32:05 UTC
Created attachment 5151 [details]
patch in jar form
Comment 5 K.C. Baltz 2002-03-22 16:43:02 UTC
Just drop the importPatch.jar in 
\netbeans\modules\patches\org-netbeans-modules-
java\importPatch.jar
Comment 6 Svata Dedic 2002-03-22 17:01:37 UTC
I'll try a little if I can make the code generator a little smarter
with the blank separating lines...
Comment 7 Svata Dedic 2002-03-22 17:47:14 UTC
Patch applied; I've added a little of code, which separates imports
from different package by a blank line... but the package level is not
configurable yet. Anyway, a simple level won't do, IMHO. Different
libraries (with different package nesting depth) may reuqire different
grouping.

See in tomorrow dev-build. Thanks!

/cvs/java/src/org/netbeans/modules/java/codegen/ImportB.java,v  <-- 
ImportB.java
new revision: 1.6; previous revision: 1.5
/cvs/java/src/org/netbeans/modules/java/model/ImportCollection.java,v
 <--  ImportCollection.java
new revision: 1.10; previous revision: 1.9
Comment 8 Jan Becicka 2002-04-12 15:29:30 UTC
VERIFIED
Comment 9 Quality Engineering 2003-07-01 13:19:35 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.