summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-23 16:56:36 (EDT)
committer sefftinge2009-04-23 16:56:36 (EDT)
commitf5fbb1afcf727c852402eb33254e1f712bdb7866 (patch)
treea30ef8c743b608dd803ad361b024a35f9725bb58
parent671e55f338352e0b90d785d08a92131bb258767e (diff)
downloadorg.eclipse.xtext-f5fbb1afcf727c852402eb33254e1f712bdb7866.zip
org.eclipse.xtext-f5fbb1afcf727c852402eb33254e1f712bdb7866.tar.gz
org.eclipse.xtext-f5fbb1afcf727c852402eb33254e1f712bdb7866.tar.bz2
ContentAssist: TerminalProposals use ValueConverter
-rwxr-xr-xplugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaBasedContentProposalProvider.java13
-rwxr-xr-xtests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractContentAssistProcessorTest.java15
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java10
3 files changed, 24 insertions, 14 deletions
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaBasedContentProposalProvider.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaBasedContentProposalProvider.java
index 1b1df84..9fe57df 100755
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaBasedContentProposalProvider.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaBasedContentProposalProvider.java
@@ -104,15 +104,22 @@ public abstract class AbstractJavaBasedContentProposalProvider extends AbstractC
/**
* @see #createCompletionProposal(AbstractElement, String, IContentAssistContext, Image)
*/
+ protected ICompletionProposal createCompletionProposal(EObject element, String name, String displayName, ContentAssistContext contentAssistContext) {
+ return createCompletionProposal(name, displayName, getImage(element), contentAssistContext);
+ }
+
+ /**
+ * @see #createCompletionProposal(AbstractElement, String, IContentAssistContext, Image)
+ */
protected ICompletionProposal createCompletionProposal(IScopedElement element, String prefix, ContentAssistContext contentAssistContext) {
- return createCompletionProposal(element.element(), element.name(), prefix, contentAssistContext);
+ return createCompletionProposal(element.element(), element.name(), element.name(), prefix, contentAssistContext);
}
/**
* @see #createCompletionProposal(AbstractElement, String, IContentAssistContext, Image)
*/
- protected ICompletionProposal createCompletionProposal(EObject element, String name, String prefix, ContentAssistContext contentAssistContext) {
- return createCompletionProposal(name, name, getImage(element), prefix, contentAssistContext);
+ protected ICompletionProposal createCompletionProposal(EObject element, String name, String displayName, String prefix, ContentAssistContext contentAssistContext) {
+ return createCompletionProposal(name, displayName, getImage(element), prefix, contentAssistContext);
}
/**
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractContentAssistProcessorTest.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractContentAssistProcessorTest.java
index b3c4e56..83beeb7 100755
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractContentAssistProcessorTest.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractContentAssistProcessorTest.java
@@ -54,7 +54,7 @@ public abstract class AbstractContentAssistProcessorTest extends AbstractXtextTe
public void testComputeCompletionProposalsCount() throws Exception {
newBuilder(setup.getRefGrammarSetup()).assertCount(1)
.append("spielplatz ").assertCount(1)
- .append("1 ").assertCount(3)
+ .append("1 ").assertCount(2)
.append("\"JUNIT\" ").assertCount(1)
.append("{ ").assertCount(5)
.append("kind ").assertCount(1)
@@ -65,20 +65,20 @@ public abstract class AbstractContentAssistProcessorTest extends AbstractXtextTe
public void testComputeCompletionProposalsText() throws Exception {
newBuilder(setup.getRefGrammarSetup()).assertText("spielplatz")
- .applyText().assertText("1 - Groesse")
- .applyText().assertText("\"Beschreibung\"", "'Beschreibung'", "{")
+ .applyText().assertText("1")
+ .applyText().assertText("\"Beschreibung\"", "{")
.applyText().assertText("{")
.applyText().assertText("erwachsener", "familie", "spielzeug", "kind", "}")
.append("erwachsener ").assertText("(")
.applyText().assertText("Name")
- .append("e1 ").assertText("1 - Age")
+ .append("e1 ").assertText("1")
.applyText().assertText(")")
.applyText().append("erwachsener (e2 0) kind ").assertText("(")
.applyText().assertText("Name")
- .append("k1 ").assertText("1 - Age")
+ .append("k1 ").assertText("1")
.applyText().assertText(")")
.applyText().append("kind (k2 0) familie ").assertText("(")
- .applyText().assertText("keyword", "'Name'", "\"Name\"", "Name")
+ .applyText().assertText("keyword", "\"Name\"", "Name")
.append("keyword ").assertText("e1","e2")
.applyText().assertText("e1","e2")
.append("e2 ").assertText("k1","k2")
@@ -155,7 +155,6 @@ public abstract class AbstractContentAssistProcessorTest extends AbstractXtextTe
"R2",
"R3",
"\"Value\"",
- "'Value'",
"(",
"[",
"+=" // current node is always a suggestion
@@ -264,7 +263,6 @@ public abstract class AbstractContentAssistProcessorTest extends AbstractXtextTe
"R2",
"R3",
"\"Value\"",
- "'Value'",
"(",
"["
);
@@ -307,7 +305,6 @@ public abstract class AbstractContentAssistProcessorTest extends AbstractXtextTe
.appendNl("generate foo \"foo\"")
.append("MyRule : 'foo' name").assertText(
"\"Value\"",
- "'Value'",
"(",
"*",
"+",
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java
index 8f5b42a..d9668eb 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java
@@ -140,9 +140,12 @@ public class ContentAssistProcessorTestBuilder {
for (int i = 0; i < computeCompletionProposals.length; i++) {
ICompletionProposal completionProposal = computeCompletionProposals[i];
+ String proposedText = completionProposal.getDisplayString();
+ if (completionProposal instanceof ConfigurableCompletionProposal)
+ proposedText = ((ConfigurableCompletionProposal) completionProposal).getReplacementString();
Assert.assertTrue("expect completionProposal text '" + expectation + "', but got " +
Strings.concat(", ", toString(computeCompletionProposals)),
- Arrays.asList(expectedText).contains(completionProposal.getDisplayString()));
+ Arrays.asList(expectedText).contains(proposedText));
}
return this;
@@ -181,7 +184,10 @@ public class ContentAssistProcessorTestBuilder {
return Collections.emptyList();
List<String> res = new ArrayList<String>(proposals.length);
for (ICompletionProposal proposal : proposals) {
- res.add(proposal.getDisplayString());
+ String proposedText = proposal.getDisplayString();
+ if (proposal instanceof ConfigurableCompletionProposal)
+ proposedText = ((ConfigurableCompletionProposal) proposal).getReplacementString();
+ res.add(proposedText);
}
return res;
}