Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368736

Summary: Auto-suggest should prioritize core JDK classes unless overridden in workspace
Product: [Eclipse Project] JDT Reporter: John Goodwin <john.goodwin>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert
Version: 3.8   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description John Goodwin CLA 2012-01-16 11:35:14 EST
Build Identifier: 20110916-0149

This is a minor issue, but one that can actually create some very frustrating usability issues:

If I auto-complete a class name (e.g. "Map") to automatically generate the import statement, Eclipse has a very annoying habit of suggesting obscure com.sun classes over core java classes. If a user is working quickly, it is very easy to end up with an import of "com.sun.xml.internal.xsom.impl.scd.Iterators.Map" rather than "java.util.Map" if you don't take the time to select the second or third suggestion.

I realize this might seem like a real corner case, but I think there could be a big UX gain to making suggestions always prioritize core Java classes, unless there is a match within the user's own workspace. People generally avoid type names that overlap with core Java names, so I think this heuristic will be more likely to place the correct suggestion first, rather than the current approach, which seems to be purely alphabetical.

Reproducible: Always

Steps to Reproduce:
1. Create a new Java class
2. Begin a new variable declaration by typing "Map"
3. Type ctrl-space to activate auto suggest.
4. Note that a "com.sun" class is suggested over "java.util.Map"
Comment 1 Dani Megert CLA 2012-01-17 05:55:03 EST
We do filter the com.sun classes from the JRE. If you add additional stuff (like I guess the tools.jar in your case), then you need to add the filters yourself. There are two ways to do it:

1) On the Java > Appearance > Type Filters page add e.g. "com.sun.*".
2) On the 'Libraries' page of your projects Java build path'  properties,
   add an exclusion rule to your JAR. Mark it as 'Forbidden' to filter it
   completely or as 'Discouraged' to allow its use but show it after other
   proposals, and mark it with a warning.
Comment 2 John Goodwin CLA 2012-01-18 10:11:19 EST
Thanks so much for the feedback. Apologies for the dup bug!