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

Bug 209467

Summary: [quick assist] Qualify simple type reference
Product: [Eclipse Project] JDT Reporter: NoName <utilisateur_182>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: benno.baumgartner, martinae, utilisateur_768
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
Patch for content assist entry to qualify a simple type name
none
second try none

Description NoName CLA 2007-11-12 05:47:29 EST
Build ID: I20071101-2000

It would be great to have the following quick assist:

java.util.Map m; <-> Map m;

(in both direction)

Tell me what you think :)
Comment 1 Benno Baumgartner CLA 2007-11-12 06:11:30 EST
See also bug 112999
Comment 2 Martin Aeschlimann CLA 2007-11-12 07:04:24 EST
We already have an action 'Add Import' that does that. Quick assist would also be possible, but is IMO not urgent.

*** This bug has been marked as a duplicate of bug 43082 ***
Comment 3 NoName CLA 2007-11-12 07:14:30 EST
(In reply to comment #2)
> We already have an action 'Add Import' that does that. Quick assist would also
> be possible, but is IMO not urgent.
> 
> *** This bug has been marked as a duplicate of bug 43082 ***

What about the other way around ?
Comment 4 Martin Aeschlimann CLA 2007-11-12 07:20:00 EST
If you want I can reopen and rename this bug for the invert request (only one request per bug, please...)
Comment 5 Martin Aeschlimann CLA 2007-11-12 08:32:56 EST
.
Comment 6 NoName CLA 2007-11-13 07:50:24 EST
(In reply to comment #5)
> .

Thanks, you were quicker.

Comment 7 NoName CLA 2008-04-11 14:49:46 EDT
Created attachment 95736 [details]
Patch for content assist entry to qualify a simple type name

The patch was done against v20080327-1300 but should works on HEAD.

Please tell if you accept it.
Comment 8 Martin Aeschlimann CLA 2008-04-14 04:50:41 EDT
Can you have a look at the following:

java.util.Vector<String>[] v;

the name can already be qualified:
  -> look if the parent isn't Name again

- treat array types
  if (binding.isArray() binding= binding.getElementType)
 
- treat parameterized type
  binding= binding.getTypeDeclaration)

You can create any kind of name (simple or qualified name) with ast.newName(name).

The test if there is a qualified name for a type is more complicated (local types, types inside local type, type varibales, ...)
I think binding.getQualifiedName will only return you a qualified name for types we are interested.
Comment 9 utilisateur_768 CLA 2008-04-23 03:01:25 EDT
(In reply to comment #8)
> Can you have a look at the following:
> 
> java.util.Vector<String>[] v;
> 
> the name can already be qualified:
>   -> look if the parent isn't Name again

Yes il will add it.

> - treat array types
>   if (binding.isArray() binding= binding.getElementType)

Ok

> - treat parameterized type
>   binding= binding.getTypeDeclaration)

It won't help. Since i don't rewrite the complete type, but only on simple name, it could be a type parameter without any problem.


> You can create any kind of name (simple or qualified name) with
> ast.newName(name).

Thanks


> The test if there is a qualified name for a type is more complicated (local
> types, types inside local type, type varibales, ...)
> I think binding.getQualifiedName will only return you a qualified name for
> types we are interested.

Well great. I will look at this method.
 

Comment 10 utilisateur_768 CLA 2008-04-23 15:07:43 EDT
binding.getQualifiedName() returns "java.util.Vector<java.lang.String>" in your example (the javadoc seems to be wrong). And "ast.newName()" of this string throw illegal exception !

Comment 11 Martin Aeschlimann CLA 2008-04-24 03:47:02 EDT
> binding.getQualifiedName() returns "java.util.Vector<java.lang.String>" in your
> example (the javadoc seems to be wrong). And "ast.newName()" of this string
> throw illegal exception !

It depends if the type binding is for a type reference or a type declaration.

pack foo;
class X<A> {
  X<String> x;
}

X<A> is the declaration: The qualified name will be foo.A
X<String> is a reference: The qualified name will be foo.A<String>

To get the declaration from a reference: binding.getTypeDeclaration
To test if a type binding is a reference: binding.isParameterizedType

-> before getting the qualified name:
  binding= binding.getTypeDeclaration)
(binding.getTypeDeclaration returns itself if the binding is not a parameterized type)


Comment 12 utilisateur_768 CLA 2008-04-24 15:43:04 EDT
Created attachment 97517 [details]
second try

here is a more complete one
Comment 13 Eclipse Genie CLA 2020-02-21 13:14:08 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.