| Summary: | [quick assist] Qualify simple type reference | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | NoName <utilisateur_182> | ||||||
| Component: | UI | Assignee: | 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
NoName
See also bug 112999 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 *** (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 ? If you want I can reopen and rename this bug for the invert request (only one request per bug, please...) . (In reply to comment #5) > . Thanks, you were quicker. 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.
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. (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. 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 ! > 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)
Created attachment 97517 [details]
second try
here is a more complete one
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. |