summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormclay2008-11-11 17:26:34 (EST)
committer sefftinge2008-11-11 17:26:34 (EST)
commit08fd787c3554b47c28117b3daf59532b9a1f4db4 (patch)
tree0d08d0e0db92f8853fbab6671ec90d2d208c1ca9
parent003bdef491f992f4d749d6b0274a29a37deaeefa (diff)
downloadorg.eclipse.xtext-08fd787c3554b47c28117b3daf59532b9a1f4db4.zip
org.eclipse.xtext-08fd787c3554b47c28117b3daf59532b9a1f4db4.tar.gz
org.eclipse.xtext-08fd787c3554b47c28117b3daf59532b9a1f4db4.tar.bz2
upd: use IXtextDocument instead of XtextDocument
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/codecompletion/DefaultContentAssistProcessor.java36
1 files changed, 19 insertions, 17 deletions
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/codecompletion/DefaultContentAssistProcessor.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/codecompletion/DefaultContentAssistProcessor.java
index 32f855b..6331160 100644
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/codecompletion/DefaultContentAssistProcessor.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/codecompletion/DefaultContentAssistProcessor.java
@@ -34,8 +34,8 @@ import org.eclipse.xtext.parsetree.NodeUtil;
import org.eclipse.xtext.parsetree.ParseTreeUtil;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.service.Inject;
+import org.eclipse.xtext.ui.core.editor.model.IXtextDocument;
import org.eclipse.xtext.ui.core.editor.model.UnitOfWork;
-import org.eclipse.xtext.ui.core.editor.model.XtextDocument;
/**
* @author Michael Clay - Initial contribution and API
@@ -49,6 +49,14 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor {
@Inject
private IProposalProvider proposalProvider;
+
+
+ /**
+ * @param proposalProvider the proposalProvider to set
+ */
+ public void setProposalProvider(IProposalProvider proposalProvider) {
+ this.proposalProvider = proposalProvider;
+ }
/**
* computes the possible grammar elements following the one at the given
@@ -62,11 +70,11 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor {
IDocument document = viewer.getDocument();
- if (document instanceof XtextDocument) {
+ if (document instanceof IXtextDocument) {
List<ICompletionProposal> completionProposalList = new ArrayList<ICompletionProposal>();
- XtextDocument xtextDocument = (XtextDocument) document;
+ IXtextDocument xtextDocument = (IXtextDocument) document;
CompositeNode rootNode = xtextDocument.readOnly(new UnitOfWork<CompositeNode>() {
public CompositeNode exec(XtextResource resource) throws Exception {
@@ -115,23 +123,17 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor {
ProposalProviderInvokerSwitch proposalProviderInvokerSwitch = new ProposalProviderInvokerSwitch(model,
document, offset, prefix, proposalProvider);
- try {
- for (List<EObject> resolvedElementOrRuleList : new ProposalCandidateResolverSwitch(
- nextValidElementSet)) {
+ for (List<EObject> resolvedElementOrRuleList : new ProposalCandidateResolverSwitch(nextValidElementSet)) {
- List<ICompletionProposal> collectedCompletionProposalList = proposalProviderInvokerSwitch
- .collectCompletionProposalList(resolvedElementOrRuleList);
+ List<ICompletionProposal> collectedCompletionProposalList = proposalProviderInvokerSwitch
+ .collectCompletionProposalList(resolvedElementOrRuleList);
- completionProposalList.addAll(collectedCompletionProposalList);
- }
- if (completionProposalList != null) {
- List<? extends ICompletionProposal> processedCompletionProposalList = proposalProvider
- .sortAndFilter(completionProposalList, model, prefix, document, offset);
- completionProposals = processedCompletionProposalList.toArray(new ICompletionProposal[] {});
- }
+ completionProposalList.addAll(collectedCompletionProposalList);
}
- catch (Exception e) {
- e.printStackTrace();
+ if (completionProposalList != null) {
+ List<? extends ICompletionProposal> processedCompletionProposalList = proposalProvider
+ .sortAndFilter(completionProposalList, model, prefix, document, offset);
+ completionProposals = processedCompletionProposalList.toArray(new ICompletionProposal[] {});
}
}
}