Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java')
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java
new file mode 100644
index 00000000000..d4d64acee51
--- /dev/null
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat Inc. 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
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.ui.internal.genericeditor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+/**
+ * A content assist processor that delegates all content assist
+ * operations to children provided in constructor and aggregates
+ * the results.
+ *
+ * @since 1.0
+ */
+public class CompositeContentAssistProcessor implements IContentAssistProcessor {
+
+ private List<IContentAssistProcessor> fContentAssistProcessors;
+
+ /**
+ * Constructor
+ * @param contentAssistProcessors the children that will actually populate the output
+ * of this content assist processor.
+ */
+ public CompositeContentAssistProcessor(List<IContentAssistProcessor> contentAssistProcessors) {
+ fContentAssistProcessors= contentAssistProcessors;
+ }
+
+ @Override
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ List<ICompletionProposal> res = new ArrayList<>();
+ for (IContentAssistProcessor processor : this.fContentAssistProcessors) {
+ res.addAll(Arrays.asList(processor.computeCompletionProposals(viewer, offset)));
+ }
+ return res.toArray(new ICompletionProposal[res.size()]);
+ }
+
+ @Override
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ List<IContextInformation> res = new ArrayList<>();
+ for (IContentAssistProcessor processor : this.fContentAssistProcessors) {
+ res.addAll(Arrays.asList(processor.computeContextInformation(viewer, offset)));
+ }
+ return res.toArray(new IContextInformation[res.size()]);
+ }
+
+ @Override
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return null;
+ }
+
+ @Override
+ public char[] getContextInformationAutoActivationCharacters() {
+ return null;
+ }
+
+ @Override
+ public String getErrorMessage() {
+ StringBuilder res = new StringBuilder();
+ for (IContentAssistProcessor processor : this.fContentAssistProcessors) {
+ String errorMessage = processor.getErrorMessage();
+ if (errorMessage != null) {
+ res.append(errorMessage);
+ res.append('\n');
+ }
+ }
+ if (res.length() == 0) {
+ return null;
+ } else {
+ return res.toString();
+ }
+ }
+
+ @Override
+ public IContextInformationValidator getContextInformationValidator() {
+ return null;
+ }
+
+} \ No newline at end of file

Back to the top