This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 387299 - IEclipseContext#runAndTrack does not collect @Inject nor @CanExecute values
Summary: IEclipseContext#runAndTrack does not collect @Inject nor @CanExecute values
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.2   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: 4.2.2   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-15 12:25 EDT by Thomas Schindl CLA
Modified: 2012-10-25 05:14 EDT (History)
6 users (show)

See Also:


Attachments
Example app (7.19 KB, application/zip)
2012-08-15 12:25 EDT, Thomas Schindl CLA
no flags Details
Patch showing the place where this happens (1.58 KB, text/plain)
2012-08-16 08:54 EDT, Nobody - feel free to take it CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schindl CLA 2012-08-15 12:25:11 EDT
Created attachment 219911 [details]
Example app

It looks like RAT is only track direct IEclipseContext access but not those done through @Inject and most important for e4 e.g. @CanExecute.

Run the attached app and see that @CanExecute stuff does not work. I'll mark this as a major bug because it is a requirement for none timerbased toolitem enable/disablement.
Comment 1 Nobody - feel free to take it CLA 2012-08-16 08:54:51 EDT
Created attachment 219958 [details]
Patch showing the place where this happens

The @CanExecute is usually called (from EHandlerService etc) through the invoke method of the injector (InjectorImpl). This methdod calls the invokeUsingClass method which explicitly tells the object supplier not to track the args in two places (the result in the end is the ANDing of the two): 
-MethodRequestor constructor 
-resolveArgs method call.

I don't know if this is by design but changing them to true worked in re-calling the method (the odd-even check in the sample project is made fine).

Now I'm not sure of the implications of this change as it is in the heart of the injector so the patch is just meant to show where the issue lies. Maybe some overloading or something else might be a better solution.
Comment 2 Oleg Besedin CLA 2012-10-24 15:48:13 EDT
(In reply to comment #0)
> Created attachment 219911 [details]
> Example app
> 
> It looks like RAT is only track direct IEclipseContext access but not those
> done through @Inject and most important for e4 e.g. @CanExecute.

Do you mean "invoke" (not "inject")?

> 
> Run the attached app and see that @CanExecute stuff does not work. I'll mark
> this as a major bug because it is a requirement for none timerbased toolitem
> enable/disablement.

By design, #invoke() is a single call, not meant to be repeated automatically. We take data for its arguments from the context, but it is assumed to be a one-time thing; we don't repeat those calls when argument values change.

Injected values we track; #invoke() we do not track. The "@CanExecute" is a form of #invoke().

(By the way, another thing while on the subject: we only track directly injected arguments. If a user code uses injected value A to get value B, we do not track B.)

As far as DI goes, this is very much by design. 

In SDK, "CanExecute" is mostly used by handler processing; "invoke" is used in a number of places. I would refrain from changing "invoke" in a non-backward compatible way. The "CanExecute" - I'll leave up to Paul as he seems to be the main consumer. Personally, it is highly visible so I'd prefer to deprecate / remove "CanExecute" and replace it with something else rather than change functionality so drastically.