summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormclay2009-03-12 19:16:37 (EDT)
committer sefftinge2009-03-12 19:16:37 (EDT)
commitcb271857e1134f29654636b6a6c395a50d0a9b72 (patch)
treed9077fdfae1c49e5ca41d20a4fcadb4b8ecfa576
parenta580428f3816b2603069236cde8bd3dac5e301a6 (diff)
downloadorg.eclipse.xtext-cb271857e1134f29654636b6a6c395a50d0a9b72.zip
org.eclipse.xtext-cb271857e1134f29654636b6a6c395a50d0a9b72.tar.gz
org.eclipse.xtext-cb271857e1134f29654636b6a6c395a50d0a9b72.tar.bz2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=268220
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java3
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java16
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java8
3 files changed, 16 insertions, 11 deletions
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java
index 3887552..af9a2c1 100644
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.AbstractRule;
+import org.eclipse.xtext.Action;
import org.eclipse.xtext.Alternatives;
import org.eclipse.xtext.Assignment;
import org.eclipse.xtext.CrossReference;
@@ -130,7 +131,7 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle
isOptional = isOptional(abstractElement);
}
- } else {
+ } else if (!(groupElement instanceof Action)) {
isOptional = GrammarUtil.isOptionalCardinality(groupElement);
}
return isOptional;
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java
index a20759e..93bf1c5 100644
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java
@@ -43,7 +43,6 @@ import org.eclipse.xtext.ui.common.editor.contentassist.IProposalProvider;
import org.eclipse.xtext.ui.common.editor.contentassist.ITemplateContentAssistProcessor;
import org.eclipse.xtext.ui.core.editor.model.IXtextDocument;
import org.eclipse.xtext.ui.core.editor.model.UnitOfWork;
-import org.eclipse.xtext.util.Strings;
import com.google.inject.Inject;
@@ -192,16 +191,15 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor {
CompositeNode rootNode = parseResult.getRootNode();
AbstractNode referenceNode = ParseTreeUtil.getLastCompleteNodeByOffset(rootNode, offset);
AbstractNode nodeAtOffset = ParseTreeUtil.getCurrentOrFollowingNodeByOffset(rootNode, offset);
-
+
if (referenceNode.getOffset()+referenceNode.getLength() == offset) {
- AbstractNode precedingReferenceNode = ParseTreeUtil.getLastCompleteNodeByOffset(rootNode,Math.max(0, referenceNode.getOffset()-1));
- String matchingString = calculateMatchString(nodeAtOffset,text, offset);
+ AbstractNode precedingReferenceNode = ParseTreeUtil.getLastCompleteNodeByOffset(rootNode,Math.max(0, referenceNode.getOffset()));
+ String matchingString = referenceNode.serialize();
result.add(newCompletionProposal(matchingString, offset, rootNode, precedingReferenceNode));
- if (!Strings.isEmpty(matchingString) &&
- referenceNode.getGrammarElement() instanceof Keyword ||
- referenceNode.getGrammarElement() instanceof CrossReference ||
- (referenceNode.getGrammarElement() instanceof RuleCall &&
- ((RuleCall)referenceNode.getGrammarElement()).getRule() instanceof TerminalRule)) {
+ if (referenceNode.getGrammarElement() instanceof Keyword ||
+ referenceNode.getGrammarElement() instanceof CrossReference ||
+ (referenceNode.getGrammarElement() instanceof RuleCall &&
+ ((RuleCall)referenceNode.getGrammarElement()).getRule() instanceof TerminalRule)) {
result.add(newCompletionProposal("", offset, rootNode, referenceNode));
}
} else {
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java
index c36c587..9dadf16 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java
@@ -127,6 +127,12 @@ public class DefaultContentAssistProcessorTest extends AbstractXtextTests {
}
+ public void testBetweenContext() throws Exception {
+ newBuilder(getRefGrammarSetup())
+ .append("spielplatz 1 \"1\" {kind")
+ .assertTextAtCursorPosition(18,"kind","erwachsener","spielzeug","familie","}");
+ }
+
public void testComputeCompletionProposalsIgnoreCase() throws Exception {
ContentAssistProcessorTestBuilder builder = newBuilder(getRefGrammarSetup());
builder = builder.append("spielplatz 1 \"SpielplatzBeschreibung\" { kind(k1 0) kind(k2 0) erwachsener(e1 0) erwachsener(e2 0) ");
@@ -139,7 +145,7 @@ public class DefaultContentAssistProcessorTest extends AbstractXtextTests {
builder.append(" familie ( keyword E").assertText("e1", "e2");
builder.append(" familie ( keyword e1 E").assertText("e1", "e2","k1","k2");
builder.append(" familie ( keyword e1 e2 K").assertText("k1", "k2", ",", ")");
- builder.append(" familie ( keyword e1 e2 k1,K").assertText(",", ")");
+ builder.append(" familie ( keyword e1 e2 k1,K").assertText("k1", "k2",",", ")");
builder.append(" familie ( keyword e1 e2 k1,k2").assertText(",", ")");
}