Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 106069 - [quick fix] bugs with generic types
Summary: [quick fix] bugs with generic types
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-04 12:44 EDT by Martin Aeschlimann CLA
Modified: 2005-09-02 10:53 EDT (History)
3 users (show)

See Also:


Attachments
patch for jdt.ui (22.60 KB, patch)
2005-08-04 12:46 EDT, Martin Aeschlimann CLA
no flags Details | Diff
patch for jdt.ui.tests (22.74 KB, patch)
2005-08-04 12:47 EDT, Martin Aeschlimann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2005-08-04 12:44:46 EDT
3.1

The attaches patch fixes the following bugs, mostly related to bugs that quick
fix has whe dealing with generic types
bug 99398, bug 99389, bug 100551, bug 100236, bug 106013

Some explanations for the reviewers:

- correct mapping of types:
ASTResolving.guessBindingForTypeReference tries to find a guess for unknown types:
E.g. here X will be guessed as String:
   List<X> list= new List<String>();

- where is which type allowed:
ASTResolving.getPossibleTypeKinds returns a set of flags to decide if a location
can be primitive, class/interface/..  or a type variable
E.g here X can only be a class or interface
  X<String> list;

UtilitiesTest tests these two methods.

- NewCUCompletionUsingWizardProposal now sets the type name including type
parameters. The type name field is then editable as we should give the user a
chance to modify the chosen type parameter names.
Other changes are to improve the guessing of the super type. Note that its
better to not guess anything than something wrong.

- to get a display string for a type binding,
BindingLabelProvider.getBindingLabel(...) should be used, never typeBinding.getName.
Comment 1 Martin Aeschlimann CLA 2005-08-04 12:46:53 EDT
Created attachment 25688 [details]
patch for jdt.ui
Comment 2 Martin Aeschlimann CLA 2005-08-04 12:47:16 EDT
Created attachment 25689 [details]
patch for jdt.ui.tests
Comment 3 Dirk Baeumer CLA 2005-08-11 10:42:26 EDT
Markus, can you please have a look at this patch as well. If we feel confident
this is something we might want to put into 3.1.1 to improve quick fix in the
space of the new 1.5 language features.
Comment 4 Dirk Baeumer CLA 2005-08-17 05:48:55 EDT
I reviewed the patch and after some testing in the 3.2 stream I opt to back
port/release it to 3.1.1.
Comment 5 Markus Keller CLA 2005-08-17 13:57:34 EDT
NewCUCompletionUsingWizardProposal#getTypeName(int, Name):
Nice workaround for NON-NLS warnings, but the following would be smaller,
faster, and easier to read:
    typeArgBaseName= name.startsWith("T") ? "S" : "T"

When I have
    java.util.Map m= new X<String, Integer>();
in a 1.4 project and invoke quick fix on 'X', the wizard is pre-filled with type
parameters and comes up with an error. IMO, it's no problem if we leave it this
way, since the error message tells about source level 5.0, etc.

Otherwise, the patch looks fine, and I agree that it would be a valuable
contribution for 3.1.1.
Comment 6 Martin Aeschlimann CLA 2005-08-18 04:41:20 EDT
patches released in 3.1.1 streams > 20050818
Comment 7 Tom Hofmann CLA 2005-09-02 10:44:28 EDT
verifying...
Comment 8 Tom Hofmann CLA 2005-09-02 10:53:04 EDT
verified all scenarios in bug 99398, bug 99389, bug 100551, bug 100236, bug
106013 work as expected in 3.1.1.