Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteicher2005-09-09 07:25:51 +0000
committerteicher2005-09-09 07:25:51 +0000
commit799ef23c4e21b4f29e192314e9bccb78f69531da (patch)
treea0da42a154305c8cc6b3b29642b5995d54e698fe
parentf95b136792b5da8c4588039fbfc30d731ea5beff (diff)
downloadeclipse.platform.text-content_assist_participants.tar.gz
eclipse.platform.text-content_assist_participants.tar.xz
eclipse.platform.text-content_assist_participants.zip
- merged HEAD to branchcontent_assist_participants
- made computer descriptors package private - every access through the category - separate two prefs: separate command (and menu) vs. inclusion in default list - message label right aligned - no Alt+/ key for hippies - determinisic - show empty proposal list if there are none (only for subsequent invocations) - merged ca menus - set default preferences to exclude spelling
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ContentAssistInvocationContext.java3
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java84
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistEvent.java3
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java12
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionListener.java3
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalComputer.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties1
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistInvocationContext.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalComputer.java9
9 files changed, 98 insertions, 47 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ContentAssistInvocationContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ContentAssistInvocationContext.java
index 6b571ead0..7fab65d8e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ContentAssistInvocationContext.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ContentAssistInvocationContext.java
@@ -23,6 +23,9 @@ package org.eclipse.jface.contentassist;
* Clients may subclass but must be careful to adhere to the described
* {@link #equals(Object) equality} contract.
* </p>
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @since 3.2
*/
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index 68c10d8df..09056edd1 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
@@ -227,6 +227,10 @@ class CompletionProposalPopup implements IContentAssistListener {
* @since 3.2
*/
private int fLastCompletionOffset;
+ /**
+ * Usually <code>true</code>, <code>false</code> if the popup is displaying an empty list after repeated invocation.
+ */
+ private boolean fHasProposals;
/**
@@ -290,23 +294,27 @@ class CompletionProposalPopup implements IContentAssistListener {
int count= (fComputedProposals == null ? 0 : fComputedProposals.length);
if (count == 0) {
-
- if (!autoActivated)
- control.getDisplay().beep();
-
- hide();
-
- } else {
-
- if (count == 1 && !autoActivated && canAutoInsert(fComputedProposals[0])) {
- insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset);
+ if (fContentAssistant.recomputeOnRepetition()) {
+ fComputedProposals= computeProposals(fInvocationOffset);
+ count= (fComputedProposals == null ? 0 : fComputedProposals.length);
+ }
+ if (count == 0) {
+ if (!autoActivated)
+ control.getDisplay().beep();
+
hide();
- } else {
- createProposalSelector();
- setProposals(fComputedProposals, false);
- displayProposals();
+ return;
}
}
+
+ if (count == 1 && !autoActivated && canAutoInsert(fComputedProposals[0])) {
+ insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset);
+ hide();
+ } else {
+ createProposalSelector();
+ setProposals(fComputedProposals, false);
+ displayProposals();
+ }
}
});
} else {
@@ -323,15 +331,11 @@ class CompletionProposalPopup implements IContentAssistListener {
private void handleRepeatedInvocation() {
ICompletionProposal[] recomputed= null;
- do {
- if (fContentAssistant.recomputeOnRepetition()) {
- recomputed= computeProposals(fFilterOffset);
- } else {
- break;
- }
- } while (recomputed == null || recomputed.length == 0);
- if (recomputed != null)
- setProposals(recomputed, false);
+ if (fContentAssistant.recomputeOnRepetition()) {
+ recomputed= computeProposals(fFilterOffset);
+ if (recomputed != null)
+ setProposals(recomputed, false);
+ }
}
/**
@@ -390,10 +394,10 @@ class CompletionProposalPopup implements IContentAssistListener {
String message= fContentAssistant.getMessage();
if (message != null) {
- fMessageText= new Label(fProposalShell, SWT.LEFT);
+ fMessageText= new Label(fProposalShell, SWT.RIGHT);
GridData textData= new GridData(SWT.FILL, SWT.BOTTOM, true, false);
fMessageText.setLayoutData(textData);
- fMessageText.setText(message);
+ fMessageText.setText(message + " "); //$NON-NLS-1$
Font font= fMessageText.getFont();
Display display= fProposalShell.getDisplay();
FontData[] fontDatas= font.getFontData();
@@ -546,6 +550,9 @@ class CompletionProposalPopup implements IContentAssistListener {
*/
private void insertProposal(ICompletionProposal p, char trigger, int stateMask, final int offset) {
+ if (!fHasProposals)
+ return;
+
fInserting= true;
IRewriteTarget target= null;
IEditingSupport helper= new IEditingSupport() {
@@ -721,6 +728,15 @@ class CompletionProposalPopup implements IContentAssistListener {
ICompletionProposal oldProposal= getSelectedProposal();
if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null)
((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
+
+ if (proposals == null || proposals.length == 0) {
+ proposals= new ICompletionProposal[] { new CompletionProposal(JFaceTextMessages.getString("CompletionProposalPopup.no_proposals"), fFilterOffset, 0, 0)}; //$NON-NLS-1$
+ fProposalTable.setEnabled(false);
+ fHasProposals= false;
+ } else {
+ fProposalTable.setEnabled(true);
+ fHasProposals= true;
+ }
fFilteredProposals= proposals;
final int newLen= proposals.length;
@@ -1141,9 +1157,19 @@ class CompletionProposalPopup implements IContentAssistListener {
int count= (fFilteredProposals == null ? 0 : fFilteredProposals.length);
if (count == 0) {
- control.getDisplay().beep();
- hide();
- } else if (count == 1 && canAutoInsert(fFilteredProposals[0])) {
+ if (fContentAssistant.recomputeOnRepetition()) {
+ fFilteredProposals= computeProposals(fInvocationOffset);
+ count= (fFilteredProposals == null ? 0 : fFilteredProposals.length);
+ }
+
+ if (count == 0) {
+ control.getDisplay().beep();
+ hide();
+ return;
+ }
+ }
+
+ if (count == 1 && canAutoInsert(fFilteredProposals[0])) {
insertProposal(fFilteredProposals[0], (char) 0, 0, fInvocationOffset);
hide();
} else {
@@ -1379,6 +1405,6 @@ class CompletionProposalPopup implements IContentAssistListener {
public void setMessage(String message) {
Assert.isNotNull(message);
if (isActive() && fMessageText != null)
- fMessageText.setText(message);
+ fMessageText.setText(message + " "); //$NON-NLS-1$
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistEvent.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistEvent.java
index b5f291e2b..82935429e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistEvent.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistEvent.java
@@ -5,6 +5,9 @@ package org.eclipse.jface.text.contentassist;
* <p>
* Clients may use this class.
* </p>
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @since 3.2
*/
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index aadefd7d1..f0f126707 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -1922,6 +1922,9 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
/**
* Adds a completion listener that will be informed before proposals are computed.
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @param listener the listener
* @since 3.2
@@ -1933,6 +1936,9 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
/**
* Removes the completion listener.
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @param listener the listener to remove
* @since 3.2
@@ -1951,7 +1957,11 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
boolean recomputeOnRepetition() {
fRepetition++;
- return true;
+ return doRepetitionHandling();
+ }
+
+ private boolean doRepetitionHandling() {
+ return fMessage != null;
}
void resetRepetition() {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionListener.java
index 23f61a26e..49f843275 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionListener.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionListener.java
@@ -5,6 +5,9 @@ package org.eclipse.jface.text.contentassist;
* <p>
* Clients may implement this interface.
* </p>
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @since 3.2
*/
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalComputer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalComputer.java
index 42f479a8f..dc67a3b14 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalComputer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalComputer.java
@@ -16,34 +16,31 @@ import org.eclipse.core.runtime.IProgressMonitor;
/**
* Computes completions and context information displayed by a content assistant.
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @since 3.2
-*/
+ */
public interface ICompletionProposalComputer {
/**
- * Returns a list of completion proposals valid at the given
- * invocation context.
+ * Returns a list of completion proposals valid at the given invocation context.
*
* @param context the context of the content assist invocation
- * @param monitor a progress monitor to report progress. The monitor
- * is private to this invocation, i.e. there is no need for
- * the receiver to spawn a sub monitor.
- * @return an array of completion proposals (element type:
- * {@link ICompletionProposal})
+ * @param monitor a progress monitor to report progress. The monitor is private to this
+ * invocation, i.e. there is no need for the receiver to spawn a sub monitor.
+ * @return an array of completion proposals (element type: {@link ICompletionProposal})
*/
List computeCompletionProposals(TextContentAssistInvocationContext context, IProgressMonitor monitor);
/**
- * Returns context information objects valid at the given invocation
- * context.
+ * Returns context information objects valid at the given invocation context.
*
* @param context the context of the content assist invocation
- * @param monitor a progress monitor to report progress. The monitor
- * is private to this invocation, i.e. there is no need for
- * the receiver to spawn a sub monitor.
- * @return an array of context information objects (element type:
- * {@link IContextInformation})
+ * @param monitor a progress monitor to report progress. The monitor is private to this
+ * invocation, i.e. there is no need for the receiver to spawn a sub monitor.
+ * @return an array of context information objects (element type: {@link IContextInformation})
*/
List computeContextInformation(TextContentAssistInvocationContext context, IProgressMonitor monitor);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties
index fc0436b49..b35cad9b3 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties
@@ -13,3 +13,4 @@
InfoPopup.info_delay_timer_name=AdditionalInfo Delay
ContentAssistant.assist_delay_timer_name=AutoAssist Delay
+CompletionProposalPopup.no_proposals=no proposals
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistInvocationContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistInvocationContext.java
index b56e1db72..3c5669c7a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistInvocationContext.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/TextContentAssistInvocationContext.java
@@ -24,6 +24,9 @@ import org.eclipse.jface.contentassist.ContentAssistInvocationContext;
* <p>
* Clients may instantiate and subclass.
* </p>
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @since 3.2
*/
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalComputer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalComputer.java
index cba1cffcf..6e2054b73 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalComputer.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalComputer.java
@@ -41,8 +41,13 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.texteditor.HippieCompletionEngine;
/**
- * A completion proposal computer for hippie word completions. Clients
- * may instantiate. TODO API doc.
+ * A completion proposal computer for hippie word completions.
+ * <p>
+ * Clients may instantiate.
+ * </p>
+ * <p>
+ * XXX this API is provisional and may change anytime during the course of 3.2
+ * </p>
*
* @since 3.2
*/

Back to the top