Bug 110596 - [assist] don't rank java.lang types lower if a simple name duplicate exists
Summary: [assist] don't rank java.lang types lower if a simple name duplicate exists
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.2 M3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-26 10:29 EDT by Tom Hofmann CLA
Modified: 2005-10-28 12:58 EDT (History)
1 user (show)

See Also:


Attachments
CompletionEngine.java.diff (734 bytes, patch)
2005-09-26 10:32 EDT, Tom Hofmann CLA
no flags Details | Diff
more general patch (1.82 KB, patch)
2005-10-05 06:17 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2005-09-26 10:29:20 EDT
3.2 M2

TYPE_REF proposal ranking...

I noticed that String is ranked lower than StringBuffer and (worse!)
StringIndexOutOfBoundsException in the following situation (| = caret):

  class X {
    St|
  }

which is especially unlucky in this situation:

  class X {
    CharSequence cs= St|
  }

Since I cannot refine the proposal list any further by typing in more characters
(since String is a prefix of the higher-ranked proposals), this means the only
way to select the proposal is by using the arrow keys / mouse.

--

The reason why String is ranked lower is that there are other types in the type
universe that have the same simple name, which causes the
AcceptedType.mustBeQualified flag to come true. This seems "unjust" for
java.lang types. Types that do not require imports should be treated almost like
already imported types.
Comment 1 Tom Hofmann CLA 2005-09-26 10:32:19 EDT
Created attachment 27513 [details]
CompletionEngine.java.diff

The patch only requires qualification for a proposal with a duplicate simple
name if the the proposed type is not in the "java.lang" package.
Comment 2 David Audel CLA 2005-10-05 06:15:49 EDT
The bug is more general.

If a type has an on demand import (java.lang has an implicit on demand import)
and there is another type with the same simple name but without an on demand
import, then CompletionEngine qualify both types. Only the type without import
should be qualified.
Comment 3 David Audel CLA 2005-10-05 06:17:42 EDT
Created attachment 27853 [details]
more general patch
Comment 4 David Audel CLA 2005-10-05 07:31:56 EDT
Fix released and test added in HEAD.
  CompletionTests#testCompletionImportedType1() -> testCompletionImportedType5()
Comment 5 Frederic Fusier CLA 2005-10-28 12:58:50 EDT
Verified for 3.2 M3 using build I20051025-0800+JDT/Core v_618a