Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 70074 - Organize Imports dialog class order isn't optimal [code manipulation]
Summary: Organize Imports dialog class order isn't optimal [code manipulation]
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.2 M5   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-14 19:10 EDT by Ryan Lowe CLA
Modified: 2006-03-21 19:48 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Lowe CLA 2004-07-14 19:10:56 EDT
In the "Organize Imports" dialog, the ordering of the classes isn't optimal.  If
I have a class in my workspace with the same name as a known class in another
package (ie. in the Java libraries), the other class is displayed first.

Wouldn't it make more sense to display my class first since I would be more
likely to chose it?

When doing multiple "organize imports" across a workspace, it's much nicer to
have the default one selected to the one I'm most likely to pick instead of
having to key down each time.

Instead of changing the order, the default selection could be changed to the
class with the matching name in the workspace.
Comment 1 Dirk Baeumer CLA 2004-07-15 04:37:42 EDT
We are thinking about remembering the last decision on clashes. 
Comment 2 Ryan Lowe CLA 2004-08-30 11:02:15 EDT
Yep, using the last decision would be a good solution as well.

What would really be nice is if the Organize Imports was a bit smarter.  If I
have the code:

List stuff = new Vector();

I'm obviously not talking about a java.awt.List here, because Vector implements
the Java Collections List interface.  But Organize Imports asks me anyway
because it's not smart enough to figure it out.

Ideally, the Organize Imports dialog shouldn't even bother prompting me unless
there is a double ambiguity between the interface/superclass on the left and the
class on the right.

Doing that would minimize the need for the Organize Imports UI to be more
efficient because it wouldn't be used as much.

Couple that automation intelligence with "Run in Background" (bug #71497) and
I'll touch Ctrl-Shift-O even less. :)

A smarter Organize Imports is a completely different issue though, I could open
another bug...
Comment 3 Alan Malloy CLA 2006-03-21 18:01:38 EST
Any one of the fixes mentioned here would be awesome. All of them would be even better, but if I had to vote for one I´d say the most important one is to recognize when a suggested import would create a compile error. This is a little more general than knowing that Vector extends List (and maybe easier to implement?). For example, if I say "List l = new Vector();" then Eclipse should know which List and Vector to use. Given "List l = null;" Eclipse clearly can't tell what kind of list I want, and it should prompt me (preferably with a customizable sort order). But if I say "List<Integer> l = null;" it should at least reduce the selection to all paraeterized types. In this case that resolves it unambiguously, because awt.List isn't paraeterized. Generalizing this to "Do not give suggestions that cause compile errors, unless AL suggestions give compile errors" would be nice. But maybe the overhead for speculative compilation is too high and you should just check for Generics.
Comment 4 Martin Aeschlimann CLA 2006-03-21 19:48:24 EST
In M5 we added a history of used types so they are are higher in the list.

The request to make smarter for 'List l= new Vector()' is bug 87950