aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-03-26 12:22:13 (EDT)
committersefftinge2009-03-26 12:22:13 (EDT)
commit9629fd3c0046fa246b5d36326d2a094d12a22a18 (patch)
tree26c142c0b5e2c8305c10ceba01fdfcfad377aac3
parent6af41f299283432ec77f6904b6a4bd3f052311e7 (diff)
downloadorg.eclipse.xtext-9629fd3c0046fa246b5d36326d2a094d12a22a18.zip
org.eclipse.xtext-9629fd3c0046fa246b5d36326d2a094d12a22a18.tar.gz
org.eclipse.xtext-9629fd3c0046fa246b5d36326d2a094d12a22a18.tar.bz2
Replace some constructor calls with injection, to make the editor more configurable
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/service/DefaultUIModule.java12
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/DefaultDamagerRepairerAdapter.java36
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/IDamagerRepairer.java22
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java7
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewerConfiguration.java28
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/reconciler/XtextReconciler.java3
6 files changed, 91 insertions, 17 deletions
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/service/DefaultUIModule.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/service/DefaultUIModule.java
index d052274..9bdf27a 100644
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/service/DefaultUIModule.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/service/DefaultUIModule.java
@@ -9,6 +9,7 @@ package org.eclipse.xtext.ui.common.service;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.rules.ITokenScanner;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
@@ -24,6 +25,9 @@ import org.eclipse.xtext.ui.common.editor.syntaxcoloring.antlr.NullTokenColorer;
import org.eclipse.xtext.ui.core.DefaultLabelProvider;
import org.eclipse.xtext.ui.core.DefaultLocationInFileProvider;
import org.eclipse.xtext.ui.core.ILocationInFileProvider;
+import org.eclipse.xtext.ui.core.editor.IDamagerRepairer;
+import org.eclipse.xtext.ui.core.editor.XtextDamagerRepairer;
+import org.eclipse.xtext.ui.core.editor.reconciler.XtextReconciler;
/**
* @author Heiko Behrens - Initial contribution and API
@@ -70,4 +74,12 @@ public abstract class DefaultUIModule extends AbstractGenericModule {
return DefaultHyperlinkDetector.class;
}
+ public Class<? extends IReconciler> bindIReconciler() {
+ return XtextReconciler.class;
+ }
+
+ public Class<? extends IDamagerRepairer> bindIDamagerRepairer() {
+ return XtextDamagerRepairer.class;
+ }
+
}
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/DefaultDamagerRepairerAdapter.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/DefaultDamagerRepairerAdapter.java
new file mode 100644
index 0000000..afd5761
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/DefaultDamagerRepairerAdapter.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009 itemis AG (http://www.itemis.eu) 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
+ *******************************************************************************/
+package org.eclipse.xtext.ui.core;
+
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.xtext.ui.core.editor.IDamagerRepairer;
+
+import com.google.inject.Inject;
+
+/**
+ * @author Sebastian Zarnekow - Initial contribution and API
+ */
+public class DefaultDamagerRepairerAdapter extends DefaultDamagerRepairer implements IDamagerRepairer {
+
+ @Inject
+ public DefaultDamagerRepairerAdapter(ITokenScanner scanner) {
+ super(scanner);
+ }
+
+ public final IPresentationDamager getDamager() {
+ return this;
+ }
+
+ public final IPresentationRepairer getRepairer() {
+ return this;
+ }
+
+}
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/IDamagerRepairer.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/IDamagerRepairer.java
new file mode 100644
index 0000000..f2d853f
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/IDamagerRepairer.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2009 itemis AG (http://www.itemis.eu) 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
+ *******************************************************************************/
+package org.eclipse.xtext.ui.core.editor;
+
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+
+/**
+ * @author Sebastian Zarnekow - Initial contribution and API
+ */
+public interface IDamagerRepairer {
+
+ IPresentationDamager getDamager();
+
+ IPresentationRepairer getRepairer();
+
+}
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java
index a698093..3270c0e 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java
@@ -12,21 +12,24 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.ITokenScanner;
import org.eclipse.xtext.parsetree.AbstractNode;
import org.eclipse.xtext.parsetree.CompositeNode;
import org.eclipse.xtext.parsetree.LeafNode;
import org.eclipse.xtext.parsetree.Range;
import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.ui.core.DefaultDamagerRepairerAdapter;
import org.eclipse.xtext.ui.core.editor.model.UnitOfWork;
import org.eclipse.xtext.ui.core.editor.model.XtextDocument;
+import com.google.inject.Inject;
+
/**
* @author Sebastian Zarnekow - Initial contribution and API
*/
-public class XtextDamagerRepairer extends DefaultDamagerRepairer {
+public class XtextDamagerRepairer extends DefaultDamagerRepairerAdapter {
+ @Inject
public XtextDamagerRepairer(ITokenScanner scanner) {
super(scanner);
}
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewerConfiguration.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewerConfiguration.java
index bce123f..77f9d99 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewerConfiguration.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewerConfiguration.java
@@ -14,25 +14,25 @@ import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
-import org.eclipse.jface.text.rules.ITokenScanner;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
-import org.eclipse.xtext.ui.core.editor.reconciler.XtextDocumentReconcileStrategy;
-import org.eclipse.xtext.ui.core.editor.reconciler.XtextReconciler;
import com.google.inject.Inject;
+import com.google.inject.Provider;
public class XtextSourceViewerConfiguration extends TextSourceViewerConfiguration {
@Inject(optional = true)
private IContentAssistProcessor contentAssistProcessor;
- @Inject(optional = true)
- private ITokenScanner tokenScanner;
-
@Inject
private IHyperlinkDetector detector;
+
+ @Inject
+ private Provider<IReconciler> reconcilerProvider;
+
+ @Inject(optional = true)
+ private Provider<IDamagerRepairer> damagerRepairerProvider;
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
@@ -46,19 +46,17 @@ public class XtextSourceViewerConfiguration extends TextSourceViewerConfiguratio
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
- XtextDocumentReconcileStrategy strategy = new XtextDocumentReconcileStrategy();
- XtextReconciler xtextReconciler = new XtextReconciler(strategy);
- xtextReconciler.setDelay(500);
- return xtextReconciler;
+ IReconciler reconciler = reconcilerProvider.get();
+ return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- if (tokenScanner != null) {
+ if (damagerRepairerProvider != null) {
PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);
- DefaultDamagerRepairer defDR = new XtextDamagerRepairer(tokenScanner);
- reconciler.setRepairer(defDR, IDocument.DEFAULT_CONTENT_TYPE);
- reconciler.setDamager(defDR, IDocument.DEFAULT_CONTENT_TYPE);
+ IDamagerRepairer defDR = damagerRepairerProvider.get();
+ reconciler.setRepairer(defDR.getRepairer(), IDocument.DEFAULT_CONTENT_TYPE);
+ reconciler.setDamager(defDR.getDamager(), IDocument.DEFAULT_CONTENT_TYPE);
return reconciler;
}
return super.getPresentationReconciler(sourceViewer);
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/reconciler/XtextReconciler.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/reconciler/XtextReconciler.java
index 4e4bf92..35ca154 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/reconciler/XtextReconciler.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/reconciler/XtextReconciler.java
@@ -25,6 +25,8 @@ import org.eclipse.xtext.ui.core.editor.model.IXtextDocumentContentObserver;
import org.eclipse.xtext.ui.core.editor.model.UnitOfWork;
import org.eclipse.xtext.ui.core.editor.model.XtextDocumentUtil;
+import com.google.inject.Inject;
+
/**
* Standard JFace Reconcilers, e.g. the MonoReconciler, convert an replace event
* into a delete and an insert DirtyRegion. This leads to significant overhead,
@@ -87,6 +89,7 @@ public class XtextReconciler extends Job implements IReconciler {
}
}
+ @Inject
public XtextReconciler(XtextDocumentReconcileStrategy strategy) {
super("XtextReconcilerJob");
setPriority(Job.SHORT);