Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2014-11-18 15:19:30 +0000
committerDani Megert2014-11-18 15:19:30 +0000
commit65c48af2e4c894561c2ccfd8a97bc40c081b14db (patch)
tree36833ee67bf751aeb6174bdceb5491c48665ab5a /org.eclipse.ui.editors
parent9bb8cccc90883337123649fca6e37807f2589ff8 (diff)
downloadeclipse.platform.text-65c48af2e4c894561c2ccfd8a97bc40c081b14db.tar.gz
eclipse.platform.text-65c48af2e4c894561c2ccfd8a97bc40c081b14db.tar.xz
eclipse.platform.text-65c48af2e4c894561c2ccfd8a97bc40c081b14db.zip
Fixed bug 440952: Basic Marker Updater should be executed before other contributed markers
Signed-off-by: Sarika Sinha <sarika.sinha@in.ibm.com>
Diffstat (limited to 'org.eclipse.ui.editors')
-rw-r--r--org.eclipse.ui.editors/schema/markerUpdaters.exsd43
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java69
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties4
4 files changed, 101 insertions, 19 deletions
diff --git a/org.eclipse.ui.editors/schema/markerUpdaters.exsd b/org.eclipse.ui.editors/schema/markerUpdaters.exsd
index 2ccb5aac2..d27f3b7eb 100644
--- a/org.eclipse.ui.editors/schema/markerUpdaters.exsd
+++ b/org.eclipse.ui.editors/schema/markerUpdaters.exsd
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.editors">
+<schema targetNamespace="org.eclipse.ui.editors" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.ui.editors" id="markerUpdaters" name="Marker Updaters"/>
@@ -11,6 +11,11 @@
</annotation>
<element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
<complexType>
<sequence>
<element ref="updater" minOccurs="1" maxOccurs="unbounded"/>
@@ -44,6 +49,9 @@
<element name="updater">
<complexType>
+ <sequence>
+ <element ref="required-updater" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
@@ -74,6 +82,21 @@
</complexType>
</element>
+ <element name="required-updater">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The fully-qualified id of a marker updater which is required for this updater.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.ui.editors.markerUpdaters/updater/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appInfo>
<meta.section type="since"/>
@@ -94,12 +117,13 @@
id=&quot;org.eclipse.jdt.ui.markerUpdaters.JavaSearchMarkerUpdater&quot;
class=&quot;org.eclipse.jdt.internal.ui.search.JavaSearchMarkerUpdater&quot;
markerType=&quot;org.eclipse.search.searchmarker&quot;&gt;
- &lt;/updater&gt;
+ &lt;required-updater id=&quot;org.eclipse.ui.texteditor.BasicMarkerUpdater&quot;/&gt;
+ &lt;/updater&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;p&gt;
This example registers &lt;samp&gt;org.eclipse.jdt.internal.ui.search.JavaSearchMarkerUpdater&lt;/samp&gt; as a marker updater for all markers of the
-type &lt;samp&gt;org.eclipse.search.searchmarker&lt;/samp&gt; including all its derived types.
+type &lt;samp&gt;org.eclipse.search.searchmarker&lt;/samp&gt; including all its derived types. This marker updater requires BasicMarkerUpdater to execute first.
&lt;/p&gt;
&lt;pre&gt;
&lt;extension point= &quot;org.eclipse.ui.editors.markerUpdaters&quot;&gt;
@@ -110,7 +134,8 @@ type &lt;samp&gt;org.eclipse.search.searchmarker&lt;/samp&gt; including all its
&lt;/extension&gt;
&lt;/pre&gt;
&lt;p&gt;
-This example registers &lt;samp&gt;org.eclipse.ui.texteditor.BasicMarkerUpdater&lt;/samp&gt; as a marker updater independent from the type of the marker.
+This example registers &lt;samp&gt;org.eclipse.ui.texteditor.BasicMarkerUpdater&lt;/samp&gt; as a marker updater independent from the type of the marker. This marker updater does not require any other updater
+to run first.
&lt;/p&gt;
</documentation>
</annotation>
@@ -124,21 +149,13 @@ This example registers &lt;samp&gt;org.eclipse.ui.texteditor.BasicMarkerUpdater&
</documentation>
</annotation>
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
- Copyright (c) 2001, 2008 IBM Corporation and others.&lt;br&gt;
+ Copyright (c) 2001, 2014 IBM Corporation and others.&lt;br&gt;
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>
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
index 0d36866d2..59479cf23 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation 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
@@ -11,7 +11,9 @@
package org.eclipse.ui.texteditor;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import org.osgi.framework.Bundle;
@@ -38,6 +40,8 @@ import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.IAnnotationMap;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+import org.eclipse.ui.internal.editors.text.NLSUtility;
import org.eclipse.ui.editors.text.EditorsUI;
@@ -72,6 +76,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
/** List of registered but not yet instantiated marker updaters */
private List fMarkerUpdaterSpecifications= null;
+ private static final String ID= "id"; //$NON-NLS-1$
/**
* Retrieves all markers from this model.
@@ -256,15 +261,71 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
private void installMarkerUpdaters() {
// initialize lists - indicates that the initialization happened
- fMarkerUpdaterSpecifications= new ArrayList(2);
fInstantiatedMarkerUpdaters= new ArrayList(2);
+ HashMap markerUpdaterOrderMap = new HashMap(2);
+ LinkedList markerUpdaterSpecificationsLinkedList= new LinkedList();
// populate list
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "markerUpdaters"); //$NON-NLS-1$
if (extensionPoint != null) {
IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++)
- fMarkerUpdaterSpecifications.add(elements[i]);
+ for (int i= 0; i < elements.length; i++) {
+ markerUpdaterSpecificationsLinkedList.add(elements[i]);
+ markerUpdaterOrderMap.put(elements[i].getAttribute(ID), new Integer(i));
+ }
+ //start sorting based on required-updater definition
+ HashMap markerUpdaterRequiredByOrderMap= new HashMap(2);
+ for (int i= 0; i < elements.length; i++) {
+ // Required marker should execute before other updater markers
+ IConfigurationElement[] requiredUpdaters= elements[i].getChildren("required-updater"); //$NON-NLS-1$
+ if (requiredUpdaters.length > 0) {
+ //ArrayList requiredUpdaters= new ArrayList(2);
+ for (int j= 0; j < requiredUpdaters.length; j++) { // If required updaters have been defined
+ String requiredID= requiredUpdaters[j].getAttribute(ID);
+ // If required ID is not a valid id
+ if (requiredID == null || (markerUpdaterOrderMap.get(requiredID) == null)) { // ID missing or invalid - log the message and move to next contribution
+ String msg= NLSUtility.format(TextEditorMessages.AbstractMarkerAnnotationModel_updaterInvalidDefinition, new Object[] { elements[i].getAttribute(ID), requiredID });
+ EditorsPlugin.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, msg));
+ continue;
+ }
+ // Updating requiredByUpdaters to identify and log error for cyclic Dependency like A required B, B required C, C required D and D required A
+ // or A requires B and B requires A
+
+ ArrayList requiredByUpdaters;
+ if (markerUpdaterRequiredByOrderMap.get(requiredID) == null) {
+ requiredByUpdaters= new ArrayList(2);
+ }
+ else {
+ requiredByUpdaters= (ArrayList)markerUpdaterRequiredByOrderMap.get(requiredID);
+ }
+ // Build up extended required id list to identify Case 2
+ if (markerUpdaterRequiredByOrderMap.get(elements[i].getAttribute(ID)) != null) {
+ ArrayList requiredByList= (ArrayList)markerUpdaterRequiredByOrderMap.get(elements[i].getAttribute(ID));
+ requiredByUpdaters.addAll(requiredByList);
+ }
+ if (requiredByUpdaters.contains(requiredID)) { //log error if marker ID is in the required list of required ID
+ String msg= NLSUtility.format(TextEditorMessages.AbstractMarkerAnnotationModel_markerUpdaterCyclicDefinition, new Object[] { elements[i].getAttribute(ID), requiredID });
+ EditorsPlugin.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, msg));
+ continue;
+ }
+ requiredByUpdaters.add(elements[i].getAttribute(ID));
+ markerUpdaterRequiredByOrderMap.put(requiredID, requiredByUpdaters);
+
+ Integer requiredLocation= (Integer)markerUpdaterOrderMap.get(requiredID);
+ if (requiredLocation.intValue() > ((Integer)markerUpdaterOrderMap.get(elements[i].getAttribute(ID))).intValue()) { // If required marker is not ordered before
+ int newLocation= (((Integer)markerUpdaterOrderMap.get(elements[i].getAttribute(ID))).intValue() == 0) ? 0 : (((Integer)markerUpdaterOrderMap.get(elements[i]
+ .getAttribute(ID))).intValue() - 1);
+ Object requiredMarker= markerUpdaterSpecificationsLinkedList.remove(requiredLocation.intValue());
+ markerUpdaterSpecificationsLinkedList.add(newLocation, requiredMarker); // Put the required location before the marker
+ markerUpdaterOrderMap.put(requiredID, new Integer(newLocation));
+ markerUpdaterOrderMap.put(elements[i].getAttribute(ID), new Integer(newLocation + 1));
+ }
+ }
+ }
+ }
+ fMarkerUpdaterSpecifications= new ArrayList(markerUpdaterSpecificationsLinkedList);
+ //end sorting
+
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.java
index c0e32be9c..d4433bdfc 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation 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
@@ -49,6 +49,8 @@ final class TextEditorMessages extends NLS {
public static String AbstractMarkerAnnotationModel_connected;
public static String AbstractMarkerAnnotationModel_createMarkerUpdater;
public static String AbstractMarkerAnnotationModel_removeAnnotations;
+ public static String AbstractMarkerAnnotationModel_updaterInvalidDefinition;
+ public static String AbstractMarkerAnnotationModel_markerUpdaterCyclicDefinition;
public static String DocumentProviderRegistry_error_extension_point_not_found;
public static String ChangeEncodingAction_message_noEncodingSupport;
public static String ChangeEncodingAction_button_apply_label;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties
index 3cdd93689..ad9bb8382 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2010 IBM Corporation and others.
+# Copyright (c) 2000, 2014 IBM Corporation 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
@@ -18,6 +18,8 @@ MarkerRulerAction_getMarker=MarkerRulerAction.getMarker
AbstractMarkerAnnotationModel_connected=AbstractMarkerAnnotationModel.connected
AbstractMarkerAnnotationModel_createMarkerUpdater=AbstractMarkerAnnotationModel.createMarkerUpdater
AbstractMarkerAnnotationModel_removeAnnotations=AbstractMarkerAnnotationModel.removeAnnotations
+AbstractMarkerAnnotationModel_updaterInvalidDefinition=Marker Updater ''{0}'' has invalid entry for required updater ''{1}''
+AbstractMarkerAnnotationModel_markerUpdaterCyclicDefinition=Marker Updater ''{0}'' and ''{1}'' depend on each other, ''{0}'' will run before ''{1}''
DocumentProviderRegistry_error_extension_point_not_found=Extension point: {0}.documentProviders not found
ChangeEncodingAction_message_noEncodingSupport=No encoding support installed

Back to the top