Bug 180905 - Tweaks to recovered bindings
Summary: Tweaks to recovered bindings
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
Depends on:
Blocks:
 
Reported: 2007-04-04 05:37 EDT by Markus Keller CLA
Modified: 2007-04-27 10:52 EDT (History)
2 users (show)

See Also:


Attachments
proposed API adjustments (4.99 KB, patch)
2007-04-04 05:38 EDT, Markus Keller CLA
no flags Details | Diff
Proposed fix (13.84 KB, patch)
2007-04-23 22:13 EDT, Olivier Thomann CLA
no flags Details | Diff
Better patch (18.66 KB, patch)
2007-04-24 10:54 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2007-04-04 05:37:34 EDT
HEAD

The current API for recovered bindings has some inconsistencies and inconveniences:
- IBinding#getKey() should return a unique key per recovered binding
- IBinding#isEqualTo(..) must return true if the argument is the same object as the receiver
- IBinding#getJavaElement() should return a non-null IJavaElement (which may not exist for recovered bindings).

It would be convenient if recoverd ITypeBindings could resemble class bindings as much as possible:
- createArrayType(..) should work
- getPackage() should return the package of the recovered reference's enclosing type declaration
- getSuperclass() should return java.lang.Object
- is*Compatible() should be adjusted accordingly
Comment 1 Markus Keller CLA 2007-04-04 05:38:31 EDT
Created attachment 62898 [details]
proposed API adjustments
Comment 2 Olivier Thomann CLA 2007-04-04 08:45:13 EDT
I completely disagree with this request.
It was never expected that recovered bindings would "behave" like other bindings. They are there only to report a binding instead of null.
You have a call to identify them.

is*Compatible() doesn't make sense. There is no "real" resolved information in this case.
Comment 3 Martin Aeschlimann CLA 2007-04-04 10:15:00 EDT
For compatibility reasons, it's better if recovered bindings behave like an existing type of bindings. If they are a special kind like now, then we need to go through all our code and check if the code made any assumptions about what bindings there can be.
We want to avoid this otherwise we can't enable recovered bindings on reconcile without badly breaking reconcile participants. If recovered bindings behave like normal class bindings, the only difference is that the return a Java element that doesn't exist. This is something we always expected.
Comment 4 Olivier Thomann CLA 2007-04-23 21:46:14 EDT
(In reply to comment #0)
> The current API for recovered bindings has some inconsistencies and
> inconveniences:
> - IBinding#getKey() should return a unique key per recovered binding
Any suggestion?

> - IBinding#getJavaElement() should return a non-null IJavaElement (which may
> not exist for recovered bindings).
This doesn't make sense. There is no such element and getJavaElement() can return null for other cases. So the user code would already have null checks for this case and I don't see a need to return a "fake" java element.

> - createArrayType(..) should work
I'll add this one.

> - getPackage() should return the package of the recovered reference's enclosing
> type declaration
null is the best answer in this case. Again getPackage() can return null so this is the best answer for recovered type binding.

> - getSuperclass() should return java.lang.Object
Ok

> - is*Compatible() should be adjusted accordingly
I'll check that.
Comment 5 Olivier Thomann CLA 2007-04-23 22:13:01 EDT
Created attachment 64669 [details]
Proposed fix

Markus and Martin,

This is a new proposal. Please review it and let me know asap what you think.
I plan to release it before the end of the week.
Comment 6 Martin Aeschlimann CLA 2007-04-24 04:23:21 EDT
We want recovered binding behave like a reference binding (class, interface...), not like a new kind of binding. If we have such a reference binding in hand, we know, from the spec, that it has a (not-null) package and a Java element. Therefore, we don't test again if the result is null.
Comment 7 Olivier Thomann CLA 2007-04-24 09:12:36 EDT
Then I'll set the package to be the default package.
But for the java element, there is nothing we can do. It doesn't make sense to return a fake element.
Comment 8 Olivier Thomann CLA 2007-04-24 09:23:06 EDT
But I don't see the point of returning values that cannot be used anyway.
Comment 9 Olivier Thomann CLA 2007-04-24 10:54:51 EDT
Created attachment 64747 [details]
Better patch
Comment 10 Olivier Thomann CLA 2007-04-24 11:23:35 EDT
Released for 3.3M7.
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0672()
org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0673()
org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0676()
Comment 11 Maxime Daniel CLA 2007-04-27 10:52:52 EDT
Verified for 3.3 M7 using source code v_751.