aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-24 09:43:43 (EDT)
committersefftinge2009-04-24 09:43:43 (EDT)
commitbde6ddd2f5ab2c3ecfb2b3ca0d2a9d8006899cc0 (patch)
treeadad8887c795273bce265d3a2f5676ddca10071f
parentc4b3de3ea2178decde8472d29622f23f2316c1c2 (diff)
downloadorg.eclipse.xtext-bde6ddd2f5ab2c3ecfb2b3ca0d2a9d8006899cc0.zip
org.eclipse.xtext-bde6ddd2f5ab2c3ecfb2b3ca0d2a9d8006899cc0.tar.gz
org.eclipse.xtext-bde6ddd2f5ab2c3ecfb2b3ca0d2a9d8006899cc0.tar.bz2
Refactoring: Move TerminalProposalProvider to org.eclipse.xtext.ui.common (https://bugs.eclipse.org/bugs/show_bug.cgi?id=265168)
-rw-r--r--devtools/org.eclipse.xtext.reference.ui/META-INF/MANIFEST.MF1
-rw-r--r--examples/org.eclipse.xtext.example.domainmodel.ui/META-INF/MANIFEST.MF1
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl.ui/META-INF/MANIFEST.MF1
-rw-r--r--examples/org.eclipse.xtext.example.fowlerdsl.ui/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.xtext.ui.common/.classpath1
-rw-r--r--plugins/org.eclipse.xtext.ui.common/META-INF/MANIFEST.MF55
-rw-r--r--plugins/org.eclipse.xtext.ui.common/build.properties3
-rw-r--r--plugins/org.eclipse.xtext.ui.common/plugin.xml_gen6
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsProposalProvider.java75
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsUiModule.java20
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/TerminalsExecutableExtensionFactory.java45
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/internal/TerminalsActivator.java51
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsProposalProvider.java137
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsUiModule.java17
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/META-INF/MANIFEST.MF4
-rw-r--r--tests/org.eclipse.xtext.ui.integration.tests/META-INF/MANIFEST.MF1
16 files changed, 384 insertions, 35 deletions
diff --git a/devtools/org.eclipse.xtext.reference.ui/META-INF/MANIFEST.MF b/devtools/org.eclipse.xtext.reference.ui/META-INF/MANIFEST.MF
index 2168327..dd69bb3f 100644
--- a/devtools/org.eclipse.xtext.reference.ui/META-INF/MANIFEST.MF
+++ b/devtools/org.eclipse.xtext.reference.ui/META-INF/MANIFEST.MF
@@ -6,7 +6,6 @@ Bundle-Version: 0.7.0.qualifier
Require-Bundle: org.eclipse.xtext.reference,
org.eclipse.xtext.ui.core,
org.eclipse.xtext.ui.common,
- org.eclipse.xtext.xtext.ui,
org.eclipse.xtext.xtend;bundle-version="0.7.0";resolution:=optional,
org.eclipse.ui.editors,
org.eclipse.ui
diff --git a/examples/org.eclipse.xtext.example.domainmodel.ui/META-INF/MANIFEST.MF b/examples/org.eclipse.xtext.example.domainmodel.ui/META-INF/MANIFEST.MF
index 1cb3950..200c6b9 100644
--- a/examples/org.eclipse.xtext.example.domainmodel.ui/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.xtext.example.domainmodel.ui/META-INF/MANIFEST.MF
@@ -9,7 +9,6 @@ Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtext.example.domainmodel,
org.eclipse.xtext.ui.core,
org.eclipse.xtext.ui.common,
- org.eclipse.xtext.xtext.ui,
org.eclipse.xtext.log4j;bundle-version="1.2.15",
org.eclipse.ui.editors,
org.eclipse.xtext.xtend;bundle-version="0.7.0";resolution:=optional,
diff --git a/examples/org.eclipse.xtext.example.ecoredsl.ui/META-INF/MANIFEST.MF b/examples/org.eclipse.xtext.example.ecoredsl.ui/META-INF/MANIFEST.MF
index 9ead954..5105bfe 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl.ui/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.xtext.example.ecoredsl.ui/META-INF/MANIFEST.MF
@@ -5,7 +5,6 @@ Bundle-SymbolicName: org.eclipse.xtext.example.ecoredsl.ui;singleton:=true
Bundle-Version: 0.7.0.qualifier
Require-Bundle: org.eclipse.xtext.ui.core,
org.eclipse.xtext.ui.common,
- org.eclipse.xtext.xtext.ui,
org.eclipse.ui.editors;bundle-version="3.4.0",
org.eclipse.ui,
org.eclipse.core.expressions;bundle-version="3.4.0",
diff --git a/examples/org.eclipse.xtext.example.fowlerdsl.ui/META-INF/MANIFEST.MF b/examples/org.eclipse.xtext.example.fowlerdsl.ui/META-INF/MANIFEST.MF
index 4ca7f0e..2d66582 100644
--- a/examples/org.eclipse.xtext.example.fowlerdsl.ui/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.xtext.example.fowlerdsl.ui/META-INF/MANIFEST.MF
@@ -10,7 +10,6 @@ Export-Package: org.eclipse.xtext.example
Require-Bundle: org.eclipse.xtext.example.fowlerdsl,
org.eclipse.xtext.ui.core,
org.eclipse.xtext.ui.common,
- org.eclipse.xtext.xtext.ui,
org.eclipse.xtext.xtend;bundle-version="0.7.0";resolution:=optional,
org.eclipse.ui.editors,
org.eclipse.ui
diff --git a/plugins/org.eclipse.xtext.ui.common/.classpath b/plugins/org.eclipse.xtext.ui.common/.classpath
index 64c5e31..59cf397 100644
--- a/plugins/org.eclipse.xtext.ui.common/.classpath
+++ b/plugins/org.eclipse.xtext.ui.common/.classpath
@@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.xtext.ui.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.xtext.ui.common/META-INF/MANIFEST.MF
index 7db78ee..dc3e557 100644
--- a/plugins/org.eclipse.xtext.ui.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.xtext.ui.common/META-INF/MANIFEST.MF
@@ -1,27 +1,28 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.xtext.ui.common;singleton:=true
-Bundle-Version: 0.7.0.qualifier
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.xtext.ui.core,
- org.eclipse.xtext.log4j;bundle-version="1.2.15",
- org.eclipse.ui.ide;bundle-version="3.4.0"
-Export-Package: org.eclipse.xtext.ui.common.editor.contentassist.impl,
- org.eclipse.xtext.ui.common.editor.folding,
- org.eclipse.xtext.ui.common.editor.formatting,
- org.eclipse.xtext.ui.common.editor.hover,
- org.eclipse.xtext.ui.common.editor.hyperlinking,
- org.eclipse.xtext.ui.common.editor.outline,
- org.eclipse.xtext.ui.common.editor.outline.impl,
- org.eclipse.xtext.ui.common.editor.preferencepage,
- org.eclipse.xtext.ui.common.editor.syntaxcoloring,
- org.eclipse.xtext.ui.common.editor.syntaxcoloring.antlr,
- org.eclipse.xtext.ui.common.editor.tasks,
- org.eclipse.xtext.ui.common.editor.tasks.dialogfields,
- org.eclipse.xtext.ui.common.service
-Eclipse-RegisterBuddy: org.eclipse.xtext.log4j
-Bundle-Activator: org.eclipse.xtext.ui.common.internal.Activator
-Bundle-ActivationPolicy: lazy
-Bundle-Vendor: %providerName
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.xtext.ui.common;singleton:=true
+Bundle-Version: 0.7.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.xtext.ui.core,
+ org.eclipse.xtext.log4j;bundle-version="1.2.15",
+ org.eclipse.ui.ide;bundle-version="3.4.0"
+Export-Package: org.eclipse.xtext.ui.common.editor.contentassist.impl,
+ org.eclipse.xtext.ui.common.editor.folding,
+ org.eclipse.xtext.ui.common.editor.formatting,
+ org.eclipse.xtext.ui.common.editor.hover,
+ org.eclipse.xtext.ui.common.editor.hyperlinking,
+ org.eclipse.xtext.ui.common.editor.outline,
+ org.eclipse.xtext.ui.common.editor.outline.impl,
+ org.eclipse.xtext.ui.common.editor.preferencepage,
+ org.eclipse.xtext.ui.common.editor.syntaxcoloring,
+ org.eclipse.xtext.ui.common.editor.syntaxcoloring.antlr,
+ org.eclipse.xtext.ui.common.editor.tasks,
+ org.eclipse.xtext.ui.common.editor.tasks.dialogfields,
+ org.eclipse.xtext.ui.common.service,
+ org.eclipse.xtext.common
+Eclipse-RegisterBuddy: org.eclipse.xtext.log4j
+Bundle-Activator: org.eclipse.xtext.ui.common.internal.Activator
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.xtext.ui.common/build.properties b/plugins/org.eclipse.xtext.ui.common/build.properties
index babf15d..230dd9c 100644
--- a/plugins/org.eclipse.xtext.ui.common/build.properties
+++ b/plugins/org.eclipse.xtext.ui.common/build.properties
@@ -1,4 +1,5 @@
-source.. = src/
+source.. = src/,\
+ src-gen/
output.. = bin/
bin.includes = META-INF/,\
.,\
diff --git a/plugins/org.eclipse.xtext.ui.common/plugin.xml_gen b/plugins/org.eclipse.xtext.ui.common/plugin.xml_gen
new file mode 100644
index 0000000..43a5dae
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.common/plugin.xml_gen
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+
+</plugin>
diff --git a/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsProposalProvider.java b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsProposalProvider.java
new file mode 100644
index 0000000..266bd5c
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsProposalProvider.java
@@ -0,0 +1,75 @@
+/*
+* generated by Xtext
+*/
+package org.eclipse.xtext.common;
+
+import org.apache.log4j.Logger;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.Alternatives;
+import org.eclipse.xtext.Assignment;
+import org.eclipse.xtext.CrossReference;
+import org.eclipse.xtext.RuleCall;
+import org.eclipse.xtext.ui.common.editor.contentassist.impl.AbstractJavaBasedContentProposalProvider;
+import org.eclipse.xtext.ui.core.editor.contentassist.ICompletionProposalAcceptor;
+import org.eclipse.xtext.ui.core.editor.contentassist.ContentAssistContext;
+
+/**
+ * Represents a generated, default implementation of interface {@link IProposalProvider}.
+ * Methods are dynamically dispatched on the first parameter, i.e., you can override them
+ * with a more concrete subtype.
+ */
+public class AbstractTerminalsProposalProvider extends AbstractJavaBasedContentProposalProvider {
+
+ private final static Logger logger = Logger.getLogger(AbstractTerminalsProposalProvider.class);
+
+
+ public void complete_ID(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("complete_ID '" + ruleCall.getRule().getName() + "' cardinality '" + ruleCall.getCardinality()
+ + "' for model '" + context.getCurrentModel() + "' and prefix '" + context.getPrefix() + "'");
+ }
+ // subclasses may override
+ }
+ public void complete_INT(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("complete_INT '" + ruleCall.getRule().getName() + "' cardinality '" + ruleCall.getCardinality()
+ + "' for model '" + context.getCurrentModel() + "' and prefix '" + context.getPrefix() + "'");
+ }
+ // subclasses may override
+ }
+ public void complete_STRING(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("complete_STRING '" + ruleCall.getRule().getName() + "' cardinality '" + ruleCall.getCardinality()
+ + "' for model '" + context.getCurrentModel() + "' and prefix '" + context.getPrefix() + "'");
+ }
+ // subclasses may override
+ }
+ public void complete_ML_COMMENT(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("complete_ML_COMMENT '" + ruleCall.getRule().getName() + "' cardinality '" + ruleCall.getCardinality()
+ + "' for model '" + context.getCurrentModel() + "' and prefix '" + context.getPrefix() + "'");
+ }
+ // subclasses may override
+ }
+ public void complete_SL_COMMENT(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("complete_SL_COMMENT '" + ruleCall.getRule().getName() + "' cardinality '" + ruleCall.getCardinality()
+ + "' for model '" + context.getCurrentModel() + "' and prefix '" + context.getPrefix() + "'");
+ }
+ // subclasses may override
+ }
+ public void complete_WS(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("complete_WS '" + ruleCall.getRule().getName() + "' cardinality '" + ruleCall.getCardinality()
+ + "' for model '" + context.getCurrentModel() + "' and prefix '" + context.getPrefix() + "'");
+ }
+ // subclasses may override
+ }
+ public void complete_ANY_OTHER(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("complete_ANY_OTHER '" + ruleCall.getRule().getName() + "' cardinality '" + ruleCall.getCardinality()
+ + "' for model '" + context.getCurrentModel() + "' and prefix '" + context.getPrefix() + "'");
+ }
+ // subclasses may override
+ }
+}
diff --git a/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsUiModule.java b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsUiModule.java
new file mode 100644
index 0000000..8655145
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/AbstractTerminalsUiModule.java
@@ -0,0 +1,20 @@
+
+/*
+ * generated by Xtext
+ */
+package org.eclipse.xtext.common;
+
+import org.eclipse.xtext.ui.common.service.DefaultUIModule;
+
+/**
+ * Manual modifications go to {org.eclipse.xtext.common.TerminalsUiModule}
+ */
+public abstract class AbstractTerminalsUiModule extends DefaultUIModule {
+
+
+
+ public Class<? extends org.eclipse.xtext.ui.core.editor.contentassist.IContentProposalProvider> bindIContentProposalProvider() {
+ return org.eclipse.xtext.common.TerminalsProposalProvider.class;
+ }
+
+}
diff --git a/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/TerminalsExecutableExtensionFactory.java b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/TerminalsExecutableExtensionFactory.java
new file mode 100644
index 0000000..e14e1e5
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/TerminalsExecutableExtensionFactory.java
@@ -0,0 +1,45 @@
+
+/*
+ * generated by Xtext
+ */
+
+package org.eclipse.xtext.common;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IExecutableExtensionFactory;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.Bundle;
+
+/**
+ * generated
+ */
+public class TerminalsExecutableExtensionFactory implements IExecutableExtensionFactory, IExecutableExtension {
+
+ private Logger log = Logger.getLogger(TerminalsExecutableExtensionFactory.class);
+ private String clazzName;
+
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException {
+ if (data instanceof String) {
+ clazzName = (String) data;
+ }
+ else {
+ throw new IllegalArgumentException("couldn't handle passed data : "+data);
+ }
+ }
+
+ public Object create() throws CoreException {
+ Bundle bundle = org.eclipse.xtext.common.internal.TerminalsActivator.getInstance().getBundle();
+ try {
+ Class<?> class1 = bundle.loadClass(clazzName);
+ return org.eclipse.xtext.common.internal.TerminalsActivator.getInstance().getInjector("org.eclipse.xtext.common.Terminals").getInstance(class1);
+ }
+ catch (Exception e) {
+ log.error(e);
+ throw new CoreException(new Status(Status.ERROR, bundle.getSymbolicName(), e.getMessage(),e));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/internal/TerminalsActivator.java b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/internal/TerminalsActivator.java
new file mode 100644
index 0000000..485539d
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.common/src-gen/org/eclipse/xtext/common/internal/TerminalsActivator.java
@@ -0,0 +1,51 @@
+
+/*
+ * generated by Xtext
+ */
+package org.eclipse.xtext.common.internal;
+
+import org.eclipse.xtext.ui.common.service.UIPluginModule;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Generated
+ */
+public class TerminalsActivator extends AbstractUIPlugin {
+
+ private Map<String,Injector> injectors = new HashMap<String,Injector>();
+ private static TerminalsActivator INSTANCE;
+
+ public Injector getInjector(String languageName) {
+ return injectors.get(languageName);
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ INSTANCE = this;
+
+ injectors.put("org.eclipse.xtext.common.Terminals", Guice.createInjector(
+ new org.eclipse.xtext.common.TerminalsRuntimeModule(),
+ new org.eclipse.xtext.common.TerminalsUiModule(),
+ createUIPluginModule()
+ ));
+
+ }
+
+ public static TerminalsActivator getInstance() {
+ return INSTANCE;
+ }
+
+ protected UIPluginModule createUIPluginModule() {
+ return new UIPluginModule(this);
+ }
+
+}
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsProposalProvider.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsProposalProvider.java
new file mode 100644
index 0000000..7bf1cc6
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsProposalProvider.java
@@ -0,0 +1,137 @@
+package org.eclipse.xtext.common;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.xtext.Assignment;
+import org.eclipse.xtext.GrammarUtil;
+import org.eclipse.xtext.RuleCall;
+import org.eclipse.xtext.conversion.IValueConverterService;
+import org.eclipse.xtext.ui.common.editor.contentassist.impl.ConfigurableCompletionProposal;
+import org.eclipse.xtext.ui.core.editor.contentassist.ContentAssistContext;
+import org.eclipse.xtext.ui.core.editor.contentassist.ICompletionProposalAcceptor;
+import org.eclipse.xtext.util.Strings;
+
+import com.google.inject.Inject;
+
+/**
+ * @author Sebastian Zarnekow - Initial contribution and API
+ */
+public class TerminalsProposalProvider extends org.eclipse.xtext.common.AbstractTerminalsProposalProvider {
+
+ @Inject
+ private IValueConverterService valueConverter;
+
+ @Override
+ public void complete_ID(EObject model, RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (doCreateIdProposals()) {
+ String feature = getAssignedFeature(ruleCall);
+ String proposalText = feature != null ? feature : Strings.toFirstUpper(ruleCall.getRule().getName().toLowerCase());
+ String displayText = proposalText;
+ if (feature != null)
+ displayText = proposalText + " - " + ruleCall.getRule().getName();
+ proposalText = valueConverter.toString(proposalText, ruleCall.getRule().getName());
+ ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context);
+ if (proposal instanceof ConfigurableCompletionProposal) {
+ ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
+ configurable.setSelectionStart(configurable.getReplacementOffset());
+ configurable.setSelectionLength(proposalText.length());
+ configurable.setAutoInsertable(false);
+ configurable.setSimpleLinkedMode(context.getViewer(), '\t', ' ');
+ }
+ acceptor.accept(proposal);
+ }
+ }
+
+ private String getAssignedFeature(RuleCall call) {
+ Assignment ass = GrammarUtil.containingAssignment(call);
+ if (ass != null) {
+ String result = ass.getFeature();
+ if (result.equals(result.toLowerCase()))
+ result = Strings.toFirstUpper(result);
+ return result;
+ }
+ return null;
+ }
+
+ @Override
+ public void complete_STRING(EObject model, RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (doCreateStringProposals()) {
+ String feature = getAssignedFeature(ruleCall);
+ createStringProposal(context, acceptor, feature, ruleCall);
+ }
+ }
+
+ private void createStringProposal(ContentAssistContext context, ICompletionProposalAcceptor acceptor,
+ String feature, RuleCall ruleCall) {
+ String proposalText = feature != null ? feature : Strings.toFirstUpper(ruleCall.getRule().getName().toLowerCase());
+ proposalText = valueConverter.toString(proposalText, ruleCall.getRule().getName());
+ String displayText = proposalText;
+ if (feature != null)
+ displayText = displayText + " - " + ruleCall.getRule().getName();
+ ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context);
+ if (proposal instanceof ConfigurableCompletionProposal) {
+ ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
+ configurable.setSelectionStart(configurable.getReplacementOffset() + 1);
+ configurable.setSelectionLength(proposalText.length() - 2);
+ configurable.setAutoInsertable(false);
+ configurable.setSimpleLinkedMode(context.getViewer(), proposalText.charAt(0), '\t');
+
+ }
+ acceptor.accept(proposal);
+ }
+
+ @Override
+ public void complete_INT(EObject model, RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ String feature = getAssignedFeature(ruleCall);
+ if (doCreateIntProposals()) {
+// createIntProposal(context, acceptor, feature, "0");
+ createIntProposal(context, acceptor, ruleCall, feature, 1);
+// createIntProposal(context, acceptor, feature, "2");
+// createIntProposal(context, acceptor, feature, "5");
+// createIntProposal(context, acceptor, feature, "10");
+// createIntProposal(context, acceptor, feature, "50");
+// createIntProposal(context, acceptor, feature, "100");
+// createIntProposal(context, acceptor, feature, "1000");
+ }
+ }
+
+ protected boolean doCreateIntProposals() {
+ return true;
+ }
+
+ protected boolean doCreateStringProposals() {
+ return true;
+ }
+
+ protected boolean doCreateIdProposals() {
+ return true;
+ }
+
+ private void createIntProposal(ContentAssistContext context, ICompletionProposalAcceptor acceptor,
+ RuleCall ruleCall, String feature, int i) {
+ String proposalText = valueConverter.toString(i, ruleCall.getRule().getName());
+ String displayText = proposalText + " - " + ruleCall.getRule().getName();
+ if (feature != null)
+ displayText = proposalText + " - " + feature;
+ ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context);
+ if (proposal instanceof ConfigurableCompletionProposal) {
+ ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
+ configurable.setSelectionStart(configurable.getReplacementOffset());
+ configurable.setSelectionLength(proposalText.length());
+ configurable.setAutoInsertable(false);
+ configurable.setSimpleLinkedMode(context.getViewer(), '\t', ' ');
+ }
+ acceptor.accept(proposal);
+ }
+
+ public void setValueConverter(IValueConverterService valueConverter) {
+ this.valueConverter = valueConverter;
+ }
+
+ public IValueConverterService getValueConverter() {
+ return valueConverter;
+ }
+}
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsUiModule.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsUiModule.java
new file mode 100644
index 0000000..d35f008
--- /dev/null
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/common/TerminalsUiModule.java
@@ -0,0 +1,17 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.xtext.common;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+
+/**
+ * Use this class to register components to be used within the IDE.
+ */
+public class TerminalsUiModule implements Module {
+
+ public void configure(Binder binder) {
+ }
+
+}
diff --git a/tests/org.eclipse.xtext.ui.common.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.xtext.ui.common.tests/META-INF/MANIFEST.MF
index 58280ae..f5c9476 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.xtext.ui.common.tests/META-INF/MANIFEST.MF
@@ -16,7 +16,6 @@ Require-Bundle: org.eclipse.ui,
org.easymock;bundle-version="2.3.0",
org.eclipse.jface.text;bundle-version="3.4.0",
org.eclipse.xtext.ui.core;bundle-version="0.7.0",
- org.eclipse.xtext.xtext.ui,
org.eclipse.xtext.xtend;bundle-version="0.7.0",
org.eclipse.xtext.example.domainmodel;bundle-version="0.7.0",
org.eclipse.xtext.example.domainmodel.ui;bundle-version="0.7.0",
@@ -31,7 +30,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.emf.common,
org.eclipse.xtend.typesystem.emf,
org.antlr.runtime,
- org.eclipse.ui.editors
+ org.eclipse.ui.editors,
+ org.eclipse.xtext.xtext.ui
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.xtext.ui.common,
diff --git a/tests/org.eclipse.xtext.ui.integration.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.xtext.ui.integration.tests/META-INF/MANIFEST.MF
index 1716186..a7ea802 100644
--- a/tests/org.eclipse.xtext.ui.integration.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.xtext.ui.integration.tests/META-INF/MANIFEST.MF
@@ -20,7 +20,6 @@ Require-Bundle: org.eclipse.xtext.generator;bundle-version="0.7.0",
org.eclipse.xtext;bundle-version="0.7.0",
org.eclipse.xtext.ui.common;bundle-version="0.7.0",
org.eclipse.xtext.ui.core;bundle-version="0.7.0",
- org.eclipse.xtext.xtext.ui,
org.eclipse.ui.ide;bundle-version="3.4.0",
org.junit;bundle-version="3.8.2",
org.eclipse.jdt.core;bundle-version="3.4.0",