Skip to content

Commit d8e65ca

Browse files
vogellaclaude
andcommitted
Docu: Update core expression document with selection variable and fix markdown
Add org.eclipse.ui.selection variable to the variables table and fix markdown rendering throughout the document by wrapping XML elements in backticks so they display correctly. Also update section titles to use title case for consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ce3b75a commit d8e65ca

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

docs/Command_Core_Expressions.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Core expressions are declarative or programmatic expressions based on the org.ec
77
Expressions and the Command Framework
88
=====================================
99

10-
The [Platform Command Framework](PlatformCommandFramework.md) uses [core expressions](Platform_Expression_Framework.md) for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions.
11-
The command framework provides the IEvaluationContext that command core expressions are evaluate against.
10+
The [Platform Command Framework](PlatformCommandFramework.md) uses [core expressions](Platform_Expression_Framework.md) for `enabledWhen` and `activeWhen` for handlers, programmatic activation of contexts, and for `visibleWhen` for menu contributions.
11+
The command framework provides the `IEvaluationContext` that command core expressions are evaluate against.
1212

13-
The IEvaluationContext provides a default variable for evaluations, and a number of named variables.
13+
The `IEvaluationContext` provides a default variable for evaluations, and a number of named variables.
1414
In the command framework, we provide the global selection as a `java.util.Collection` as the default variable.
1515
It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.
1616

17-
The <with/> element can be used to change which variable the child expression elements are evaluating against.
17+
The `<with/>` element can be used to change which variable the child expression elements are evaluating against.
1818

1919
Variables and the Command Framework
2020
===================================
@@ -25,7 +25,7 @@ Some of the variables may not be set, depending on the current application conte
2525

2626
| Name | Type | Description | Since |
2727
| --- | --- | --- | --- |
28-
| activeContexts | A `java.util.Collection` of `java.lang.String` | This is a collection of the active context IDs as strings. Most commonly used with <iterate/>, <count/>, and <test/> with a combined `org.eclipse.common.expressions.PropertyTester`. In **3.3** action sets are mirrored by contexts whose parent is `org.eclipse.ui.actionSet`, and the active action sets show up in the list of active contexts. | 3.2 |
28+
| activeContexts | A `java.util.Collection` of `java.lang.String` | This is a collection of the active context IDs as strings. Most commonly used with `<iterate/>`, `<count/>`, and `<test/>` with a combined `org.eclipse.common.expressions.PropertyTester`. In **3.3** action sets are mirrored by contexts whose parent is `org.eclipse.ui.actionSet`, and the active action sets show up in the list of active contexts. | 3.2 |
2929
| activeActionSets | An `IActionSetDescriptor\[\]` | **Note:** This is currently not used as it points to an internal class and the type might change in any release. | 3.2 |
3030
| activeShell | `org.eclipse.swt.widgets.Shell` | The currently active shell. It can be a dialog or workbench window shell. | 3.2 |
3131
| activeWorkbenchWindowShell | `org.eclipse.swt.widgets.Shell` | The active workbench window shell. | 3.2 |
@@ -38,14 +38,15 @@ Some of the variables may not be set, depending on the current application conte
3838
| activePart | `org.eclipse.ui.IWorkbenchPart` | The active part, which can be the same as the active editor. | 3.2 |
3939
| activePartId | `java.lang.String` | The ID of the currently active part. | 3.2 |
4040
| activeSite | `org.eclipse.ui.IWorkbenchPartSite` | The site of the currently active part. | 3.2 |
41-
| selection | `org.eclipse.jface.viewers.ISelection` | The current global selection. It is often used with <test/> elements with `org.eclipse.core.expressions.PropertyTester`, in programmatic core expressions, and in **3.3** with <iterate/> and <count/> elements. | 3.2 |
42-
| activeMenu | A `java.util.Collection` of `java.lang.String` | This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with <iterate/>, <count/>, and <test/> with a combined `org.eclipse.common.expressions.PropertyTester`. | 3.2 |
41+
| org.eclipse.ui.selection | `Object` | The current global selection if the `ESelectionService` is used. It is often used with `<test/>` elements with `org.eclipse.core.expressions.PropertyTester`, in programmatic core expressions, potentially with `<iterate/>` and `<count/>` elements. | 4.0 |
42+
| selection | `org.eclipse.jface.viewers.ISelection` | The current global selection. It is often used with `<test/>` elements with `org.eclipse.core.expressions.PropertyTester`, in programmatic core expressions, and in **3.3** with `<iterate/>` and `<count/>` elements. | 3.2 |
43+
| activeMenu | A `java.util.Collection` of `java.lang.String` | This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with `<iterate/>`, `<count/>`, and `<test/>` with a combined `org.eclipse.common.expressions.PropertyTester`. | 3.2 |
4344
| activeMenuSelection | `org.eclipse.jface.viewers.ISelection` | This is a selection that is available while a context menu is showing. It is the selection from the selection provider used to register the context menu, usually from `getSite().registerContextMenu(*)`. It is usually the same as the `selection`variable, but not always. This is more for legacy compatibility. | 3.3 |
4445
| activeMenuEditorInput | `org.eclipse.jface.viewers.ISelection` | This is a selection that is available while a context menu is showing. It is the selection from the editor input, usually if includeEditorInput was set to `true` during `getEditorSite().registerContextMenu(*)`. This is more for legacy compatibility. | 3.3 |
4546
| activeFocusControl | `org.eclipse.swt.widgets.Control` | A control that has focus and has been registered with the [IFocusService](https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/swt/IFocusService.java). | 3.3 |
4647
| activeFocusControlId | `java.lang.String` | The ID of a control that has focus and has been registered with the `org.eclipse.ui.swt.IFocusService`. | 3.3 |
4748

48-
Note: All these variables can be used with <test/> and a `org.eclipse.common.expressions.PropertyTester`.
49+
Note: All these variables can be used with `<test/>` and a `org.eclipse.common.expressions.PropertyTester`.
4950

5051
Property Testers
5152
================
@@ -104,7 +105,7 @@ For example, to test an IResource name the property would be `org.eclipse.core.r
104105
| **Property** | **Description** | |
105106
| isPerspectiveOpen | Tests if any perspective is open. | |
106107

107-
Expression examples
108+
Expression Examples
108109
===================
109110

110111
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.
@@ -118,7 +119,7 @@ You can browse the [plugin.xml](https://github.com/eclipse-platform/eclipse.plat
118119
The InfoView provides an `IStructuredSelection` with 0 or more `org.eclipse.ui.examples.contributions.model.Person`.
119120

120121
When using the default variable, you must treat it as an `java.util.Collection`.
121-
That means using <count> or <iterate>
122+
That means using `<count>` or `<iterate>`
122123

123124
```xml
124125
<activeWhen>
@@ -150,7 +151,7 @@ For example:
150151
</activeWhen>
151152
```
152153

153-
Active editor type
154+
Active Editor Type
154155
------------------
155156

156157
If you want your handler to be active for a specific type of editor, you can use **activeEditorId** to target your handler.
@@ -162,7 +163,7 @@ If you want your handler to be active for a specific type of editor, you can use
162163
</activeWhen>
163164
```
164165

165-
Complex nested boolean expressions
166+
Complex Nested Boolean Expressions
166167
----------------------------------
167168

168169
You can also write complex nested boolean expressions, like **(a & b & (c | d | (!e)))**:
@@ -188,16 +189,16 @@ New Core Expressions in 3.3
188189

189190
In 3.3 there were 2 additions to the core expressions framework.
190191

191-
count and iterate
192+
Count and Iterate
192193
-----------------
193194

194195
Count and iterate have always worked against `java.util.Collection`.
195-
The <count/> and <iterate> elements can now be used on any variable that adapts to `org.eclipse.core.expressions.ICountable` and `org.eclipse.core.expressions.IIterable` or implements the interfaces directly.
196+
The `<count/>` and `<iterate>` elements can now be used on any variable that adapts to `org.eclipse.core.expressions.ICountable` and `org.eclipse.core.expressions.IIterable` or implements the interfaces directly.
196197
It wasn't possible to use the java 1.5 constructs for iterable.
197198

198199
The workbench provides an adapter for `ISelection` and `IStructuredSelection`.
199200

200-
definitions
201+
Definitions
201202
-----------
202203

203204
The **org.eclipse.core.expressions.definitions** extension point was introduced.

0 commit comments

Comments
 (0)