Bug 119948 - [expressions] Eclipse core expression returns invalid result for AdaptExpression
Summary: [expressions] Eclipse core expression returns invalid result for AdaptExpression
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: bugday, helpwanted
Depends on: 127623
Blocks:
  Show dependency tree
 
Reported: 2005-12-08 14:11 EST by Michael D. Elder CLA
Modified: 2019-08-31 08:35 EDT (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael D. Elder CLA 2005-12-08 14:11:30 EST
The AdaptExpression assumes that if an element has an AdapterFactory for a target type, and the adapter returned is null, that the evaluation result is NOT_LOADED. However, there are cases where the adapter factory is loaded, but the element doeesn't have a valid adaption path. For instance, there is an adapter factory defined for IFile-->IJavaElement, but not all IFiles adapt to IJavaElement, only those which are part of the Java model. 

Therefore, the following expression:

<adapt 
   type="org.eclipse.jdt.coreIJavaElement" />

Should return EvalutationResult.FALSE when the JDT adapter factory is loaded, and a given IFile does not adapt to IJavaElement (like the '.project' file for instance).
Comment 1 Nick Edgar CLA 2005-12-08 14:59:45 EST
Moving this to JDT-UI but that's not ideal either.  Dirk, which component should we use for core.expressions?
Comment 2 Dirk Baeumer CLA 2005-12-09 08:12:15 EST
The home is currently JDT/UI.

Will look into it during M5.
Comment 3 Dirk Baeumer CLA 2006-01-03 12:16:08 EST
The problem is that the adpat expression isn't able to figure this out without additional API on IAdapterManager. I propose an additional method queryAdapter(Object adaptable, String adapterTypeName) which returns either NONE, NOT_LOADED, LOADED.

John, any comments ?
Comment 4 John Arthorne CLA 2006-01-03 17:01:53 EST
Can't you distinguish this case using IAdapterManager.hasAdapter?  If hasAdapter returns true, then you know there is a factory that claims it can do the transformation. If a subsequent call to loadAdapter returns null, you know that the factory exists but it is not willing to provide an adapter in that case.
Comment 5 Dirk Baeumer CLA 2006-01-04 05:49:01 EST
If I call loadAdapter then I will trigger plug-in loading which I try to avoid. Currently the expression language doesn't load any polug-ins. It returns NOT_LOADED instead. 

Comment 6 Dirk Baeumer CLA 2006-02-13 10:54:56 EST
Moving to M6.

John, can you please respond to my last comment.
Comment 7 John Arthorne CLA 2006-02-13 12:14:53 EST
Well, it sounds like you need new API on IAdapterManager then.  I suggest entering an enhancement against Equinox Bundles (I don't have commit rights to IAdapterManager since the move to Equinox).  The short summary is that when hasAdapter returns true but getAdapter returns false, there are two possible reasons:

 - The factory is not yet loaded
 - The factory is loaded but cannot adapt that particular object.
Comment 8 Dirk Baeumer CLA 2006-03-03 12:27:21 EST
Michael, how important is this for you. If very important can you please express this in bug 127623. I can't fix this without the additional API.
Comment 9 Dirk Baeumer CLA 2006-03-26 05:45:20 EST
Postponing since bug 127623 didn't get fixed in core.
Comment 10 Michael D. Elder CLA 2006-03-26 12:25:22 EST
I think for this release we can get around this since NOT_LOADED == FALSE in most of our uses of the Core Expressions framework. 

One possible suggestion is that with the new API on EvaluationContext to load plugins when necessary to evaluate expressions could also indicate that it's okay to load plugins for Adapter Factories as well. 
Comment 11 Boris Bokowski CLA 2006-07-29 01:19:13 EDT
See bug 151239 for another case where an adapt expression should return FALSE instead of NOT_LOADED.
Comment 12 Dani Megert CLA 2009-03-24 13:03:05 EDT
Moving bugs due to ownership change.
Comment 13 Paul Webster CLA 2010-05-12 09:18:04 EDT
I'd like to consider this as an enhancement for 3.7.  Adding the adapt element equivalent of test's forcePluginActivation attribute.

PW
Comment 14 Paul Webster CLA 2011-03-09 10:46:50 EST
I'll have to move it off to 3.8/4.2

PW
Comment 15 Craig Foote CLA 2012-05-13 11:25:58 EDT
Hi Paul, how's it looking for for delivery with 4.2?
Comment 16 Paul Webster CLA 2012-05-13 11:56:00 EDT
this won't make it into 4.2 now.  I've marked it as helpwanted.

PW
Comment 17 Dani Megert CLA 2013-05-27 04:16:30 EDT
(In reply to comment #16)
> this won't make it into 4.2 now.  I've marked it as helpwanted.
> 
> PW

Sorry, 4.3 is already closed for such a change.
Comment 18 Eclipse Genie CLA 2019-08-31 08:35:33 EDT
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.

If you have further information on the current state of the bug, please add it. 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.