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.
Implement Optimize Imports.
My 2 cents... Rather than add a new feature, we could simply have the Fix Imports feature modified. Fix Imports adds missing imports and removes unused imports. It would be nice if it also automatically re-ordered the import statements on each invocation so they are in the proper and sorted order. Many tools like checkstyle, pmd, etc. check that the imports appear in sorted order. If you have a class with imports that are completely out of order and you delete all the imports, trigger the Fix Imports and they are all re-added, but in the correct order. The Fix Imports feature should re-order the imports that are already there, without having to delete them all and triggering fix imports.
IMHO these issues should be taken into account here: Issue 42157 {Make IDE Settings movable without import} Issue 55647 {Allow user to choose which version to import settings from} Issue 129611 {Correct modified module links in library descriptors while importing settings for new NB installation}
I support the initiative, but it would be useful to have the option of turning it off, since it would cause "false positives" in your version control, and may not be desirable. On the other hand, it would also be nice to be able to hook it onto the 'Save ' action, so it will fix your imports when you save the file.
Don't forget about static imports, be sure to agree with issue 122109's modifications to SourceUtils.add*Imports (if that patch is accepted)
Seriously, P3 TASK does not sound right and I am afraid this will never be done. [65cat] discussion touched the details that some companies are very sensitive to code conventions. Those will frequently include: import order wildcard imports allowed or not no unused imports Obviously this can become a blocker for an adoption if other tools have that support.
This has been mentioned in the plan here http://wiki.netbeans.org/EditorPlan68. I will ask Max but I guess we might move it to the next release since we are post feature freeze/beta now and this sounds like a bigger feature (if I understand it right).
Thanks for the feedback.
I've done a first version for this: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=27296 It's an unsigned nbm and very less tested but it works for me. Jens
Thanks Jens. Works great. 3 comments: - If the order is already correct, it does nothing (should separate the groups if they aren't already). - It would be great if 'Fix imports' was automatically called before organizing, that way one keystroke would be enough to fix and organize. - There could be a special package group representing 'all the other imports', which could be placed in any position in the list (so that f.i. java.* could be after all the other imports). Thanks!
see also 183703
Implemented in jet-main. http://hg.netbeans.org/jet-main/rev/c604329f2888
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/c604329f2888 User: Dusan Balek <dbalek@netbeans.org> Log: Issue #122109: Implement Optimize Imports - fixed.