Bug 83502 - Need API to create binding keys.
Summary: Need API to create binding keys.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 87725 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-23 08:53 EST by Dirk Baeumer CLA
Modified: 2006-04-14 10:26 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2005-01-23 08:53:39 EST
Due to the limitation of isAssignmentCompatible being limited to bindings form
the same compiler context, JDT/UI implemented some helper class to do this
checks accross compiler contexts.

To provide a efficient implementation I had to hardcode the binding key for the
following types:

- all primitives, including void and null
- all "box" primitives (e.g. Integer, Double, ...)
- Object, Serializable, Cloneable

Could this key somewhere be specified or could the key in general be specified
so that I will not be tricked by key changes. I would be OK for me to know that
the keys for these types will not change in the future.
Comment 1 Philipe Mulet CLA 2005-02-03 04:55:28 EST
A loose spec is preferrable until we have consolidated our implementation (as we
may discover further issues). However, how about helper methods on Signature to
decode them ? 
Comment 2 Dirk Baeumer CLA 2005-02-03 05:57:48 EST
Having methods on Signature to create them would be fine as well. For the
primitive types I already use class Singnature.
Comment 3 Dirk Baeumer CLA 2005-03-11 05:48:00 EST
Having API to create binding keys is getting more important. We need this for
the type implementation we did for refactoring to not hold onto bindings (memory
consumption).

The API to create keys has to support type parameters, wildcards, arrays and
parameterized types as well.
Comment 4 Jerome Lanneluc CLA 2005-03-22 10:39:04 EST
Dirk, do you have the signatures of these types in your hand ? Or do you want to
create the binding keys from a fully qualified name ?
Comment 5 Markus Keller CLA 2005-03-22 13:00:37 EST
[Dirk is not here today, so I'd like to jump in.]

Comment 3 requests API to make new binding keys out of existing binding keys.
The use case is like this:
1. I have a type binding for type XY and store its binding key -> xyKey
2. I'd like to have a binding key for the type XY[] -> xyArrayKey
    (the new API should allow to add the array dimensions to the key)
3. I compare xyArrayKey with other binding keys, and I may eventually convert
the key back to an ITypeBinding in a compiler loop.

The same should be possible for e.g. parameterized types: I have a base type (as
key) and type arguments (keys, too) and I want to combine them into a key for
BaseType<TypeArg1, TypeArg2, ..>.
Comment 6 Dirk Baeumer CLA 2005-03-22 18:05:45 EST
I also need to create binding keys from fully qualified names at least for
Object, Serializable, Clonaeble, the base types and the corresponding boxed types.
Comment 7 Jerome Lanneluc CLA 2005-03-23 10:00:17 EST
Added API BindingKey#createTypeBindingKey(String typeName).
Added tests BindingKeyTests#test015() to testo17().
Comment 8 Jerome Lanneluc CLA 2005-03-23 10:59:50 EST
Added API BindingKey#createParameterizedTypeBindingKey(String genericTypeKey,
String[] argumentTypeKeys) to create a parameterized or raw type binding key.
Added tests BindingKeyTests#test018() to testo19().
Comment 9 Jerome Lanneluc CLA 2005-03-23 11:38:10 EST
Added API BindingKey#createArrayTypeBindingKey(String typeKey, int
arrayDimension) to create an array type binding key.
Added tests BindingKeyTests#test020() to test021().
Comment 10 Jerome Lanneluc CLA 2005-03-23 12:24:42 EST
Added API BindingKey#createWildcardTypeBindingKey(String typeKey, char kind) to
create a wildcard type binding key.
Added tests BindingKeyTests#test022() to test024().
Comment 11 Jerome Lanneluc CLA 2005-03-23 12:29:09 EST
Do you need to create type variable binding keys ?
Comment 12 Markus Keller CLA 2005-03-23 12:56:31 EST
> Do you need to create type variable binding keys ?
Yes, please. I think that would be convenient too. And from looking at your
pace, that shouldn't be too complicated to add, right ;-).
Comment 13 Jerome Lanneluc CLA 2005-03-24 04:44:22 EST
The pace is high because the implementation is very naive. I certainly will have
to go back to those when you enter bugs in the future :-)
Comment 14 Jerome Lanneluc CLA 2005-03-24 04:48:19 EST
Added API BindingKey#createTypeVariableBindingKey(String typeVariableName,
String declaringKey) to create a type variable binding key.
Added tests BindingKeyTests#test025() to test026().
Comment 15 David Audel CLA 2005-03-31 06:09:03 EST
Verified in I20050330-0500
Comment 16 Frederic Fusier CLA 2006-04-14 10:26:30 EDT
*** Bug 87725 has been marked as a duplicate of this bug. ***