Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2018-03-22 15:17:35 +0000
committerLucas Bullen2018-03-27 12:07:28 +0000
commit2c46f0a21f3a27b35898ca47d062ac7cf375c4b9 (patch)
treeca0de1ef01edf1810191a5c37cd85dbf80979900
parentba618ed417867d991a486c9760e3f1e4f5a1ef75 (diff)
downloadeclipse.platform.text-2c46f0a21f3a27b35898ca47d062ac7cf375c4b9.tar.gz
eclipse.platform.text-2c46f0a21f3a27b35898ca47d062ac7cf375c4b9.tar.xz
eclipse.platform.text-2c46f0a21f3a27b35898ca47d062ac7cf375c4b9.zip
Bug 532774 - [GenericEditor] Support <enabledWhen> for the all generericI20180327-0805
editor extension points Change-Id: Ifbe2b0fa2312b0141f57a2483fce45695a679cfa Signed-off-by: angelozerr <angelo.zerr@gmail.com>
-rw-r--r--org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd270
-rw-r--r--org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd270
-rw-r--r--org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd270
-rw-r--r--org.eclipse.ui.genericeditor/schema/hoverProviders.exsd328
-rw-r--r--org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd270
-rw-r--r--org.eclipse.ui.genericeditor/schema/reconcilers.exsd270
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/AutoEditStrategyRegistry.java5
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java5
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java12
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java66
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java5
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ReconcilerRegistry.java9
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/TextHoverRegistry.java4
13 files changed, 1046 insertions, 738 deletions
diff --git a/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd b/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd
index 6e9cc940446..e179bfc8c3b 100644
--- a/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd
+++ b/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd
@@ -1,116 +1,154 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.ui.genericeditor" id="autoEditStrategies" name="Auto edit strategies"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute auto edit strategies for a given content type.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="autoEditStrategy"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="autoEditStrategy">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.IAutoEditStrategy&lt;/code&gt;
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.IAutoEditStrategy"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="contentType" type="string" use="required">
- <annotation>
- <documentation>
- The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 1.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- This is an example of a strategy being registered for a target definition file type:
-
-&lt;pre&gt;
-&lt;extension point=&quot;org.eclipse.ui.genericeditor.autoEditStrategies&quot;&gt;
- &lt;autoEditStrategy
- class=&quot;org.eclipse.ui.genericeditor.examples.TargedDefinitionAutoEditStrategy&quot;
- contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
- &lt;/autoEditStrategy&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2017 Rogue Wave Software Inc. and others
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.ui.genericeditor" id="autoEditStrategies" name="Auto edit strategies"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute auto edit strategies for a given content type.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="autoEditStrategy"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="autoEditStrategy">
+ <complexType>
+ <sequence>
+ <element ref="enabledWhen" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.IAutoEditStrategy&lt;/code&gt;
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.IAutoEditStrategy"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="contentType" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="enabledWhen">
+ <annotation>
+ <documentation>
+ A core Expression that controls the enabled of the given auto edit strategies. The viewer, editor, and editor input are registered in the evaluation context as variable:
+
+ * &lt;with variable=&quot;viewer&quot;&gt; : use it if your expression requires the viewer.
+ * &lt;with variable=&quot;editor&quot;&gt; : use it if your expression requires the editor.
+ * &lt;with variable=&quot;editorInput&quot;&gt; : use it if your expression requires the editor input.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="not"/>
+ <element ref="or"/>
+ <element ref="and"/>
+ <element ref="instanceof"/>
+ <element ref="test"/>
+ <element ref="systemTest"/>
+ <element ref="equals"/>
+ <element ref="count"/>
+ <element ref="with"/>
+ <element ref="resolve"/>
+ <element ref="adapt"/>
+ <element ref="iterate"/>
+ <element ref="reference"/>
+ </choice>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ This is an example of a strategy being registered for a target definition file type:
+
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.genericeditor.autoEditStrategies&quot;&gt;
+ &lt;autoEditStrategy
+ class=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionAutoEditStrategy&quot;
+ contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
+ &lt;enabledWhen&gt;
+ &lt;with variable=&quot;editor&quot;&gt;
+ &lt;test property=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionPropertyTester&quot;&gt;
+ &lt;/test&gt;
+ &lt;/with&gt;
+ &lt;/enabledWhen&gt;
+ &lt;/autoEditStrategy&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2017 Rogue Wave Software Inc. and others
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd b/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd
index 441b85ab13f..3bc7352f9c4 100644
--- a/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd
+++ b/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd
@@ -1,116 +1,154 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.ui.genericeditor" id="contentAssistProcessors" name="Content assist processors"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute content assist processors for adding content assist support to a given content type.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="contentAssistProcessor"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="contentAssistProcessor">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.contentassist.IContentAssistProcessor&lt;/code&gt;
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.contentassist.IContentAssistProcessor"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="contentType" type="string" use="required">
- <annotation>
- <documentation>
- The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 1.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- This is an example of a processor being registered for a target definition file type:
-
-&lt;pre&gt;
-&lt;extension point=&quot;org.eclipse.ui.genericeditor.contentAssistProcessors&quot;&gt;
- &lt;contentAssistProcessor
- class=&quot;org.eclipse.ui.genericeditor.examples.TargedDefinitionContentAssist&quot;
- contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
- &lt;/contentAssistProcessor&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2016 Red Hat Inc. and others
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.ui.genericeditor" id="contentAssistProcessors" name="Content assist processors"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute content assist processors for adding content assist support to a given content type.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="contentAssistProcessor"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contentAssistProcessor">
+ <complexType>
+ <sequence>
+ <element ref="enabledWhen" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.contentassist.IContentAssistProcessor&lt;/code&gt;
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.contentassist.IContentAssistProcessor"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="contentType" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="enabledWhen">
+ <annotation>
+ <documentation>
+ A core Expression that controls the enabled of the given content assist processor. The viewer, editor, and editor input are registered in the evaluation context as variable:
+
+ * &lt;with variable=&quot;viewer&quot;&gt; : use it if your expression requires the viewer.
+ * &lt;with variable=&quot;editor&quot;&gt; : use it if your expression requires the editor.
+ * &lt;with variable=&quot;editorInput&quot;&gt; : use it if your expression requires the editor input.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="not"/>
+ <element ref="or"/>
+ <element ref="and"/>
+ <element ref="instanceof"/>
+ <element ref="test"/>
+ <element ref="systemTest"/>
+ <element ref="equals"/>
+ <element ref="count"/>
+ <element ref="with"/>
+ <element ref="resolve"/>
+ <element ref="adapt"/>
+ <element ref="iterate"/>
+ <element ref="reference"/>
+ </choice>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ This is an example of a processor being registered for a target definition file type:
+
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.genericeditor.contentAssistProcessors&quot;&gt;
+ &lt;contentAssistProcessor
+ class=&quot;org.eclipse.ui.genericeditor.examples.TargedDefinitionContentAssist&quot;
+ contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
+ &lt;enabledWhen&gt;
+ &lt;with variable=&quot;editor&quot;&gt;
+ &lt;test property=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionPropertyTester&quot;&gt;
+ &lt;/test&gt;
+ &lt;/with&gt;
+ &lt;/enabledWhen&gt;
+ &lt;/contentAssistProcessor&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2016 Red Hat Inc. and others
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd b/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd
index 25c6abf7249..7724a4973d1 100644
--- a/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd
+++ b/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd
@@ -1,116 +1,154 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.ui.genericeditor" id="highlightReconcilers" name="Highlight reconcilers"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute highlight reconcilers for controlling the highlighting on a file with a given content type. Reconcilers attached to this extension point that listen to the preference &quot;org.eclipse.ui.genericeditor.togglehighlight&quot; will be toggled with the &quot;Toggle Mark Occurences&quot; button.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="highlightReconciler"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="highlightReconciler">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.reconciler.IReconciler&lt;/code&gt;
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.reconciler.IReconciler"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="contentType" type="string" use="required">
- <annotation>
- <documentation>
- The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 1.1
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- Below is an example of how to use the Highlight Reconciler extension point:
-
-&lt;pre&gt;
-&lt;extension point=&quot;org.eclipse.ui.genericeditor.highlightReconcilers&quot;&gt;
- &lt;presentationReconciler
- class=&quot;org.eclipse.ui.genericeditor.examples.TPHighlightReconcilers&quot;
- contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
- &lt;/presentationReconciler&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2017 Red Hat Inc. and others
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.ui.genericeditor" id="highlightReconcilers" name="Highlight reconcilers"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute highlight reconcilers for controlling the highlighting on a file with a given content type. Reconcilers attached to this extension point that listen to the preference &quot;org.eclipse.ui.genericeditor.togglehighlight&quot; will be toggled with the &quot;Toggle Mark Occurences&quot; button.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="highlightReconciler"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="highlightReconciler">
+ <complexType>
+ <sequence>
+ <element ref="enabledWhen" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.reconciler.IReconciler&lt;/code&gt;
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.reconciler.IReconciler"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="contentType" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="enabledWhen">
+ <annotation>
+ <documentation>
+ A core Expression that controls the enabled of the given highlight reconciler. The viewer, editor, and editor input are registered in the evaluation context as variable:
+
+ * &lt;with variable=&quot;viewer&quot;&gt; : use it if your expression requires the viewer.
+ * &lt;with variable=&quot;editor&quot;&gt; : use it if your expression requires the editor.
+ * &lt;with variable=&quot;editorInput&quot;&gt; : use it if your expression requires the editor input.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="not"/>
+ <element ref="or"/>
+ <element ref="and"/>
+ <element ref="instanceof"/>
+ <element ref="test"/>
+ <element ref="systemTest"/>
+ <element ref="equals"/>
+ <element ref="count"/>
+ <element ref="with"/>
+ <element ref="resolve"/>
+ <element ref="adapt"/>
+ <element ref="iterate"/>
+ <element ref="reference"/>
+ </choice>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ Below is an example of how to use the Highlight Reconciler extension point:
+
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.genericeditor.highlightReconcilers&quot;&gt;
+ &lt;highlightReconciler
+ class=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionHighlightReconciler&quot;
+ contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
+ &lt;enabledWhen&gt;
+ &lt;with variable=&quot;editor&quot;&gt;
+ &lt;test property=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionPropertyTester&quot;&gt;
+ &lt;/test&gt;
+ &lt;/with&gt;
+ &lt;/enabledWhen&gt;
+ &lt;/highlightReconciler&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2017 Red Hat Inc. and others
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd b/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd
index 572920483b3..440c2edd0af 100644
--- a/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd
+++ b/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd
@@ -1,145 +1,183 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.ui.genericeditor" id="hoverProviders" name="Hover providers"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute hover providers for showing text hovers in a file with a given content type.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="hoverProvider" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="hoverProvider">
- <complexType>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- A string uniquely identifying this reference provider.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.ITextHover&lt;/code&gt;
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.ITextHover"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="contentType" type="string" use="required">
- <annotation>
- <documentation>
- The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="isBefore" type="string">
- <annotation>
- <documentation>
- The id of a hoverProvider before which to place this contribution.
-Plan is to have contributions are sorted according to that value and to have only the first one shown (or the the first &quot;compoundable&quot; ones)
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.ui.genericeditor.hoverProviders/hoverProvider/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="isAfter" type="string">
- <annotation>
- <documentation>
- The id of a hoverProvider after which to place this contribution.
-Plan is to have contributions are sorted according to that value and to have only the first one shown (or the the first &quot;compoundable&quot; ones)
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.ui.genericeditor.hoverProviders/hoverProvider/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 1.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- Below is an example using the hover provider extension point:
-
-&lt;pre&gt;
-&lt;extension point=&quot;org.eclipse.ui.genericeditor.hoverProviders&quot;&gt;
- &lt;hoverProvider
- class=&quot;org.eclipse.ui.genericeditor.tests.contributions.MagicHoverProvider&quot;
- contentType=&quot;org.eclipse.core.runtime.text&quot;&gt;
- &lt;/hoverProvider&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2016 Red Hat Inc. and others
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.ui.genericeditor" id="hoverProviders" name="Hover providers"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute hover providers for showing text hovers in a file with a given content type.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="hoverProvider" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="hoverProvider">
+ <complexType>
+ <sequence>
+ <element ref="enabledWhen" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ A string uniquely identifying this reference provider.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.ITextHover&lt;/code&gt;
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.ITextHover"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="contentType" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="isBefore" type="string">
+ <annotation>
+ <documentation>
+ The id of a hoverProvider before which to place this contribution.
+Plan is to have contributions are sorted according to that value and to have only the first one shown (or the the first &quot;compoundable&quot; ones)
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.ui.genericeditor.hoverProviders/hoverProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="isAfter" type="string">
+ <annotation>
+ <documentation>
+ The id of a hoverProvider after which to place this contribution.
+Plan is to have contributions are sorted according to that value and to have only the first one shown (or the the first &quot;compoundable&quot; ones)
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.ui.genericeditor.hoverProviders/hoverProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="enabledWhen">
+ <annotation>
+ <documentation>
+ A core Expression that controls the enabled of the given hover provider. The viewer, editor, and editor input are registered in the evaluation context as variable:
+
+ * &lt;with variable=&quot;viewer&quot;&gt; : use it if your expression requires the viewer.
+ * &lt;with variable=&quot;editor&quot;&gt; : use it if your expression requires the editor.
+ * &lt;with variable=&quot;editorInput&quot;&gt; : use it if your expression requires the editor input.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="not"/>
+ <element ref="or"/>
+ <element ref="and"/>
+ <element ref="instanceof"/>
+ <element ref="test"/>
+ <element ref="systemTest"/>
+ <element ref="equals"/>
+ <element ref="count"/>
+ <element ref="with"/>
+ <element ref="resolve"/>
+ <element ref="adapt"/>
+ <element ref="iterate"/>
+ <element ref="reference"/>
+ </choice>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ Below is an example using the hover provider extension point:
+
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.genericeditor.hoverProviders&quot;&gt;
+ &lt;hoverProvider
+ class=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionHoverProvider&quot;
+ contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
+ &lt;enabledWhen&gt;
+ &lt;with variable=&quot;editor&quot;&gt;
+ &lt;test property=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionPropertyTester&quot;&gt;
+ &lt;/test&gt;
+ &lt;/with&gt;
+ &lt;/enabledWhen&gt;
+ &lt;/hoverProvider&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2016 Red Hat Inc. and others
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd b/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd
index 17aca3a3506..ab7bdf59cf6 100644
--- a/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd
+++ b/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd
@@ -1,116 +1,154 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.ui.genericeditor" id="presentationReconcilers" name="Presentation reconcilers"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute presentation reconcilers for controlling the presentation on a file with a given content type.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="presentationReconciler"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="presentationReconciler">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.presentation.IPresentationReconciler&lt;/code&gt;
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.presentation.IPresentationReconciler"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="contentType" type="string" use="required">
- <annotation>
- <documentation>
- The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 1.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- Below is an example of how to use the Presentation Reconciler extension point:
-
-&lt;pre&gt;
-&lt;extension point=&quot;org.eclipse.ui.genericeditor.presentationReconcilers&quot;&gt;
- &lt;presentationReconciler
- class=&quot;org.eclipse.ui.genericeditor.examples.TPPresentationReconciler&quot;
- contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
- &lt;/presentationReconciler&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2016 Red Hat Inc. and others
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.ui.genericeditor" id="presentationReconcilers" name="Presentation reconcilers"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute presentation reconcilers for controlling the presentation on a file with a given content type.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="presentationReconciler"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="presentationReconciler">
+ <complexType>
+ <sequence>
+ <element ref="enabledWhen" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.presentation.IPresentationReconciler&lt;/code&gt;
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.presentation.IPresentationReconciler"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="contentType" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="enabledWhen">
+ <annotation>
+ <documentation>
+ A core Expression that controls the enabled of the given presentation reconciler. The viewer, editor, and editor input are registered in the evaluation context as variable:
+
+ * &lt;with variable=&quot;viewer&quot;&gt; : use it if your expression requires the viewer.
+ * &lt;with variable=&quot;editor&quot;&gt; : use it if your expression requires the editor.
+ * &lt;with variable=&quot;editorInput&quot;&gt; : use it if your expression requires the editor input.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="not"/>
+ <element ref="or"/>
+ <element ref="and"/>
+ <element ref="instanceof"/>
+ <element ref="test"/>
+ <element ref="systemTest"/>
+ <element ref="equals"/>
+ <element ref="count"/>
+ <element ref="with"/>
+ <element ref="resolve"/>
+ <element ref="adapt"/>
+ <element ref="iterate"/>
+ <element ref="reference"/>
+ </choice>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ Below is an example of how to use the Presentation Reconciler extension point:
+
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.genericeditor.presentationReconcilers&quot;&gt;
+ &lt;presentationReconciler
+ class=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionPresentationReconciler&quot;
+ contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
+ &lt;enabledWhen&gt;
+ &lt;with variable=&quot;editor&quot;&gt;
+ &lt;test property=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionPropertyTester&quot;&gt;
+ &lt;/test&gt;
+ &lt;/with&gt;
+ &lt;/enabledWhen&gt;
+ &lt;/presentationReconciler&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2016 Red Hat Inc. and others
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.genericeditor/schema/reconcilers.exsd b/org.eclipse.ui.genericeditor/schema/reconcilers.exsd
index 5b36bc98d76..0ae5376e2cc 100644
--- a/org.eclipse.ui.genericeditor/schema/reconcilers.exsd
+++ b/org.eclipse.ui.genericeditor/schema/reconcilers.exsd
@@ -1,116 +1,154 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.ui.genericeditor" id="reconcilers" name="Reconcilers"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute reconcilers for controlling the presentation on a file with a given content type.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="reconciler"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="reconciler">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.reconciler.IReconciler&lt;/code&gt;
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.reconciler.IReconciler"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="contentType" type="string" use="required">
- <annotation>
- <documentation>
- The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 1.1
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- Below is an example of how to use the Reconciler extension point:
-
-&lt;pre&gt;
-&lt;extension point=&quot;org.eclipse.ui.genericeditor.reconcilers&quot;&gt;
- &lt;reconciler
- class=&quot;org.eclipse.ui.genericeditor.examples.TPReconciler&quot;
- contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
- &lt;/reconciler&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2017 Red Hat Inc. and others
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.ui.genericeditor" id="reconcilers" name="Reconcilers"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute reconcilers for controlling the presentation on a file with a given content type.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="reconciler"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="reconciler">
+ <complexType>
+ <sequence>
+ <element ref="enabledWhen" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully qualified class name implementing the interface &lt;code&gt;org.eclipse.jface.text.reconciler.IReconciler&lt;/code&gt;
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.reconciler.IReconciler"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="contentType" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="enabledWhen">
+ <annotation>
+ <documentation>
+ A core Expression that controls the enabled of the given reconciler. The viewer, editor, and editor input are registered in the evaluation context as variable:
+
+ * &lt;with variable=&quot;viewer&quot;&gt; : use it if your expression requires the viewer.
+ * &lt;with variable=&quot;editor&quot;&gt; : use it if your expression requires the editor.
+ * &lt;with variable=&quot;editorInput&quot;&gt; : use it if your expression requires the editor input.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="not"/>
+ <element ref="or"/>
+ <element ref="and"/>
+ <element ref="instanceof"/>
+ <element ref="test"/>
+ <element ref="systemTest"/>
+ <element ref="equals"/>
+ <element ref="count"/>
+ <element ref="with"/>
+ <element ref="resolve"/>
+ <element ref="adapt"/>
+ <element ref="iterate"/>
+ <element ref="reference"/>
+ </choice>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ Below is an example of how to use the Reconciler extension point:
+
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.genericeditor.reconcilers&quot;&gt;
+ &lt;reconciler
+ class=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionReconciler&quot;
+ contentType=&quot;org.eclipse.pde.targetFile&quot;&gt;
+ &lt;enabledWhen&gt;
+ &lt;with variable=&quot;editor&quot;&gt;
+ &lt;test property=&quot;org.eclipse.ui.genericeditor.examples.TargetDefinitionPropertyTester&quot;&gt;
+ &lt;/test&gt;
+ &lt;/with&gt;
+ &lt;/enabledWhen&gt;
+ &lt;/reconciler&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2017 Red Hat Inc. and others
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/AutoEditStrategyRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/AutoEditStrategyRegistry.java
index 425415a953b..bdb3c5de0f4 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/AutoEditStrategyRegistry.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/AutoEditStrategyRegistry.java
@@ -26,6 +26,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
/**
* A registry of auto edit strategies provided by extension
@@ -59,17 +60,19 @@ public class AutoEditStrategyRegistry {
*
* @param sourceViewer
* the source viewer we're hooking completion to.
+ * @param editor the text editor
* @param contentTypes
* the content types of the document we're editing.
* @return the list of {@link IAutoEditStrategy} contributed for at least
* one of the content types.
*/
- public List<IAutoEditStrategy> getAutoEditStrategies(ISourceViewer sourceViewer, Set<IContentType> contentTypes) {
+ public List<IAutoEditStrategy> getAutoEditStrategies(ISourceViewer sourceViewer, ITextEditor editor, Set<IContentType> contentTypes) {
if (this.outOfSync) {
sync();
}
return this.extensions.values().stream()
.filter(ext -> contentTypes.contains(ext.targetContentType))
+ .filter(ext -> ext.matches(sourceViewer, editor))
.sorted(new ContentTypeSpecializationComparator<IAutoEditStrategy>())
.map(GenericContentTypeRelatedExtension<IAutoEditStrategy>::createDelegate)
.collect(Collectors.toList());
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java
index 187de272595..dd2a3b87dc6 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java
@@ -34,6 +34,7 @@ import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
/**
* A registry of content assist processors provided by extension <code>org.eclipse.ui.genericeditor.contentAssistProcessors</code>.
@@ -145,15 +146,17 @@ public class ContentAssistProcessorRegistry {
* Get the contributed {@link IContentAssistProcessor}s that are relevant to hook on source viewer according
* to document content types.
* @param sourceViewer the source viewer we're hooking completion to.
+ * @param editor the text editor
* @param contentTypes the content types of the document we're editing.
* @return the list of {@link IContentAssistProcessor} contributed for at least one of the content types.
*/
- public List<IContentAssistProcessor> getContentAssistProcessors(ISourceViewer sourceViewer, Set<IContentType> contentTypes) {
+ public List<IContentAssistProcessor> getContentAssistProcessors(ISourceViewer sourceViewer, ITextEditor editor, Set<IContentType> contentTypes) {
if (this.outOfSync) {
sync();
}
return this.extensions.values().stream()
.filter(ext -> contentTypes.contains(ext.targetContentType))
+ .filter(ext -> ext.matches(sourceViewer, editor))
.sorted(new ContentTypeSpecializationComparator<IContentAssistProcessor>())
.map(GenericContentTypeRelatedExtension<IContentAssistProcessor>::createDelegate)
.collect(Collectors.toList());
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java
index 3b39a9e4078..1d149b3b38f 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java
@@ -99,7 +99,7 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
- List<ITextHover> hovers = GenericEditorPlugin.getDefault().getHoverRegistry().getAvailableHovers(sourceViewer, getContentTypes());
+ List<ITextHover> hovers = GenericEditorPlugin.getDefault().getHoverRegistry().getAvailableHovers(sourceViewer, editor, getContentTypes());
if (hovers == null || hovers.isEmpty()) {
return null;
} else if (hovers.size() == 1) {
@@ -118,7 +118,7 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe
contentAssistant.setAutoActivationDelay(0);
contentAssistant.enableColoredLabels(true);
contentAssistant.enableAutoActivation(true);
- this.processors = registry.getContentAssistProcessors(sourceViewer, getContentTypes());
+ this.processors = registry.getContentAssistProcessors(sourceViewer, editor, getContentTypes());
if (this.processors.isEmpty()) {
this.processors.add(new DefaultContentAssistProcessor());
}
@@ -140,7 +140,7 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconcilerRegistry registry = GenericEditorPlugin.getDefault().getPresentationReconcilerRegistry();
- List<IPresentationReconciler> reconciliers = registry.getPresentationReconcilers(sourceViewer, getContentTypes());
+ List<IPresentationReconciler> reconciliers = registry.getPresentationReconcilers(sourceViewer, editor, getContentTypes());
if (!reconciliers.isEmpty()) {
return reconciliers.get(0);
}
@@ -191,8 +191,8 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
ReconcilerRegistry registry = GenericEditorPlugin.getDefault().getReconcilerRegistry();
- List<IReconciler> reconciliers = registry.getReconcilers(sourceViewer, getContentTypes());
- List<IReconciler> highlightReconciliers = registry.getHighlightReconcilers(sourceViewer, getContentTypes());
+ List<IReconciler> reconciliers = registry.getReconcilers(sourceViewer, editor, getContentTypes());
+ List<IReconciler> highlightReconciliers = registry.getHighlightReconcilers(sourceViewer, editor, getContentTypes());
if(!highlightReconciliers.isEmpty()) {
reconciliers.addAll(highlightReconciliers);
@@ -209,7 +209,7 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe
@Override
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
AutoEditStrategyRegistry registry = GenericEditorPlugin.getDefault().getAutoEditStrategyRegistry();
- List<IAutoEditStrategy> editStrategies = registry.getAutoEditStrategies(sourceViewer, getContentTypes());
+ List<IAutoEditStrategy> editStrategies = registry.getAutoEditStrategies(sourceViewer, editor, getContentTypes());
if (!editStrategies.isEmpty()) {
return editStrategies.toArray(new IAutoEditStrategy[editStrategies.size()]);
}
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java
index 1de66f221be..8dd2e27e348 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java
@@ -10,12 +10,19 @@
*******************************************************************************/
package org.eclipse.ui.internal.genericeditor;
+import org.eclipse.core.expressions.ElementHandler;
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
/**
* This class wraps and proxies an instance of T provided through extensions
@@ -25,15 +32,20 @@ import org.eclipse.core.runtime.content.IContentType;
* @param <T> the actual type to proxy, typically the one defined on the extension point.
*/
public class GenericContentTypeRelatedExtension<T> {
+ private static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
private static final String CONTENT_TYPE_ATTRIBUTE = "contentType"; //$NON-NLS-1$
+ private static final String ENABLED_WHEN_ATTRIBUTE = "enabledWhen"; //$NON-NLS-1$
public final IConfigurationElement extension;
public final IContentType targetContentType;
+ public final Expression enabledWhen;
public GenericContentTypeRelatedExtension(IConfigurationElement element) throws Exception {
this.extension = element;
- this.targetContentType = Platform.getContentTypeManager().getContentType(element.getAttribute(CONTENT_TYPE_ATTRIBUTE));
+ this.targetContentType = Platform.getContentTypeManager()
+ .getContentType(element.getAttribute(CONTENT_TYPE_ATTRIBUTE));
+ this.enabledWhen = buildEnabledWhen(element);
}
@SuppressWarnings("unchecked")
@@ -45,4 +57,56 @@ public class GenericContentTypeRelatedExtension<T> {
}
return null;
}
+
+ /**
+ * Returns the expression {@link Expression} declared in the
+ * <code>enabledWhen</code> element.
+ *
+ * @param configElement the configuration element
+ * @return the expression {@link Expression} declared in the enabledWhen
+ * element.
+ * @throws CoreException when enabledWhen expression is not valid.
+ */
+ private static Expression buildEnabledWhen(IConfigurationElement configElement) throws CoreException {
+ final IConfigurationElement[] children = configElement.getChildren(ENABLED_WHEN_ATTRIBUTE);
+ if (children.length > 0) {
+ IConfigurationElement[] subChildren = children[0].getChildren();
+ if (subChildren.length != 1) {
+ throw new CoreException(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID,
+ "One <enabledWhen> element is accepted. Disabling " //$NON-NLS-1$
+ + configElement.getAttribute(ID_ATTRIBUTE)));
+ }
+ final ElementHandler elementHandler = ElementHandler.getDefault();
+ final ExpressionConverter converter = ExpressionConverter.getDefault();
+ return elementHandler.create(converter, subChildren[0]);
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the given viewer, editor matches the enabledWhen expression
+ * and false otherwise.
+ *
+ * @param viewer the viewer
+ * @param editor the editor
+ * @return true if the given viewer, editor matches the enabledWhen expression
+ * and false otherwise.
+ */
+ public boolean matches(ISourceViewer viewer, ITextEditor editor) {
+ if (enabledWhen == null) {
+ return true;
+ }
+ EvaluationContext context = new EvaluationContext(null, editor);
+ context.setAllowPluginActivation(true);
+ context.addVariable("viewer", viewer); //$NON-NLS-1$
+ context.addVariable("editor", editor); //$NON-NLS-1$
+ context.addVariable("editorInput", editor.getEditorInput()); //$NON-NLS-1$
+ try {
+ return enabledWhen.evaluate(context) == EvaluationResult.TRUE;
+ } catch (CoreException e) {
+ GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID,
+ "Error while 'enabledWhen' evaluation", e)); //$NON-NLS-1$
+ return false;
+ }
+ }
}
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java
index 6826e4ead20..f8568ceee26 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java
@@ -26,6 +26,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
/**
* A registry of presentation reconciliers provided by extension <code>org.eclipse.ui.genericeditor.presentationReconcilers</code>.
@@ -56,15 +57,17 @@ public class PresentationReconcilerRegistry {
* Get the contributed {@link IPresentationReconciliers}s that are relevant to hook on source viewer according
* to document content types.
* @param sourceViewer the source viewer we're hooking completion to.
+ * @param editor the text editor
* @param contentTypes the content types of the document we're editing.
* @return the list of {@link IPresentationReconciler} contributed for at least one of the content types.
*/
- public List<IPresentationReconciler> getPresentationReconcilers(ISourceViewer sourceViewer, Set<IContentType> contentTypes) {
+ public List<IPresentationReconciler> getPresentationReconcilers(ISourceViewer sourceViewer, ITextEditor editor, Set<IContentType> contentTypes) {
if (this.outOfSync) {
sync();
}
return this.extensions.values().stream()
.filter(ext -> contentTypes.contains(ext.targetContentType))
+ .filter(ext -> ext.matches(sourceViewer, editor))
.sorted(new ContentTypeSpecializationComparator<IPresentationReconciler>())
.map(GenericContentTypeRelatedExtension<IPresentationReconciler>::createDelegate)
.collect(Collectors.toList());
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ReconcilerRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ReconcilerRegistry.java
index b31ecadbd17..74e8183d75d 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ReconcilerRegistry.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ReconcilerRegistry.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
/**
* A registry of reconciliers provided by extensions <code>org.eclipse.ui.genericeditor.reconcilers</code>
@@ -59,16 +60,18 @@ public class ReconcilerRegistry {
* Get the contributed {@link IReconciliers}s that are relevant to hook on source viewer according
* to document content types.
* @param sourceViewer the source viewer we're hooking completion to.
+ * @param editor the text editor
* @param contentTypes the content types of the document we're editing.
* @return the list of {@link IReconciler} contributed for at least one of the content types,
* sorted by most generic content type to most specific.
*/
- public List<IReconciler> getReconcilers(ISourceViewer sourceViewer, Set<IContentType> contentTypes) {
+ public List<IReconciler> getReconcilers(ISourceViewer sourceViewer, ITextEditor editor, Set<IContentType> contentTypes) {
if (this.outOfSync) {
sync();
}
List<IReconciler> reconcilers = this.extensions.values().stream()
.filter(ext -> contentTypes.contains(ext.targetContentType))
+ .filter(ext -> ext.matches(sourceViewer, editor))
.sorted(new ContentTypeSpecializationComparator<IReconciler>().reversed())
.map(GenericContentTypeRelatedExtension<IReconciler>::createDelegate)
.collect(Collectors.toList());
@@ -79,16 +82,18 @@ public class ReconcilerRegistry {
* Get the contributed highlight {@link IReconciliers}s that are relevant to hook on source viewer according
* to document content types.
* @param sourceViewer the source viewer we're hooking completion to.
+ * @param editor the text editor
* @param contentTypes the content types of the document we're editing.
* @return the list of highlight {@link IReconciler}s contributed for at least one of the content types,
* sorted by most generic content type to most specific.
*/
- public List<IReconciler> getHighlightReconcilers(ISourceViewer sourceViewer, Set<IContentType> contentTypes) {
+ public List<IReconciler> getHighlightReconcilers(ISourceViewer sourceViewer, ITextEditor editor, Set<IContentType> contentTypes) {
if (this.highlightOutOfSync) {
syncHighlight();
}
List<IReconciler> highlightReconcilers = this.highlightExtensions.values().stream()
.filter(ext -> contentTypes.contains(ext.targetContentType))
+ .filter(ext -> ext.matches(sourceViewer, editor))
.sorted(new ContentTypeSpecializationComparator<IReconciler>().reversed())
.map(GenericContentTypeRelatedExtension<IReconciler>::createDelegate)
.collect(Collectors.toList());
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/TextHoverRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/TextHoverRegistry.java
index f68bbf74deb..72bba197eaa 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/TextHoverRegistry.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/TextHoverRegistry.java
@@ -32,6 +32,7 @@ import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.internal.genericeditor.GenericContentTypeRelatedExtension;
import org.eclipse.ui.internal.genericeditor.GenericEditorPlugin;
+import org.eclipse.ui.texteditor.ITextEditor;
/**
* Text hover registry that manages the detectors
@@ -92,12 +93,13 @@ public final class TextHoverRegistry {
}, EXTENSION_POINT_ID);
}
- public List<ITextHover> getAvailableHovers(ISourceViewer sourceViewer, Set<IContentType> contentTypes) {
+ public List<ITextHover> getAvailableHovers(ISourceViewer sourceViewer, ITextEditor editor, Set<IContentType> contentTypes) {
if (this.outOfSync) {
sync();
}
return this.extensions.stream()
.filter(ext -> contentTypes.contains(ext.targetContentType))
+ .filter(ext -> ext.matches(sourceViewer, editor))
// don't sort in the stream as the initial structure is already sorted by isAfter/isBefore
.map(GenericContentTypeRelatedExtension<ITextHover>::createDelegate)
.collect(Collectors.toList());

Back to the top