Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2017-08-08 10:33:41 -0400
committerMickael Istria2017-08-08 19:00:38 -0400
commit1ba9040176a1bdaf3c47df85728ae4ab5b0d2a93 (patch)
treef15d6c6e94d1f07e3c163a9e8c94321f6ad75ce8 /org.eclipse.ui.genericeditor.tests
parent896e9624a30afb9e3f75daa648707b808d26ae0b (diff)
downloadeclipse.platform.text-1ba9040176a1bdaf3c47df85728ae4ab5b0d2a93.tar.gz
eclipse.platform.text-1ba9040176a1bdaf3c47df85728ae4ab5b0d2a93.tar.xz
eclipse.platform.text-1ba9040176a1bdaf3c47df85728ae4ab5b0d2a93.zip
Bug 520685 - [Generic Editor] Sort ext. by most specialized content-typeI20170809-2000
Factorize extensions and registry polling (can be continued). This allows most registries to return first the extension that applies to the most specialized content-types. Change-Id: Icfd5d0c2e72cd579e9fe8c034420d88c628f39a6 Signed-off-by: Mickael Istria <mistria@redhat.com>
Diffstat (limited to 'org.eclipse.ui.genericeditor.tests')
-rw-r--r--org.eclipse.ui.genericeditor.tests/plugin.xml29
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java3
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java2
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java2
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerBlue.java38
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerGreen.java42
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerRed.java (renamed from org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconciler.java)4
7 files changed, 108 insertions, 12 deletions
diff --git a/org.eclipse.ui.genericeditor.tests/plugin.xml b/org.eclipse.ui.genericeditor.tests/plugin.xml
index a6b412453..4d02c03df 100644
--- a/org.eclipse.ui.genericeditor.tests/plugin.xml
+++ b/org.eclipse.ui.genericeditor.tests/plugin.xml
@@ -36,14 +36,22 @@
class="org.eclipse.ui.genericeditor.tests.contributions.TheReconciler"
contentType="org.eclipse.ui.genericeditor.tests.content-type">
</reconciler>
- </extension>
- <extension
+ </extension>
+ <extension
point="org.eclipse.ui.genericeditor.presentationReconcilers">
<presentationReconciler
- class="org.eclipse.ui.genericeditor.tests.contributions.ThePresentationReconciler"
- contentType="org.eclipse.ui.genericeditor.tests.content-type">
+ class="org.eclipse.ui.genericeditor.tests.contributions.ThePresentationReconcilerBlue"
+ contentType="org.eclipse.core.runtime.text">
+ </presentationReconciler>
+ <presentationReconciler
+ class="org.eclipse.ui.genericeditor.tests.contributions.ThePresentationReconcilerRed"
+ contentType="org.eclipse.ui.genericeditor.tests.specialized-content-type">
+ </presentationReconciler>
+ <presentationReconciler
+ class="org.eclipse.ui.genericeditor.tests.contributions.ThePresentationReconcilerGreen"
+ contentType="org.eclipse.ui.genericeditor.tests.content-type">
</presentationReconciler>
- </extension>
+ </extension>
<extension
point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
@@ -60,6 +68,13 @@
name="Generic Editor Test content-type"
priority="normal">
</content-type>
+ <content-type
+ base-type="org.eclipse.ui.genericeditor.tests.content-type"
+ file-names="foo.txt"
+ id="org.eclipse.ui.genericeditor.tests.specialized-content-type"
+ name="Specialized Generic Editor content-type"
+ priority="normal">
+ </content-type>
</extension>
<extension
point="org.eclipse.ui.genericeditor.autoEditStrategies">
@@ -69,11 +84,11 @@
</autoEditStrategy>
<autoEditStrategy
class="org.eclipse.ui.genericeditor.tests.contributions.TheAutoEditStrategySecond"
- contentType="org.eclipse.core.runtime.text">
+ contentType="org.eclipse.ui.genericeditor.tests.content-type">
</autoEditStrategy>
<autoEditStrategy
class="org.eclipse.ui.genericeditor.tests.contributions.TheAutoEditStrategyThird"
- contentType="org.eclipse.core.runtime.text">
+ contentType="org.eclipse.ui.genericeditor.tests.specialized-content-type">
</autoEditStrategy>
</extension>
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java
index 8a30f57a7..1aa3a3e51 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java
@@ -25,7 +25,8 @@ public class AutoEditTest extends AbstratGenericEditorTest {
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
StyledText control= (StyledText) editor.getAdapter(Control.class);
control.setText("");
- Assert.assertEquals("AutoAddedFirst! AutoAddedSecond! AutoAddedThird!", document.get());
+ // order of auto-edits from most specialized to least specialized
+ Assert.assertEquals("AutoAddedThird!AutoAddedSecond!AutoAddedFirst!", document.get());
}
}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java
index 37e2587d8..92c0ec64b 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java
@@ -18,7 +18,7 @@ public class TheAutoEditStrategySecond implements IAutoEditStrategy {
@Override
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- command.text = command.text + " AutoAddedSecond!";
+ command.text = command.text + "AutoAddedSecond!";
}
}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java
index c7882aaf4..5c4ef8c8d 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java
@@ -18,7 +18,7 @@ public class TheAutoEditStrategyThird implements IAutoEditStrategy {
@Override
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- command.text = command.text + " AutoAddedThird!";
+ command.text = command.text + "AutoAddedThird!";
}
}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerBlue.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerBlue.java
new file mode 100644
index 000000000..44ce5c58b
--- /dev/null
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerBlue.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sopot Cela (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.ui.genericeditor.tests.contributions;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+
+public class ThePresentationReconcilerBlue extends PresentationReconciler {
+
+ public ThePresentationReconcilerBlue() {
+ RuleBasedScanner scanner= new RuleBasedScanner();
+ IRule[] rules = new IRule[1];
+ rules[0]= new SingleLineRule("'", "'", new Token(new TextAttribute(new Color(Display.getCurrent(), new RGB(0, 0, 255))))); //$NON-NLS-1$ //$NON-NLS-2$
+ scanner.setRules(rules);
+ DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
+ this.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ this.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ }
+
+}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerGreen.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerGreen.java
new file mode 100644
index 000000000..2c6d8c41b
--- /dev/null
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerGreen.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2016-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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sopot Cela (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.ui.genericeditor.tests.contributions;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+
+/**
+ * This presentation reconciler is associated to a more "basic" content-type so it
+ * shouldn't be used.
+ */
+public class ThePresentationReconcilerGreen extends PresentationReconciler {
+
+ public ThePresentationReconcilerGreen() {
+ RuleBasedScanner scanner= new RuleBasedScanner();
+ IRule[] rules = new IRule[1];
+ rules[0]= new SingleLineRule("'", "'", new Token(new TextAttribute(new Color(Display.getCurrent(), new RGB(0, 255, 0))))); //$NON-NLS-1$ //$NON-NLS-2$
+ scanner.setRules(rules);
+ DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
+ this.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ this.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ }
+
+}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconciler.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerRed.java
index c2ee68a74..abfd5cb0e 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconciler.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconcilerRed.java
@@ -23,9 +23,9 @@ import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
-public class ThePresentationReconciler extends PresentationReconciler {
+public class ThePresentationReconcilerRed extends PresentationReconciler {
- public ThePresentationReconciler() {
+ public ThePresentationReconcilerRed() {
RuleBasedScanner scanner= new RuleBasedScanner();
IRule[] rules = new IRule[1];
rules[0]= new SingleLineRule("'", "'", new Token(new TextAttribute(new Color(Display.getCurrent(), new RGB(255, 0, 0))))); //$NON-NLS-1$ //$NON-NLS-2$

Back to the top