Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363699 - [Compatibility] ExpressionContext: all variables are invalidated on every active part switch
Summary: [Compatibility] ExpressionContext: all variables are invalidated on every act...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-14 09:49 EST by Oleg Besedin CLA
Modified: 2021-08-17 12:57 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Besedin CLA 2011-11-14 09:49:18 EST
All variables in ExpressionContext are retrieved using this:

	public Object getVariable(String name) {
		Object obj = eclipseContext.getActiveLeaf().get(name);
	...
	}

This means that on every change of the active part all of the variables retrieved for commands evaluation (activeWhen, enabledWhen) are marked as invalid. This triggers a snowball causing all handler processing to be re-done from scratch.

A lot of variables (such as, for instance, activeWorkbenchWindow) either do not depend on the active part, or are not affected by the switch in the particular active part.

However, some variables might be affected by the active part switch.

We need to get a list of common variables and start setting/updating them on their appropriate contexts, then remove the "getActiveLeaf()" from the code above.
Comment 1 Thomas Schindl CLA 2011-11-14 09:55:10 EST
Well when this clean up is done then bug 358020 is probably important as well (the patch there changes the logic a bit but I'm not sure what Paul is going to do with it)
Comment 2 Paul Webster CLA 2011-11-14 10:26:39 EST
The problem is architectural in nature, and so we should think about the solution as such.

In 3.x there is the EvalutionService.  It holds an EvaluationContext and the ISourceProviders update that one global context with variables.  Asking for the state usually creates a child EvaluationContext off of the main one, but only to protect the global context from changes.  The entire app sees the application state, so your window active part is visible to all windows (we just try and disable any visible UI changes in the non-active window).  The number of application variables is extensible using the org.eclipse.ui.services extension point.

In Eclipse 4 we have a hierarchy of IEclipseContexts that matches the part hierarchy.  Its goal is "Ask your context for runtime state and you will get the correct answer, based on your place in the hierarchy and the active threads".  For Eclipse 4 the lookup is "find the active leaf and then walk up the parent hierarchy".

The current code is the simplest that will provide the correct answer.  How can we make it performant?

PW
Comment 3 Eclipse Genie CLA 2019-05-15 19:24:19 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.
Comment 4 Dani Megert CLA 2019-05-30 11:09:56 EDT
Nothing changed here.
Comment 5 Eclipse Genie CLA 2021-08-17 12:57:56 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. 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.