diff options
author | Sarika Sinha | 2014-11-18 15:19:30 +0000 |
---|---|---|
committer | Dani Megert | 2014-11-18 15:19:30 +0000 |
commit | 65c48af2e4c894561c2ccfd8a97bc40c081b14db (patch) | |
tree | 36833ee67bf751aeb6174bdceb5491c48665ab5a /org.eclipse.ui.editors.tests | |
parent | 9bb8cccc90883337123649fca6e37807f2589ff8 (diff) | |
download | eclipse.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.tests')
5 files changed, 198 insertions, 2 deletions
diff --git a/org.eclipse.ui.editors.tests/META-INF/MANIFEST.MF b/org.eclipse.ui.editors.tests/META-INF/MANIFEST.MF index 4a19d59aeb9..7696fa406ff 100644 --- a/org.eclipse.ui.editors.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.editors.tests/META-INF/MANIFEST.MF @@ -1,8 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name -Bundle-SymbolicName: org.eclipse.ui.editors.tests +Bundle-SymbolicName: org.eclipse.ui.editors.tests;singleton:=true Bundle-Version: 3.8.300.qualifier +Bundle-Activator: org.eclipse.ui.editors.tests.EditorTestPlugin Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin Export-Package: org.eclipse.ui.editors.tests @@ -20,3 +21,4 @@ Require-Bundle: org.eclipse.text.tests;bundle-version="[3.5.0,4.0.0)" Bundle-RequiredExecutionEnvironment: J2SE-1.4 Eclipse-BundleShape: dir +Bundle-ActivationPolicy: lazy diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorTestPlugin.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorTestPlugin.java new file mode 100644 index 00000000000..3550478f31b --- /dev/null +++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorTestPlugin.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.editors.tests; + +import java.io.BufferedInputStream; +import java.lang.reflect.Field; + +import org.osgi.framework.BundleContext; + +import org.eclipse.core.runtime.ContributorFactorySimple; +import org.eclipse.core.runtime.IContributor; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Plugin; + +public class EditorTestPlugin extends Plugin { + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) + */ + public static String PLUGIN_ID= "org.eclipse.ui.editors.tests"; + + // The shared instance + private static EditorTestPlugin fgPlugin; + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static EditorTestPlugin getDefault() { + return fgPlugin; + } + + public void start(BundleContext context) throws Exception { + super.start(context); + fgPlugin= this; + IExtensionRegistry registry= Platform.getExtensionRegistry(); + IContributor pointContributor= ContributorFactorySimple.createContributor(Long.toString(fgPlugin.getBundle().getBundleId())); + + try{ + BufferedInputStream bis= new BufferedInputStream(getClass().getResourceAsStream("plugin.xml")); + + Field field= + org.eclipse.core.internal.registry.ExtensionRegistry.class + .getDeclaredField("masterToken"); + field.setAccessible(true); + Object masterToken= field.get(registry); + registry.addContribution(bis, pointContributor, true, null, null, masterToken); + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + + public EditorTestPlugin() { + super(); + } + +} diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java index d71901468e8..2c4a13a8733 100644 --- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java +++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.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 @@ -27,6 +27,7 @@ public class EditorsTestSuite extends TestSuite { suite.addTest(EncodingChangeTests.suite()); suite.addTest(GotoLineTest.suite()); suite.addTest(SegmentedModeTest.suite()); + suite.addTest(MarkerAnnotationOrderTest.suite()); //$JUnit-END$ return suite; } diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java new file mode 100644 index 00000000000..84d01153560 --- /dev/null +++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.editors.tests; + +import java.util.ArrayList; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.osgi.framework.Bundle; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; + +import org.eclipse.core.resources.IMarker; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.Position; + +import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; + +import org.eclipse.ui.editors.text.EditorsUI; + +public class MarkerAnnotationOrderTest extends TestCase { + + public static Test suite() { + return new TestSuite(MarkerAnnotationOrderTest.class); + } + + public void testDirectDependency() { + final ArrayList list= new ArrayList(2); + Bundle bundle= Platform.getBundle(EditorsUI.PLUGIN_ID); + ILog log= Platform.getLog(bundle); + log.addLogListener(new ILogListener() { + + public void logging(IStatus status, String plugin) { + list.add(status); + } + }); + + TestMarkerAnnotationModel t1= new TestMarkerAnnotationModel(); + Position position= new Position(0); + position.delete(); + IDocument d= null; + try { + t1.updateMarker(d, null, position); + } catch (CoreException e) { + fail("update marker failed to execute"); + EditorTestPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, EditorTestPlugin.PLUGIN_ID, e.getMessage())); + } + + assertEquals("Wrong number of messages", 2, list.size()); + assertEquals( + "Wrong Message for first status", + "Marker Updater org.eclipse.ui.texteditor.BasicMarkerUpdaterTest2 and org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1 depend on each other, org.eclipse.ui.texteditor.BasicMarkerUpdaterTest2 will run before org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1", + ((Status)list.get(0)).getMessage()); + assertEquals( + "Wrong Message for second status", + "Marker Updater org.eclipse.ui.texteditor.BasicMarkerUpdaterTest4 and org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1 depend on each other, org.eclipse.ui.texteditor.BasicMarkerUpdaterTest4 will run before org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1", + ((Status)list.get(1)).getMessage()); + + } + + public class TestMarkerAnnotationModel extends AbstractMarkerAnnotationModel { + protected IMarker[] retrieveMarkers() throws CoreException { + return null; + } + + protected void deleteMarkers(IMarker[] markers) throws CoreException { + } + + protected void listenToMarkerChanges(boolean listen) { + } + + protected boolean isAcceptable(IMarker marker) { + return false; + } + + } + +} diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/plugin.xml b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/plugin.xml new file mode 100644 index 00000000000..024b89a819b --- /dev/null +++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/plugin.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin> + <extension + point="org.eclipse.ui.editors.markerUpdaters"> + <updater + class="org.eclipse.ui.texteditor.BasicMarkerUpdater" + id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1" + markerType="org.eclipse.ui.editors.test.DummyMarkerType"> + <required-updater id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest2"/> + </updater> + <updater + class="org.eclipse.ui.texteditor.BasicMarkerUpdater" + id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest2" + markerType="org.eclipse.ui.editors.test.DummyMarkerType"> + <required-updater id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1"/> + <required-updater id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest3"/> + </updater> + <updater + class="org.eclipse.ui.texteditor.BasicMarkerUpdater" + id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest3" + markerType="org.eclipse.ui.editors.test.DummyMarkerType"> + <required-updater id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest4"/> + </updater> + <updater + class="org.eclipse.ui.texteditor.BasicMarkerUpdater" + id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest4" + markerType="org.eclipse.ui.editors.test.DummyMarkerType"> + <required-updater id="org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1"/> + </updater> + </extension> +</plugin>
\ No newline at end of file |