Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Bullen2017-09-01 13:27:17 -0400
committerLucas Bullen2017-10-17 09:36:03 -0400
commit3c1fd5a3277074256b6d3f1bf2aa9a6b41f8b094 (patch)
tree4cf5bd5431edb8d814ec6bdc5c9f39980b1f7667 /org.eclipse.ui.genericeditor
parent43cdbb7d723b29c84d152bdb5d2d350d5fe39e40 (diff)
downloadeclipse.platform.text-3c1fd5a3277074256b6d3f1bf2aa9a6b41f8b094.tar.gz
eclipse.platform.text-3c1fd5a3277074256b6d3f1bf2aa9a6b41f8b094.tar.xz
eclipse.platform.text-3c1fd5a3277074256b6d3f1bf2aa9a6b41f8b094.zip
Bug 521031 - [generic editor] How to implement Matching bracketI20171019-2000I20171018-2000I20171017-2000
Example added to .project editor Fix added to CompositeReconciler for dealing with strategy-less reconcilers Change-Id: I0b9597e5b25b4001c8e587b3dcdecb1aa3897cfd Signed-off-by: Lucas Bullen <lbullen@redhat.com>
Diffstat (limited to 'org.eclipse.ui.genericeditor')
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconciler.java18
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconcilerStrategy.java12
2 files changed, 18 insertions, 12 deletions
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconciler.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconciler.java
index eb3f9f07c..31b1362ce 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconciler.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconciler.java
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.ui.internal.genericeditor;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.ITextViewer;
@@ -23,7 +25,7 @@ public class CompositeReconciler implements IReconciler, IReconcilerExtension {
private List<IReconciler> fReconcilers;
public CompositeReconciler(List<IReconciler> reconcilers) {
- fReconcilers = reconcilers;
+ fReconcilers = reconcilers.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
@Override
@@ -61,7 +63,19 @@ public class CompositeReconciler implements IReconciler, IReconcilerExtension {
@Override
public IReconcilingStrategy getReconcilingStrategy(String contentType) {
- return new CompositeReconcilerStrategy(fReconcilers, contentType);
+ List<IReconcilingStrategy> strategies = new ArrayList<>();
+ for (IReconciler iReconciler : fReconcilers) {
+ IReconcilingStrategy strategy = iReconciler.getReconcilingStrategy(contentType);
+ if(strategy != null) {
+ strategies.add(strategy);
+ }
+ }
+
+ if(strategies.size() == 1) {
+ return strategies.get(0);
+ }
+
+ return new CompositeReconcilerStrategy(strategies);
}
}
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconcilerStrategy.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconcilerStrategy.java
index f302460a3..98699fc98 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconcilerStrategy.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeReconcilerStrategy.java
@@ -10,28 +10,20 @@
*******************************************************************************/
package org.eclipse.ui.internal.genericeditor;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
public class CompositeReconcilerStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension{
private List<IReconcilingStrategy> fReconcilingStrategies;
- public CompositeReconcilerStrategy(List<IReconciler> reconcilers, String contentType) {
- this.fReconcilingStrategies = new ArrayList<>();
- for (IReconciler iReconciler : reconcilers) {
- IReconcilingStrategy strategy = iReconciler.getReconcilingStrategy(contentType);
- if(strategy != null) {
- fReconcilingStrategies.add(strategy);
- }
- }
+ public CompositeReconcilerStrategy(List<IReconcilingStrategy> strategies) {
+ this.fReconcilingStrategies = strategies;
}
@Override
public void setProgressMonitor(IProgressMonitor monitor) {

Back to the top